{"id":32663309,"url":"https://github.com/gmunumel/market-mind","last_synced_at":"2026-04-07T22:31:19.600Z","repository":{"id":320539499,"uuid":"1078627270","full_name":"gmunumel/market-mind","owner":"gmunumel","description":"AI market intelligence and analysis.","archived":false,"fork":false,"pushed_at":"2025-10-25T11:22:18.000Z","size":348,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-02T20:04:02.862Z","etag":null,"topics":["ai","chromadb","fastapi","langchain","langgraph","postgresql","rag","react"],"latest_commit_sha":null,"homepage":"https://market-mind.stackedge.dev/portfolio/market-mind/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gmunumel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-18T04:33:45.000Z","updated_at":"2025-10-25T11:22:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"bb579bd0-016f-4bc1-8e4a-ae6496f49b8e","html_url":"https://github.com/gmunumel/market-mind","commit_stats":null,"previous_names":["gmunumel/market-mind"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gmunumel/market-mind","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmunumel%2Fmarket-mind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmunumel%2Fmarket-mind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmunumel%2Fmarket-mind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmunumel%2Fmarket-mind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gmunumel","download_url":"https://codeload.github.com/gmunumel/market-mind/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmunumel%2Fmarket-mind/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31532170,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","chromadb","fastapi","langchain","langgraph","postgresql","rag","react"],"created_at":"2025-10-31T21:23:41.477Z","updated_at":"2026-04-07T22:31:19.576Z","avatar_url":"https://github.com/gmunumel.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Market Mind\n\nMarket 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.\n\n## Project structure\n\n```\n.\n├── backend/              # FastAPI + LangChain backend (Python 3.12, uv managed)\n├── frontend/             # React + Vite + Tailwind chat interface with Zustand store\n├── charts/               # Helm charts for k3s deployments (frontend \u0026 backend)\n├── docker-compose.yml    # Multi-service stack for local Docker workflows\n├── .devcontainer/        # VS Code Dev Container definition\n├── .env                  # Runtime configuration (copy-safe defaults)\n└── README.md\n```\n\n## Features\n\n- Stateful LangGraph agent using LangChain, OpenAI `gpt-4o`, DuckDuckGo search, and Chroma persistent vector store.\n- PostgreSQL persistence for chat sessions and message history.\n- Rate limiting per user (hourly/daily) to prevent abuse.\n- Langfuse instrumentation hooks for trace monitoring.\n- React chat UI with multiple conversations, dark/light themes, and Zustand-based state management.\n- Dockerfiles, Docker Compose, VS Code DevContainer, and Helm charts for seamless local dev and k3s deployment.\n\n## Prerequisites\n\n- Python \u003e= 3.12 with [uv](https://github.com/astral-sh/uv) (`pip install uv`).\n- Node.js \u003e= 20 and npm \u003e= 10.\n- Docker \u0026 Docker Compose (optional).\n- k3s / Kubernetes cluster with Helm (optional for deployment).\n\n## Configuration\n\nEnvironment variables are managed through `.env` in the repository root. Duplicate the defaults if you need private overrides:\n\n```bash\ncp .env.example .env\n```\n\nUpdate the following keys before running production workloads:\n\n- `OPENAI_API_KEY`\n- `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY`\n- `DATABASE_URL` (if not using Docker Compose defaults)\n\nFor 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.\n\n## Running locally (without Docker)\n\n1. **Start dependencies (optional but recommended via Compose)**\n   ```bash\n   docker compose up postgres chroma\n   ```\n\n2. **Backend**\n   ```bash\n   cd backend\n   uv sync\n   uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload\n   ```\n\n3. **Frontend**\n   ```bash\n   cd frontent\n   npm install\n   npm run dev\n   ```\n\nThe 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.\n\n### API quick start\n\n- Health check: `GET http://localhost:8000/health`\n- Create chat: `POST http://localhost:8000/chats`\n- Send message: `POST http://localhost:8000/chats/{chatId}/messages`\n\n## Docker workflow\n\nBuild and run the whole stack:\n\n```bash\ndocker compose up --build\n```\n\nServices launched:\n\n- `frontend` → http://localhost:5173\n- `backend` → http://localhost:8000\n- `postgres` (data persisted to `postgres_data` volume)\n- `chroma` (vector store persisted to `chroma_data`)\n\nOverride environment variables by editing `.env` before starting Compose.\n\n## VS Code Dev Container\n\n1. Install the **Dev Containers** extension.\n2. Open the repository in VS Code and select **Reopen in Container**.\n3. The container pre-installs Python 3.12, Node 20, uv, project dependencies, and recommended extensions. Docker Compose brings up the `postgres` and `chroma` services automatically; other services can be started manually as needed.\n\nAfter launch:\n\n```bash\n# Backend shell\ncd backend\nuv run uvicorn app.main:app --reload\n\n# Frontend shell\ncd frontend\nnpm run dev\n```\n\n## Testing\n\nBackend (pytest):\n```bash\ncd backend\nuv run pytest\n```\n\nFrontend (Vitest):\n```bash\ncd frontend\nnpm run test\n```\n\nCI scripts can call these commands to validate both layers.\n\n## Deployment to k3s with Helm\n\n1. **Build and push images**\n   ```bash\n   # Backend\n   docker build -t ghcr.io/\u003corg\u003e/market-mind-backend:latest backend\n   docker push ghcr.io/\u003corg\u003e/market-mind-backend:latest\n\n   # Frontend (build with API endpoint baked in)\n   docker build --build-arg VITE_API_URL=http://market-mind-backend:8000 \\\n     -t ghcr.io/\u003corg\u003e/market-mind-frontend:latest frontend\n   docker push ghcr.io/\u003corg\u003e/market-mind-frontend:latest\n   ```\n\n2. **Create a namespace and override values**\n   ```bash\n   kubectl create namespace market-mind\n   ```\n   Prepare override files (or use `--set` flags) to supply secrets safely:\n   ```yaml\n   # backend-values.yaml\n   image:\n     repository: ghcr.io/\u003corg\u003e/market-mind-backend\n     tag: latest\n   env:\n     OPENAI_API_KEY: \"\u003copenai-key\u003e\"\n     LANGFUSE_PUBLIC_KEY: \"\u003clangfuse-public\u003e\"\n     LANGFUSE_SECRET_KEY: \"\u003clangfuse-secret\u003e\"\n     DATABASE_URL: \"postgresql+psycopg://market_mind:market_mind@postgresql:5432/market_mind\"\n   ```\n   ```yaml\n   # frontend-values.yaml\n   image:\n     repository: ghcr.io/\u003corg\u003e/market-mind-frontend\n     tag: latest\n   env:\n     VITE_API_URL: \"http://market-mind-backend:8000\"\n   ```\n\n3. **Install the charts**\n   ```bash\n   helm install market-mind-backend charts/backend -n market-mind -f backend-values.yaml\n   helm install market-mind-frontend charts/frontend -n market-mind -f frontend-values.yaml\n   ```\n\n4. **Verify**\n   ```bash\n   kubectl get pods -n market-mind\n   kubectl get svc -n market-mind\n   ```\n\nThe 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).\n\n## Observability \u0026 limits\n\n- **Langfuse**: configure `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY`, and `LANGFUSE_HOST` (default cloud endpoint) to enable tracing. Without credentials the backend gracefully disables Langfuse calls.\n- **Rate limiting**: defaults to 60 requests/hour and 500 requests/day per `X-User-Id`. Override with `HOURLY_REQUEST_LIMIT` / `DAILY_REQUEST_LIMIT`.\n\n## Chat retention / cleanup\n\n- Run `uv run python -m app.scripts.purge_chats --older-than-hours 24` locally or in CI to wipe chats older than a day (omit the flag to delete everything).\n- Enable the automated cleanup CronJob in the backend Helm chart by setting:\n  ```yaml\n  cleanup:\n    enabled: true\n    schedule: \"0 3 * * *\"   # UTC time to run\n    olderThanHours: 24\n  ```\n  This reuses the backend image to execute the purge script inside the cluster once per schedule.\n\n## Next steps\n\n- Integrate authenticated user IDs to align rate limits with your identity provider.\n- Automate database migrations via Alembic before deploying to production.\n- Harden the Docker images (distroless, multi-stage builds) and add CI pipelines.\n\nHappy hacking!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmunumel%2Fmarket-mind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgmunumel%2Fmarket-mind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmunumel%2Fmarket-mind/lists"}