Market Mind is a full-stack AI research assistant that provides real-time financial and crypto intelligence. The agent combines live DuckDuckGo market signals, a LangGraph workflow orchestrated by LangChain, Chroma vector memory, and PostgreSQL chat history to deliver contextualised investment insights with usage limits and Langfuse observability.
.
├── backend/ # FastAPI + LangChain backend (Python 3.12, uv managed)
├── frontend/ # React + Vite + Tailwind chat interface with Zustand store
├── charts/ # Helm charts for k3s deployments (frontend & backend)
├── docker-compose.yml # Multi-service stack for local Docker workflows
├── .devcontainer/ # VS Code Dev Container definition
├── .env # Runtime configuration (copy-safe defaults)
└── README.md
- Stateful LangGraph agent using LangChain, OpenAI
gpt-4o, DuckDuckGo search, and Chroma persistent vector store. - PostgreSQL persistence for chat sessions and message history.
- Rate limiting per user (hourly/daily) to prevent abuse.
- Langfuse instrumentation hooks for trace monitoring.
- React chat UI with multiple conversations, dark/light themes, and Zustand-based state management.
- Dockerfiles, Docker Compose, VS Code DevContainer, and Helm charts for seamless local dev and k3s deployment.
- Python >= 3.12 with uv (
pip install uv). - Node.js >= 20 and npm >= 10.
- Docker & Docker Compose (optional).
- k3s / Kubernetes cluster with Helm (optional for deployment).
Environment variables are managed through .env in the repository root. Duplicate the defaults if you need private overrides:
cp .env.example .envUpdate the following keys before running production workloads:
OPENAI_API_KEYLANGFUSE_PUBLIC_KEY,LANGFUSE_SECRET_KEYDATABASE_URL(if not using Docker Compose defaults)
For local development outside Docker, set DATABASE_URL to your host Postgres connection string (e.g. postgresql+psycopg://market_mind:market_mind@localhost:5432/market_mind) and run PostgreSQL/Chroma manually or via Docker.
-
Start dependencies (optional but recommended via Compose)
docker compose up postgres chroma
-
Backend
cd backend uv sync uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload -
Frontend
cd frontent npm install npm run dev
The chat UI is available at http://localhost:5173 (proxied to the backend on http://localhost:8000). Supply an X-User-Id header to the backend if you integrate via API; the frontend handles this automatically.
- Health check:
GET http://localhost:8000/health - Create chat:
POST http://localhost:8000/chats - Send message:
POST http://localhost:8000/chats/{chatId}/messages
Build and run the whole stack:
docker compose up --buildServices launched:
frontend→ http://localhost:5173backend→ http://localhost:8000postgres(data persisted topostgres_datavolume)chroma(vector store persisted tochroma_data)
Override environment variables by editing .env before starting Compose.
- Install the Dev Containers extension.
- Open the repository in VS Code and select Reopen in Container.
- The container pre-installs Python 3.12, Node 20, uv, project dependencies, and recommended extensions. Docker Compose brings up the
postgresandchromaservices automatically; other services can be started manually as needed.
After launch:
# Backend shell
cd backend
uv run uvicorn app.main:app --reload
# Frontend shell
cd frontend
npm run devBackend (pytest):
cd backend
uv run pytestFrontend (Vitest):
cd frontend
npm run testCI scripts can call these commands to validate both layers.
-
Build and push images
# Backend docker build -t ghcr.io/<org>/market-mind-backend:latest backend docker push ghcr.io/<org>/market-mind-backend:latest # Frontend (build with API endpoint baked in) docker build --build-arg VITE_API_URL=http://market-mind-backend:8000 \ -t ghcr.io/<org>/market-mind-frontend:latest frontend docker push ghcr.io/<org>/market-mind-frontend:latest
-
Create a namespace and override values
kubectl create namespace market-mind
Prepare override files (or use
--setflags) to supply secrets safely:# backend-values.yaml image: repository: ghcr.io/<org>/market-mind-backend tag: latest env: OPENAI_API_KEY: "<openai-key>" LANGFUSE_PUBLIC_KEY: "<langfuse-public>" LANGFUSE_SECRET_KEY: "<langfuse-secret>" DATABASE_URL: "postgresql+psycopg://market_mind:market_mind@postgresql:5432/market_mind"
# frontend-values.yaml image: repository: ghcr.io/<org>/market-mind-frontend tag: latest env: VITE_API_URL: "http://market-mind-backend:8000"
-
Install the charts
helm install market-mind-backend charts/backend -n market-mind -f backend-values.yaml helm install market-mind-frontend charts/frontend -n market-mind -f frontend-values.yaml
-
Verify
kubectl get pods -n market-mind kubectl get svc -n market-mind
The backend chart provisions a persistent volume for Chroma. Point DATABASE_URL at your managed PostgreSQL instance or reference an in-cluster service. For TLS/ingress, fill ingress.hosts and ingress.tls or integrate with your preferred controller (e.g., Traefik/NGINX).
- Langfuse: configure
LANGFUSE_PUBLIC_KEY,LANGFUSE_SECRET_KEY, andLANGFUSE_HOST(default cloud endpoint) to enable tracing. Without credentials the backend gracefully disables Langfuse calls. - Rate limiting: defaults to 60 requests/hour and 500 requests/day per
X-User-Id. Override withHOURLY_REQUEST_LIMIT/DAILY_REQUEST_LIMIT.
- Run
uv run python -m app.scripts.purge_chats --older-than-hours 24locally or in CI to wipe chats older than a day (omit the flag to delete everything). - Enable the automated cleanup CronJob in the backend Helm chart by setting:
This reuses the backend image to execute the purge script inside the cluster once per schedule.
cleanup: enabled: true schedule: "0 3 * * *" # UTC time to run olderThanHours: 24
- Integrate authenticated user IDs to align rate limits with your identity provider.
- Automate database migrations via Alembic before deploying to production.
- Harden the Docker images (distroless, multi-stage builds) and add CI pipelines.
Happy hacking!