# saikrishna-bathina/cricbot architecture

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

- Interactive diagram: https://gitdiagram.com/saikrishna-bathina/cricbot
- Repository: https://github.com/saikrishna-bathina/cricbot

## Overview

CricBot is a cricket-law adjudication platform: officials ask a question or describe an incident, the Express API coordinates retrieval and answer generation, and the interface presents rulings with citations. Separate product paths support clause search, exams, discrepancy reports, and administrator-managed rulebook ingestion. The graph combines documented capabilities with sampled call relationships; unsampled feature internals are represented at their source paths, and their unverified links are omitted.

Main entry points: [`client/src/App.jsx`](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/client/src/App.jsx) (CricBot interface), [`server/src/app.js`](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/app.js) (REST gateway), [`server/src/controllers/adminController.js`](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/controllers/adminController.js) (Admin controller), [`server/src/services/rag/pythonRagClient.js`](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/services/rag/pythonRagClient.js) (Python service adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Official-facing client"]
  node_web["CricBot interface<br/>[App.jsx]"]
  node_chat["Adjudication desk<br/>[ChatPage.jsx]"]
  node_scenario["Scenario analyser<br/>[ScenarioPage.jsx]"]
  node_lawsearch["Clause search<br/>[LawsSearchPage.jsx]"]
  node_adminui["Document console"]
  node_quizui["Umpire exams<br/>[QuizPage.jsx]"]
end

subgraph group_api["Express application"]
  node_gateway["REST gateway<br/>[app.js]"]
  node_chatapi["Chat controller<br/>[chatController.js]"]
  node_scenarioapi["Scenario controller"]
  node_searchapi["Law search controller"]
  node_adminapi["Admin controller<br/>[adminController.js]"]
  node_orchestrator["RAG orchestrator<br/>[ragOrchestrator.js]"]
  node_pythonclient["Python service adapter<br/>[pythonRagClient.js]"]
end

subgraph group_rag["Grounded answer service"]
  node_ragapp["FastAPI service<br/>[main.py]"]
  node_answer["Answer synthesis<br/>[answer_service.py]"]
  node_retriever["Hybrid retrieval<br/>[retriever.py]"]
end

subgraph group_knowledge["Rulebook knowledge"]
  node_chunks["Chunk repository<br/>[chunks.py]"]
  node_store[("MongoDB Atlas<br/>[mongo.py]")]
  node_ingest["PDF ingestion<br/>[pipeline.py]"]
  node_docadmin["Document administration"]
end

subgraph group_operations["Assessment and oversight"]
  node_quizapi["Quiz controller<br/>[quizController.js]"]
  node_reports["Discrepancy reports"]
  node_quizservice["Exam scoring<br/>[quizService.js]"]
end

node_official(("Match official"))

node_official -->|"uses"| node_web
node_web -->|"routes to"| node_chat
node_web -->|"routes to"| node_scenario
node_web -->|"routes to"| node_lawsearch
node_web -->|"routes to"| node_adminui
node_web -->|"routes to"| node_quizui
node_web -->|"REST requests"| node_gateway
node_gateway -->|"routes"| node_chatapi
node_gateway -->|"routes"| node_scenarioapi
node_gateway -->|"routes"| node_searchapi
node_gateway -->|"routes"| node_adminapi
node_gateway -->|"routes"| node_quizapi
node_chatapi -->|"delegates"| node_orchestrator
node_scenarioapi -.->|"analyzes via"| node_pythonclient
node_orchestrator -.->|"proxies queries"| node_pythonclient
node_pythonclient -->|"HTTP requests"| node_ragapp
node_ragapp -->|"registers API"| node_answer
node_answer -->|"retrieves evidence"| node_retriever
node_retriever -->|"searches chunks"| node_chunks
node_ingest -->|"writes chunks"| node_chunks
node_adminapi -->|"delegates ingestion"| node_docadmin
node_lawsearch -->|"searches clauses"| node_searchapi
node_quizapi -.->|"scores exams"| node_quizservice
node_adminapi -.->|"reads documents"| node_store
node_reports -.->|"stores reports"| node_store

click node_web "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/client/src/App.jsx"
click node_chat "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/client/src/pages/ChatPage.jsx"
click node_scenario "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/client/src/pages/ScenarioPage.jsx"
click node_lawsearch "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/client/src/pages/LawsSearchPage.jsx"
click node_adminui "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/client/src/pages/AdminDocumentsPage.jsx"
click node_quizui "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/client/src/pages/QuizPage.jsx"
click node_gateway "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/app.js"
click node_chatapi "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/controllers/chatController.js"
click node_scenarioapi "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/controllers/scenarioController.js"
click node_searchapi "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/controllers/lawSearchController.js"
click node_adminapi "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/controllers/adminController.js"
click node_quizapi "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/controllers/quizController.js"
click node_reports "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/controllers/reportController.js"
click node_orchestrator "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/services/rag/ragOrchestrator.js"
click node_pythonclient "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/services/rag/pythonRagClient.js"
click node_ragapp "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/rag-service/app/main.py"
click node_answer "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/rag-service/app/generation/answer_service.py"
click node_retriever "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/rag-service/app/retrieval/retriever.py"
click node_chunks "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/rag-service/app/db/repositories/chunks.py"
click node_store "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/rag-service/app/db/mongo.py"
click node_ingest "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/rag-service/app/ingestion/pipeline.py"
click node_docadmin "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/services/ingestion/documentAdminService.js"
click node_quizservice "https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/services/quizzes/quizService.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,node_chat,node_scenario,node_lawsearch,node_adminui,node_quizui toneBlue
class node_gateway,node_chatapi,node_scenarioapi,node_searchapi,node_adminapi,node_orchestrator,node_pythonclient toneAmber
class node_ragapp,node_answer,node_retriever toneMint
class node_chunks,node_store,node_ingest,node_docadmin toneRose
class node_quizapi,node_reports,node_quizservice,node_official toneIndigo
```

## Components

### Official-facing client

- [CricBot interface](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/client/src/App.jsx): `client/src/App.jsx`
- [Adjudication desk](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/client/src/pages/ChatPage.jsx): `client/src/pages/ChatPage.jsx`
- [Scenario analyser](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/client/src/pages/ScenarioPage.jsx): `client/src/pages/ScenarioPage.jsx`
- [Clause search](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/client/src/pages/LawsSearchPage.jsx): `client/src/pages/LawsSearchPage.jsx`
- [Document console](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/client/src/pages/AdminDocumentsPage.jsx): `client/src/pages/AdminDocumentsPage.jsx`
- [Umpire exams](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/client/src/pages/QuizPage.jsx): `client/src/pages/QuizPage.jsx`

### Express application

- [REST gateway](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/app.js): `server/src/app.js`
- [Chat controller](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/controllers/chatController.js): `server/src/controllers/chatController.js`
- [Scenario controller](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/controllers/scenarioController.js): `server/src/controllers/scenarioController.js`
- [Law search controller](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/controllers/lawSearchController.js): `server/src/controllers/lawSearchController.js`
- [Admin controller](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/controllers/adminController.js): `server/src/controllers/adminController.js`
- [RAG orchestrator](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/services/rag/ragOrchestrator.js): `server/src/services/rag/ragOrchestrator.js`
- [Python service adapter](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/services/rag/pythonRagClient.js): `server/src/services/rag/pythonRagClient.js`

### Grounded answer service

- [FastAPI service](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/rag-service/app/main.py): `rag-service/app/main.py`
- [Answer synthesis](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/rag-service/app/generation/answer_service.py): `rag-service/app/generation/answer_service.py`
- [Hybrid retrieval](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/rag-service/app/retrieval/retriever.py): `rag-service/app/retrieval/retriever.py`

### Rulebook knowledge

- [Chunk repository](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/rag-service/app/db/repositories/chunks.py): `rag-service/app/db/repositories/chunks.py`
- [MongoDB Atlas](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/rag-service/app/db/mongo.py): `rag-service/app/db/mongo.py`
- [PDF ingestion](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/rag-service/app/ingestion/pipeline.py): `rag-service/app/ingestion/pipeline.py`
- [Document administration](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/services/ingestion/documentAdminService.js): `server/src/services/ingestion/documentAdminService.js`

### Assessment and oversight

- [Quiz controller](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/controllers/quizController.js): `server/src/controllers/quizController.js`
- [Discrepancy reports](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/controllers/reportController.js): `server/src/controllers/reportController.js`
- [Exam scoring](https://github.com/saikrishna-bathina/cricbot/blob/feature/python-rag/server/src/services/quizzes/quizService.js): `server/src/services/quizzes/quizService.js`

### Other components

- **Match official**

## Connections

- Match official → CricBot interface: uses (evidence: `README.md`)
- CricBot interface → Adjudication desk: routes to (evidence: `client/src/App.jsx`)
- CricBot interface → Scenario analyser: routes to (evidence: `client/src/App.jsx`)
- CricBot interface → Clause search: routes to (evidence: `client/src/App.jsx`)
- CricBot interface → Document console: routes to (evidence: `client/src/App.jsx`)
- CricBot interface → Umpire exams: routes to (evidence: `client/src/App.jsx`)
- CricBot interface → REST gateway: REST requests (evidence: `README.md`)
- REST gateway → Chat controller: routes (evidence: `server/src/app.js`)
- REST gateway → Scenario controller: routes (evidence: `server/src/app.js`)
- REST gateway → Law search controller: routes (evidence: `server/src/app.js`)
- REST gateway → Admin controller: routes (evidence: `server/src/app.js`)
- REST gateway → Quiz controller: routes (evidence: `server/src/app.js`)
- Chat controller → RAG orchestrator: delegates (evidence: `server/src/controllers/chatController.js`)
- Scenario controller → Python service adapter: analyzes via
- RAG orchestrator → Python service adapter: proxies queries
- Python service adapter → FastAPI service: HTTP requests (evidence: `server/src/services/rag/pythonRagClient.js`)
- FastAPI service → Answer synthesis: registers API (evidence: `rag-service/app/main.py`)
- Answer synthesis → Hybrid retrieval: retrieves evidence (evidence: `rag-service/app/generation/answer_service.py`)
- Hybrid retrieval → Chunk repository: searches chunks (evidence: `rag-service/app/retrieval/retriever.py`)
- PDF ingestion → Chunk repository: writes chunks (evidence: `rag-service/app/ingestion/pipeline.py`)
- Admin controller → Document administration: delegates ingestion (evidence: `server/src/controllers/adminController.js`)
- Clause search → Law search controller: searches clauses (evidence: `client/src/pages/LawsSearchPage.jsx`)
- Quiz controller → Exam scoring: scores exams
- Admin controller → MongoDB Atlas: reads documents
- Discrepancy reports → MongoDB Atlas: stores reports
