Stella is a Stellar-focused AI chat assistant with a React/Vite frontend and an Express backend. It streams responses from OpenRouter, retrieves relevant Stellar Developer Docs from a local docs checkout, and can include uploaded text or PDF files as extra context for each chat turn.
- Streaming chat responses over newline-delimited JSON.
- Local Stellar Developer Docs retrieval for Stella v2.
- Mintlify assistant API mode for the Mintlify AI option.
- Editable system/context prompt in
context/system.md. - Local browser conversation history.
- File attachments for text-like files and PDFs.
- Source links surfaced in the chat UI when retrieved docs include URLs.
- Vitest coverage for chat helpers and prompt/context assembly.
- React 19 and Vite for the client.
- Express 5 and TypeScript for the server.
- OpenRouter chat completions for model responses.
- Local hybrid search over Markdown/MDX Stellar docs.
- Multer and
pdf-parsefor attachment handling. - Vitest for tests.
- Node.js 20 or newer is recommended.
- An OpenRouter API key.
npm installCreate a local .env file from the example:
cp .env.example .envThen set at least:
OPENROUTER_API_KEY=your_openrouter_key
STELLA_API_KEYS=["stella-local-dev-key"]
VITE_STELLA_API_KEY=stella-local-dev-keyThe default .env.example values are:
| Variable | Purpose | Default |
|---|---|---|
OPENROUTER_API_KEY |
Required for real chat responses. | empty |
STELLA_API_KEYS |
JSON array or comma-separated list of app access keys accepted by /api/chat. |
["stella-local-dev-key"] |
VITE_STELLA_API_KEY |
Browser app access key sent in the X-Stella-API-Key header. Must match one value in STELLA_API_KEYS. |
stella-local-dev-key |
RATE_LIMIT_MAX_REQUESTS |
Server-wide maximum accepted chat requests per rate-limit window. | 10 |
RATE_LIMIT_WINDOW_MS |
Rate-limit window length in milliseconds. | 60000 |
PORT |
Express server port. | 3028 |
OPENROUTER_MODEL |
OpenRouter model id. | deepseek/deepseek-v4-pro |
MINTLIFY_API_KEY |
Required for Mintlify assistant mode if the API is enabled. | empty |
MINTLIFY_DOMAIN |
Mintlify assistant domain. | stellardevelopmentfoundation |
STELLAR_DOCS_ROOT |
Local Stellar docs directory searched by Stella v2. | stellar-docs/docs |
STELLAR_DOCS_BASE_URL |
Public URL prefix used for local docs citations. | https://developers.stellar.org/docs |
DOCS_CONTEXT_MAX_CHARS |
Maximum local docs context added to each Stella v2 turn. | 16000 |
CUSTOM_CONTEXT_PATH |
Path to the editable system/context prompt. | context/system.md |
MAX_FILES |
Maximum attachments per message. | 5 |
MAX_FILE_BYTES |
Maximum bytes per uploaded file. | 8388608 |
Start the frontend and backend together:
npm run devThis runs Express with tsx watch server/index.ts on http://localhost:3028.
In development, Express mounts Vite as middleware, so the frontend and /api
routes share the same port. In production, the server uses PORT from .env
or falls back to 3028.
npm run dev
npm run build
npm start
npm testnpm run devstarts the TypeScript server watcher with Vite middleware.npm run buildcompiles the server and builds the client intodist/.npm startruns the built server fromdist/server.npm testruns the Vitest test suite.
server/
index.ts Express app, routes, streaming response handling
openrouter.ts OpenRouter streaming client
docsSearch.ts Local Stellar docs indexing, ranking, and retrieval
files.ts Text and PDF extraction for attachments
context.ts Prompt assembly and message sanitization
config.ts Environment configuration
client/src/
App.tsx Main chat UI
chat.ts Conversation storage and helper functions
styles.css Application styles
context/
system.md Custom system/context prompt loaded by the server
tests/
*.test.ts Vitest tests
Returns:
{ "ok": true }Accepts multipart/form-data:
message: required user message.messages: optional JSON-encoded chat history.files: optional uploaded attachments.
Requests must include the configured app key:
X-Stella-API-Key: stella-local-dev-keyThe response is streamed as newline-delimited JSON events:
{ "type": "sources", "sources": [] }
{ "type": "delta", "text": "Partial response text" }
{ "type": "done", "sources": [] }If an error occurs, the stream includes:
{ "type": "error", "error": "Message" }Stella accepts PDFs and common text-like files, including:
.txt,.md,.mdx,.json,.csv- TypeScript, JavaScript, CSS, HTML, XML
- YAML, TOML, Python, Go, Rust, Java, Solidity, shell scripts
Each extracted file is truncated to 40,000 characters before being added to the prompt. Uploaded file count and size are controlled by MAX_FILES and MAX_FILE_BYTES.
Edit context/system.md to change Stella's baseline behavior without changing code. The server loads this file for every chat request and combines it with retrieved Stellar docs context.
If the file is missing or empty, the server falls back to a built-in Stellar-focused assistant prompt.
Run:
npm testCurrent tests cover:
- Chat title/id helpers.
- Chat history sanitization.
- File context insertion.
- System prompt assembly with retrieved docs.
Add or update tests when changing prompt assembly, streaming parsing, retrieval behavior, file extraction, or conversation helpers.
Build the app:
npm run buildRun the compiled server:
npm startThe production Express server serves the built frontend from dist/client and exposes the API routes from the same process.
- Do not commit
.envor real API keys. - Keep OpenRouter access server-side only.
- Treat
VITE_STELLA_API_KEYas a lightweight access gate, not a secret; it is included in the browser bundle. /api/chatallows 10 accepted requests per minute server-wide by default and returns429withRate limit exceededwhen the limit is hit.- Preserve upload size and type checks when extending attachment support.
- Treat
context/system.mdas application behavior configuration, not a place for secrets.