# prerna7506/repolens architecture

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

- Interactive diagram: https://gitdiagram.com/prerna7506/repolens
- Repository: https://github.com/prerna7506/repolens

## Overview

RepoLens lets users connect GitHub repositories, index their code, browse it, and ask questions answered with file-and-line citations. The main path is repository submission through the gateway to the ingestion worker, followed by hybrid retrieval and LLM answering; separate capabilities cover OAuth, history, live presence, and webhook-driven re-indexing. The README documents several subsystems whose implementation was not sampled, so those links are shown as unverified rather than inferred from module names.

Main entry points: [`backend/api-gateway/src/app.js`](https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/app.js) (Express gateway), [`backend/ingestion/app/main.py`](https://github.com/prerna7506/repolens/blob/main/backend/ingestion/app/main.py) (Worker API), [`backend/api-gateway/src/db/db_connection.js`](https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/db/db_connection.js) (Postgres index), [`backend/ingestion/app/tasks/ingest.py`](https://github.com/prerna7506/repolens/blob/main/backend/ingestion/app/tasks/ingest.py) (Clone and index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_angular["Angular app<br/>[app.config.ts]"]
  node_repo_ui["Repo browsing"]
  node_explorer["Code explorer"]
  node_chat["Ask questions<br/>[chat.component.ts]"]
  node_search["Search"]
  node_history_ui["Query history"]
  node_auth_ui["Auth client<br/>[auth.service.ts]"]
  node_repo_service["Repository client<br/>[repo.service.ts]"]
  node_query_service["Query client<br/>[query.service.ts]"]
  node_socket_client["Live presence client<br/>[socket.service.ts]"]
end

subgraph group_gateway["API gateway"]
  node_gateway["Express gateway<br/>[app.js]"]
  node_auth_routes["Auth routes<br/>[auth.js]"]
  node_auth_controller["OAuth and tokens<br/>[authController.js]"]
  node_repo_routes["Repository routes<br/>[repos.js]"]
  node_repo_controller["Repository operations<br/>[repoController.js]"]
  node_query_routes["Query routes<br/>[query.js]"]
  node_query_controller["Retrieval and answers<br/>[queryController.js]"]
  node_webhook["Push webhook"]
  node_socket_server["Socket presence<br/>[socket.js]"]
end

subgraph group_ingestion["Code ingestion"]
  node_worker_api["Worker API<br/>[main.py]"]
  node_ingest_task["Clone and index<br/>[ingest.py]"]
  node_celery["Task dispatch<br/>[celery_app.py]"]
end

subgraph group_data["Index and cache"]
  node_postgres[("Postgres index<br/>[db_connection.js]")]
  node_redis[("Redis cache and queue<br/>[redis.js]")]
end

subgraph group_integrations["External services"]
  node_github["GitHub"]
  node_llm["Groq LLM"]
  node_embed_model["Embedding model"]
end

node_user(("User"))

node_user -->|"uses"| node_angular
node_angular -->|"initializes"| node_auth_ui
node_repo_ui -->|"uses"| node_repo_service
node_explorer -.->|"loads file content"| node_query_service
node_chat -.->|"asks questions"| node_query_service
node_search -.->|"searches"| node_query_service
node_history_ui -->|"loads history"| node_query_service
node_repo_service -.->|"REST requests"| node_gateway
node_query_service -->|"REST requests"| node_gateway
node_auth_ui -->|"auth requests"| node_gateway
node_socket_client -.->|"WebSocket presence"| node_socket_server
node_gateway -->|"mounts"| node_auth_routes
node_gateway -->|"mounts"| node_repo_routes
node_gateway -->|"mounts"| node_query_routes
node_gateway -->|"mounts"| node_webhook
node_auth_routes -->|"dispatches"| node_auth_controller
node_repo_routes -->|"dispatches"| node_repo_controller
node_query_routes -->|"dispatches"| node_query_controller
node_repo_controller -->|"reads and writes"| node_postgres
node_repo_controller -->|"starts ingestion"| node_worker_api
node_query_controller -->|"requests embedding"| node_worker_api
node_query_controller -->|"retrieves and stores queries"| node_postgres
node_query_controller -->|"generates cited answer"| node_llm
node_webhook -->|"reads repository data"| node_postgres
node_webhook -.->|"triggers delta indexing"| node_worker_api
node_worker_api -->|"dispatches task"| node_celery
node_celery -->|"runs task"| node_ingest_task
node_ingest_task -.->|"clones repository"| node_github
node_ingest_task -.->|"writes chunks and embeddings"| node_postgres
node_ingest_task -->|"caches embeddings"| node_redis
node_ingest_task -->|"embeds chunks"| node_embed_model
node_worker_api -->|"health checks"| node_postgres
node_worker_api -->|"health checks"| node_redis
node_gateway -.->|"enables live presence"| node_socket_server
node_auth_controller -->|"reads and writes users"| node_postgres
node_auth_controller -.->|"OAuth login"| node_github

click node_angular "https://github.com/prerna7506/repolens/blob/main/frontend/src/app/app.config.ts"
click node_repo_ui "https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/components/repository/repository.component.ts"
click node_explorer "https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/components/code-explorer/code-explorer.component.ts"
click node_chat "https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/components/chat/chat.component.ts"
click node_search "https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/components/search/search.component.ts"
click node_history_ui "https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/components/search-history/search-history.component.ts"
click node_auth_ui "https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/services/auth.service.ts"
click node_repo_service "https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/services/repo.service.ts"
click node_query_service "https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/services/query.service.ts"
click node_socket_client "https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/services/socket.service.ts"
click node_gateway "https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/app.js"
click node_auth_routes "https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/routes/auth.js"
click node_auth_controller "https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/controller/authController.js"
click node_repo_routes "https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/routes/repos.js"
click node_repo_controller "https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/controller/repoController.js"
click node_query_routes "https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/routes/query.js"
click node_query_controller "https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/controller/queryController.js"
click node_webhook "https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/controller/webhookController.js"
click node_socket_server "https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/socket.js"
click node_worker_api "https://github.com/prerna7506/repolens/blob/main/backend/ingestion/app/main.py"
click node_ingest_task "https://github.com/prerna7506/repolens/blob/main/backend/ingestion/app/tasks/ingest.py"
click node_celery "https://github.com/prerna7506/repolens/blob/main/backend/ingestion/app/celery_app.py"
click node_postgres "https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/db/db_connection.js"
click node_redis "https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/db/redis.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_angular,node_repo_ui,node_explorer,node_chat,node_search,node_history_ui,node_auth_ui,node_repo_service,node_query_service,node_socket_client,node_user toneBlue
class node_gateway,node_auth_routes,node_auth_controller,node_repo_routes,node_repo_controller,node_query_routes,node_query_controller,node_webhook,node_socket_server toneAmber
class node_worker_api,node_ingest_task,node_celery toneMint
class node_postgres,node_redis toneRose
class node_github,node_llm,node_embed_model toneIndigo
```

## Components

### Web application

- [Angular app](https://github.com/prerna7506/repolens/blob/main/frontend/src/app/app.config.ts): `frontend/src/app/app.config.ts`
- [Repo browsing](https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/components/repository/repository.component.ts): `frontend/src/app/core/components/repository/repository.component.ts`
- [Code explorer](https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/components/code-explorer/code-explorer.component.ts): `frontend/src/app/core/components/code-explorer/code-explorer.component.ts`
- [Ask questions](https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/components/chat/chat.component.ts): `frontend/src/app/core/components/chat/chat.component.ts`
- [Search](https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/components/search/search.component.ts): `frontend/src/app/core/components/search/search.component.ts`
- [Query history](https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/components/search-history/search-history.component.ts): `frontend/src/app/core/components/search-history/search-history.component.ts`
- [Auth client](https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/services/auth.service.ts): `frontend/src/app/core/services/auth.service.ts`
- [Repository client](https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/services/repo.service.ts): `frontend/src/app/core/services/repo.service.ts`
- [Query client](https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/services/query.service.ts): `frontend/src/app/core/services/query.service.ts`
- [Live presence client](https://github.com/prerna7506/repolens/blob/main/frontend/src/app/core/services/socket.service.ts): `frontend/src/app/core/services/socket.service.ts`

### API gateway

- [Express gateway](https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/app.js): `backend/api-gateway/src/app.js`
- [Auth routes](https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/routes/auth.js): `backend/api-gateway/src/routes/auth.js`
- [OAuth and tokens](https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/controller/authController.js): `backend/api-gateway/src/controller/authController.js`
- [Repository routes](https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/routes/repos.js): `backend/api-gateway/src/routes/repos.js`
- [Repository operations](https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/controller/repoController.js): `backend/api-gateway/src/controller/repoController.js`
- [Query routes](https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/routes/query.js): `backend/api-gateway/src/routes/query.js`
- [Retrieval and answers](https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/controller/queryController.js): `backend/api-gateway/src/controller/queryController.js`
- [Push webhook](https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/controller/webhookController.js): `backend/api-gateway/src/controller/webhookController.js`
- [Socket presence](https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/socket.js): `backend/api-gateway/src/socket.js`

### Code ingestion

- [Worker API](https://github.com/prerna7506/repolens/blob/main/backend/ingestion/app/main.py): `backend/ingestion/app/main.py`
- [Clone and index](https://github.com/prerna7506/repolens/blob/main/backend/ingestion/app/tasks/ingest.py): `backend/ingestion/app/tasks/ingest.py`
- [Task dispatch](https://github.com/prerna7506/repolens/blob/main/backend/ingestion/app/celery_app.py): `backend/ingestion/app/celery_app.py`

### Index and cache

- [Postgres index](https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/db/db_connection.js): `backend/api-gateway/src/db/db_connection.js`
- [Redis cache and queue](https://github.com/prerna7506/repolens/blob/main/backend/api-gateway/src/db/redis.js): `backend/api-gateway/src/db/redis.js`

### External services

- **GitHub**
- **Groq LLM**
- **Embedding model**

### Other components

- **User**

## Connections

- User → Angular app: uses (evidence: `README.md`)
- Angular app → Auth client: initializes (evidence: `frontend/src/app/app.config.ts`)
- Repo browsing → Repository client: uses (evidence: `frontend/src/app/core/components/repository/repository.component.ts`)
- Code explorer → Query client: loads file content
- Ask questions → Query client: asks questions
- Search → Query client: searches
- Query history → Query client: loads history (evidence: `frontend/src/app/core/components/search-history/search-history.component.ts`)
- Repository client → Express gateway: REST requests
- Query client → Express gateway: REST requests (evidence: `frontend/src/app/core/services/query.service.ts`)
- Auth client → Express gateway: auth requests (evidence: `frontend/src/app/core/services/auth.service.ts`)
- Live presence client → Socket presence: WebSocket presence
- Express gateway → Auth routes: mounts (evidence: `backend/api-gateway/src/app.js`)
- Express gateway → Repository routes: mounts (evidence: `backend/api-gateway/src/app.js`)
- Express gateway → Query routes: mounts (evidence: `backend/api-gateway/src/app.js`)
- Express gateway → Push webhook: mounts (evidence: `backend/api-gateway/src/app.js`)
- Auth routes → OAuth and tokens: dispatches (evidence: `backend/api-gateway/src/routes/auth.js`)
- Repository routes → Repository operations: dispatches (evidence: `backend/api-gateway/src/routes/repos.js`)
- Query routes → Retrieval and answers: dispatches (evidence: `backend/api-gateway/src/routes/query.js`)
- Repository operations → Postgres index: reads and writes (evidence: `backend/api-gateway/src/controller/repoController.js`)
- Repository operations → Worker API: starts ingestion (evidence: `backend/api-gateway/src/controller/repoController.js`)
- Retrieval and answers → Worker API: requests embedding (evidence: `backend/api-gateway/src/controller/queryController.js`)
- Retrieval and answers → Postgres index: retrieves and stores queries (evidence: `backend/api-gateway/src/controller/queryController.js`)
- Retrieval and answers → Groq LLM: generates cited answer (evidence: `backend/api-gateway/src/controller/queryController.js`)
- Push webhook → Postgres index: reads repository data (evidence: `backend/api-gateway/src/controller/webhookController.js`)
- Push webhook → Worker API: triggers delta indexing
- Worker API → Task dispatch: dispatches task (evidence: `backend/ingestion/app/main.py`)
- Task dispatch → Clone and index: runs task (evidence: `backend/ingestion/app/tasks/ingest.py`)
- Clone and index → GitHub: clones repository
- Clone and index → Postgres index: writes chunks and embeddings
- Clone and index → Redis cache and queue: caches embeddings (evidence: `backend/ingestion/app/tasks/ingest.py`)
- Clone and index → Embedding model: embeds chunks (evidence: `backend/ingestion/app/tasks/ingest.py`)
- Worker API → Postgres index: health checks (evidence: `backend/ingestion/app/main.py`)
- Worker API → Redis cache and queue: health checks (evidence: `backend/ingestion/app/main.py`)
- Express gateway → Socket presence: enables live presence
- OAuth and tokens → Postgres index: reads and writes users (evidence: `backend/api-gateway/src/controller/authController.js`)
- OAuth and tokens → GitHub: OAuth login
