# ayushks404/codemind architecture

> Architecture diagram of the GitHub repository ayushks404/codemind, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayushks404/codemind
- Repository: https://github.com/ayushks404/codemind

## Overview

CodeMind AI lets users register, connect a GitHub repository, and ask questions about its code. The main workflow is project creation → asynchronous indexing → query job → agent retrieval and answer generation → streamed or polled results in the browser. Indexing uses repository cloning, AST-aware chunking, embeddings, and Qdrant; queries use a LangGraph agent and code-search tools. The README documents the Redis/Celery and WebSocket flow. Some service directories are scaffolded for a later split, and unsampled implementations are represented only where documented.

Main entry points: [`services/query/src/controllers/query_controllers.js`](https://github.com/ayushks404/codemind/blob/main/services/query/src/controllers/query_controllers.js) (Query API), [`services/agent/graph/react_graph.py`](https://github.com/ayushks404/codemind/blob/main/services/agent/graph/react_graph.py) (ReAct agent), [`services/agent/rag/rag_engine.py`](https://github.com/ayushks404/codemind/blob/main/services/agent/rag/rag_engine.py) (Index pipeline), [`frontend/src/pages/query.jsx`](https://github.com/ayushks404/codemind/blob/main/frontend/src/pages/query.jsx) (Query page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser application"]
  node_web_ui["React UI<br/>[dashboard.jsx]"]
  node_query_ui["Query page<br/>[query.jsx]"]
  node_auth_state["Auth state<br/>[AuthContext.jsx]"]
  node_browser_events["Browser events<br/>[useWebSocket.js]"]
  node_job_poller["Job polling<br/>[useJobPoller.js]"]
end

subgraph group_services["API and job dispatch"]
  node_project_api["Project API"]
  node_project_routes["Project routes<br/>[project_routes.js]"]
  node_query_api["Query API"]
  node_query_routes["Query routes<br/>[query_routes.js]"]
  node_auth_api["Auth handlers<br/>[authcontrollers.js]"]
end

subgraph group_indexing["Repository indexing"]
  node_index_worker["Index worker<br/>[index_worker.py]"]
  node_index_pipeline["Index pipeline<br/>[rag_engine.py]"]
  node_repo_chunker["Clone and chunk<br/>[chunker.py]"]
  node_embeddings["Embeddings<br/>[embeddings.py]"]
end

subgraph group_agent["Question answering"]
  node_query_worker["Query worker<br/>[query_worker.py]"]
  node_agent_graph["ReAct agent<br/>[react_graph.py]"]
  node_agent_tools["Code tools<br/>[file_tools.py]"]
  node_llm["Groq LLM<br/>[llm_client.py]"]
end

subgraph group_infrastructure["Persistence and delivery"]
  node_user_store[("User records<br/>[user.js]")]
  node_vector_store[("Vector store<br/>[vector_store.py]")]
  node_publisher["Event publisher<br/>[redis_publisher.py]"]
  node_redis["Redis queues and pub/sub"]
  node_websocket["WebSocket bridge<br/>[server.js]"]
  node_mongo[("MongoDB")]
  node_qdrant[("Qdrant")]
end

node_user(("User"))

node_user -->|"uses"| node_web_ui
node_web_ui -.->|"manages projects"| node_project_api
node_web_ui -.->|"registers and logs in"| node_auth_api
node_query_ui -->|"submits questions"| node_query_api
node_query_ui -->|"polls status"| node_job_poller
node_query_ui -->|"handles events"| node_browser_events
node_auth_state -->|"guards routes"| node_web_ui
node_project_routes -->|"routes requests"| node_project_api
node_project_api -->|"stores projects"| node_mongo
node_project_api -->|"enqueues indexing"| node_redis
node_redis -->|"dispatches index jobs"| node_index_worker
node_index_worker -->|"runs indexing"| node_index_pipeline
node_index_pipeline -->|"reads and chunks"| node_repo_chunker
node_index_pipeline -->|"embeds chunks"| node_embeddings
node_index_pipeline -->|"writes vectors"| node_vector_store
node_index_worker -->|"publishes completion"| node_publisher
node_query_routes -->|"routes requests"| node_query_api
node_query_api -->|"checks query cache"| node_redis
node_query_api -->|"stores job status"| node_mongo
node_query_api -->|"enqueues query"| node_redis
node_redis -->|"dispatches query jobs"| node_query_worker
node_query_worker -->|"invokes graph"| node_agent_graph
node_agent_graph -->|"runs code tools"| node_agent_tools
node_agent_graph -->|"embeds question"| node_embeddings
node_agent_graph -.->|"retrieves code"| node_vector_store
node_agent_graph -.->|"generates answer"| node_llm
node_agent_graph -->|"publishes agent steps"| node_publisher
node_query_worker -->|"publishes result"| node_publisher
node_publisher -->|"publishes events"| node_redis
node_redis -->|"delivers pub/sub"| node_websocket
node_websocket -->|"pushes updates"| node_browser_events
node_job_poller -.->|"checks status"| node_query_api
node_query_api -->|"returns job result"| node_query_ui
node_auth_api -->|"reads and writes"| node_user_store

click node_web_ui "https://github.com/ayushks404/codemind/blob/main/frontend/src/pages/dashboard.jsx"
click node_query_ui "https://github.com/ayushks404/codemind/blob/main/frontend/src/pages/query.jsx"
click node_auth_state "https://github.com/ayushks404/codemind/blob/main/frontend/src/context/AuthContext.jsx"
click node_project_api "https://github.com/ayushks404/codemind/blob/main/services/project/src/controllers/project_controllers.js"
click node_project_routes "https://github.com/ayushks404/codemind/blob/main/services/project/src/routes/project_routes.js"
click node_query_api "https://github.com/ayushks404/codemind/blob/main/services/query/src/controllers/query_controllers.js"
click node_query_routes "https://github.com/ayushks404/codemind/blob/main/services/query/src/routes/query_routes.js"
click node_auth_api "https://github.com/ayushks404/codemind/blob/main/services/auth/src/controllers/authcontrollers.js"
click node_user_store "https://github.com/ayushks404/codemind/blob/main/services/auth/src/models/user.js"
click node_index_worker "https://github.com/ayushks404/codemind/blob/main/services/agent/workers/index_worker.py"
click node_index_pipeline "https://github.com/ayushks404/codemind/blob/main/services/agent/rag/rag_engine.py"
click node_repo_chunker "https://github.com/ayushks404/codemind/blob/main/services/agent/rag/chunker.py"
click node_embeddings "https://github.com/ayushks404/codemind/blob/main/services/agent/rag/embeddings.py"
click node_vector_store "https://github.com/ayushks404/codemind/blob/main/services/agent/rag/vector_store.py"
click node_query_worker "https://github.com/ayushks404/codemind/blob/main/services/agent/workers/query_worker.py"
click node_agent_graph "https://github.com/ayushks404/codemind/blob/main/services/agent/graph/react_graph.py"
click node_agent_tools "https://github.com/ayushks404/codemind/blob/main/services/agent/tools/file_tools.py"
click node_llm "https://github.com/ayushks404/codemind/blob/main/services/agent/llm_client.py"
click node_publisher "https://github.com/ayushks404/codemind/blob/main/services/agent/notifications/redis_publisher.py"
click node_websocket "https://github.com/ayushks404/codemind/blob/main/services/websocket/src/server.js"
click node_browser_events "https://github.com/ayushks404/codemind/blob/main/frontend/src/hooks/useWebSocket.js"
click node_job_poller "https://github.com/ayushks404/codemind/blob/main/frontend/src/hooks/useJobPoller.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web_ui,node_query_ui,node_auth_state,node_browser_events,node_job_poller,node_user toneBlue
class node_project_api,node_project_routes,node_query_api,node_query_routes,node_auth_api toneAmber
class node_index_worker,node_index_pipeline,node_repo_chunker,node_embeddings toneMint
class node_query_worker,node_agent_graph,node_agent_tools,node_llm toneRose
class node_user_store,node_vector_store,node_publisher,node_redis,node_websocket,node_mongo,node_qdrant toneIndigo
```

## Components

### Browser application

- [React UI](https://github.com/ayushks404/codemind/blob/main/frontend/src/pages/dashboard.jsx): `frontend/src/pages/dashboard.jsx`
- [Query page](https://github.com/ayushks404/codemind/blob/main/frontend/src/pages/query.jsx): `frontend/src/pages/query.jsx`
- [Auth state](https://github.com/ayushks404/codemind/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Browser events](https://github.com/ayushks404/codemind/blob/main/frontend/src/hooks/useWebSocket.js): `frontend/src/hooks/useWebSocket.js`
- [Job polling](https://github.com/ayushks404/codemind/blob/main/frontend/src/hooks/useJobPoller.js): `frontend/src/hooks/useJobPoller.js`

### API and job dispatch

- [Project API](https://github.com/ayushks404/codemind/blob/main/services/project/src/controllers/project_controllers.js): `services/project/src/controllers/project_controllers.js`
- [Project routes](https://github.com/ayushks404/codemind/blob/main/services/project/src/routes/project_routes.js): `services/project/src/routes/project_routes.js`
- [Query API](https://github.com/ayushks404/codemind/blob/main/services/query/src/controllers/query_controllers.js): `services/query/src/controllers/query_controllers.js`
- [Query routes](https://github.com/ayushks404/codemind/blob/main/services/query/src/routes/query_routes.js): `services/query/src/routes/query_routes.js`
- [Auth handlers](https://github.com/ayushks404/codemind/blob/main/services/auth/src/controllers/authcontrollers.js): `services/auth/src/controllers/authcontrollers.js`

### Repository indexing

- [Index worker](https://github.com/ayushks404/codemind/blob/main/services/agent/workers/index_worker.py): `services/agent/workers/index_worker.py`
- [Index pipeline](https://github.com/ayushks404/codemind/blob/main/services/agent/rag/rag_engine.py): `services/agent/rag/rag_engine.py`
- [Clone and chunk](https://github.com/ayushks404/codemind/blob/main/services/agent/rag/chunker.py): `services/agent/rag/chunker.py`
- [Embeddings](https://github.com/ayushks404/codemind/blob/main/services/agent/rag/embeddings.py): `services/agent/rag/embeddings.py`

### Question answering

- [Query worker](https://github.com/ayushks404/codemind/blob/main/services/agent/workers/query_worker.py): `services/agent/workers/query_worker.py`
- [ReAct agent](https://github.com/ayushks404/codemind/blob/main/services/agent/graph/react_graph.py): `services/agent/graph/react_graph.py`
- [Code tools](https://github.com/ayushks404/codemind/blob/main/services/agent/tools/file_tools.py): `services/agent/tools/file_tools.py`
- [Groq LLM](https://github.com/ayushks404/codemind/blob/main/services/agent/llm_client.py): `services/agent/llm_client.py`

### Persistence and delivery

- [User records](https://github.com/ayushks404/codemind/blob/main/services/auth/src/models/user.js): `services/auth/src/models/user.js`
- [Vector store](https://github.com/ayushks404/codemind/blob/main/services/agent/rag/vector_store.py): `services/agent/rag/vector_store.py`
- [Event publisher](https://github.com/ayushks404/codemind/blob/main/services/agent/notifications/redis_publisher.py): `services/agent/notifications/redis_publisher.py`
- **Redis queues and pub/sub**
- [WebSocket bridge](https://github.com/ayushks404/codemind/blob/main/services/websocket/src/server.js): `services/websocket/src/server.js`
- **MongoDB**
- **Qdrant**

### Other components

- **User**

## Connections

- User → React UI: uses (evidence: `README.md`)
- React UI → Project API: manages projects
- React UI → Auth handlers: registers and logs in
- Query page → Query API: submits questions (evidence: `frontend/src/pages/query.jsx`)
- Query page → Job polling: polls status (evidence: `frontend/src/pages/query.jsx`)
- Query page → Browser events: handles events (evidence: `frontend/src/pages/query.jsx`)
- Auth state → React UI: guards routes (evidence: `frontend/src/App.jsx`)
- Project routes → Project API: routes requests (evidence: `services/project/src/routes/project_routes.js`)
- Project API → MongoDB: stores projects (evidence: `services/project/src/controllers/project_controllers.js`)
- Project API → Redis queues and pub/sub: enqueues indexing (evidence: `services/project/src/controllers/project_controllers.js`)
- Redis queues and pub/sub → Index worker: dispatches index jobs (evidence: `README.md`)
- Index worker → Index pipeline: runs indexing (evidence: `services/agent/workers/index_worker.py`)
- Index pipeline → Clone and chunk: reads and chunks (evidence: `services/agent/rag/rag_engine.py`)
- Index pipeline → Embeddings: embeds chunks (evidence: `services/agent/rag/rag_engine.py`)
- Index pipeline → Vector store: writes vectors (evidence: `services/agent/rag/rag_engine.py`)
- Index worker → Event publisher: publishes completion (evidence: `services/agent/workers/index_worker.py`)
- Query routes → Query API: routes requests (evidence: `services/query/src/routes/query_routes.js`)
- Query API → Redis queues and pub/sub: checks query cache (evidence: `services/query/src/controllers/query_controllers.js`)
- Query API → MongoDB: stores job status (evidence: `services/query/src/controllers/query_controllers.js`)
- Query API → Redis queues and pub/sub: enqueues query (evidence: `services/query/src/controllers/query_controllers.js`)
- Redis queues and pub/sub → Query worker: dispatches query jobs (evidence: `README.md`)
- Query worker → ReAct agent: invokes graph (evidence: `services/agent/workers/query_worker.py`)
- ReAct agent → Code tools: runs code tools (evidence: `services/agent/graph/react_graph.py`)
- ReAct agent → Embeddings: embeds question (evidence: `services/agent/graph/react_graph.py`)
- ReAct agent → Vector store: retrieves code
- ReAct agent → Groq LLM: generates answer
- ReAct agent → Event publisher: publishes agent steps (evidence: `services/agent/graph/react_graph.py`)
- Query worker → Event publisher: publishes result (evidence: `services/agent/workers/query_worker.py`)
- Event publisher → Redis queues and pub/sub: publishes events (evidence: `README.md`)
- Redis queues and pub/sub → WebSocket bridge: delivers pub/sub (evidence: `README.md`)
- WebSocket bridge → Browser events: pushes updates (evidence: `README.md`)
- Job polling → Query API: checks status
- Query API → Query page: returns job result (evidence: `services/query/src/controllers/query_controllers.js`)
- Auth handlers → User records: reads and writes (evidence: `services/auth/src/controllers/authcontrollers.js`)
