8000 GitHub - jamesbachini/Stella: An Agentic AI Chat Assistant For The Stellar Community · GitHub
[go: up one dir, main page]

Skip to content
jamesbachiniPublic

About

An Agentic AI Chat Assistant For The Stellar Community

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Stella

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.

Features

  • 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.

Tech Stack

  • 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-parse for attachment handling.
  • Vitest for tests.

Getting Started

Prerequisites

  • Node.js 20 or newer is recommended.
  • An OpenRouter API key.

Install

npm install

Configure

Create a local .env file from the example:

cp .env.example .env

Then set at least:

OPENROUTER_API_KEY=your_openrouter_key
STELLA_API_KEYS=["stella-local-dev-key"]
VITE_STELLA_API_KEY=stella-local-dev-key

The 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

Development

Start the frontend and backend together:

npm run dev

This 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.

Available Scripts

npm run dev
npm run build
npm start
npm test
  • npm run dev starts the TypeScript server watcher with Vite middleware.
  • npm run build compiles the server and builds the client into dist/.
  • npm start runs the built server from dist/server.
  • npm test runs the Vitest test suite.

Project Structure

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

API Overview

GET /api/health

Returns:

{ "ok": true }

POST /api/chat

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-key

The 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" }

Attachment Support

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.

Custom Context

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.

Testing

Run:

npm test

Current 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.

Production Build

Build the app:

npm run build

Run the compiled server:

npm start

The production Express server serves the built frontend from dist/client and exposes the API routes from the same process.

Security Notes

  • Do not commit .env or real API keys.
  • Keep OpenRouter access server-side only.
  • Treat VITE_STELLA_API_KEY as a lightweight access gate, not a secret; it is included in the browser bundle.
  • /api/chat allows 10 accepted requests per minute server-wide by default and returns 429 with Rate limit exceeded when the limit is hit.
  • Preserve upload size and type checks when extending attachment support.
  • Treat context/system.md as application behavior configuration, not a place for secrets.

About

An Agentic AI Chat Assistant For The Stellar Community

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0