# anshulsharma48/gitinsight architecture

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

- Interactive diagram: https://gitdiagram.com/anshulsharma48/gitinsight
- Repository: https://github.com/anshulsharma48/gitinsight

## Overview

GitInsight lets users authenticate, import a public GitHub repository, inspect its metadata and tree, review deterministic health findings and AI insights, and ask citation-grounded codebase questions. The graph follows the documented UI-to-API workflow and the source-indexed backend calls. README-described capabilities such as onboarding roadmaps and static audit dimensions are retained; unsampled implementation details and unsupported links are omitted.

Main entry points: [`client/src/App.jsx`](https://github.com/anshulsharma48/gitinsight/blob/master/client/src/App.jsx) (App routing and landing), [`client/src/services/api.js`](https://github.com/anshulsharma48/gitinsight/blob/master/client/src/services/api.js) (Authenticated API client), [`server/routes/repositoryRoutes.js`](https://github.com/anshulsharma48/gitinsight/blob/master/server/routes/repositoryRoutes.js) (Repository routes), [`server/controllers/analysisController.js`](https://github.com/anshulsharma48/gitinsight/blob/master/server/controllers/analysisController.js) (Analysis orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["App routing and landing<br/>[App.jsx]"]
  node_authui["Session state<br/>[AuthContext.jsx]"]
  node_dashboard["Repository dashboard<br/>[Dashboard.jsx]"]
  node_detail["Repository details"]
  node_analysisui["Health results"]
  node_chatu["Repository chat UI<br/>[RepositoryChat.jsx]"]
  node_apiclient["Authenticated API client<br/>[api.js]"]
end

subgraph group_identity["Identity and API"]
  node_server["Express API bootstrap<br/>[server.js]"]
  node_authroutes["Auth routes<br/>[authRoutes.js]"]
  node_repo_routes["Repository routes"]
  node_authcontroller["Account handlers<br/>[authController.js]"]
  node_authmw["JWT protection<br/>[authMiddleware.js]"]
  node_userdb[("User records<br/>[User.js]")]
end

subgraph group_audit["Repository ingestion and audit"]
  node_repocontroller["Repository import and access"]
  node_github["GitHub repository fetch<br/>[githubService.js]"]
  node_fallback["Offline fallback data<br/>[fallbackData.js]"]
  node_repodb[("Repository records<br/>[Repository.js]")]
  node_analysiscontroller["Analysis orchestration"]
  node_scoring["Deterministic health scoring<br/>[scoringEngine.js]"]
  node_quality["Code quality rules"]
  node_security["Security rules"]
  node_analysisdb[("Analysis records<br/>[Analysis.js]")]
end

subgraph group_chat["Grounded repository chat"]
  node_gemini["AI insights and responses<br/>[geminiService.js]"]
  node_ragcontroller["Index and chat handlers<br/>[ragController.js]"]
  node_rag["Chunking and retrieval<br/>[ragService.js]"]
  node_chunks[("Indexed code chunks<br/>[RepositoryChunk.js]")]
end

node_user(("Repository user"))
node_github_service["GitHub REST API"]
node_gemini_service["Google Gemini"]
node_mongo[("MongoDB")]

node_user -->|"uses"| node_app
node_app -->|"provides session"| node_authui
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_detail
node_app -->|"routes to"| node_analysisui
node_app -->|"routes to"| node_chatu
node_authui -->|"verifies session"| node_apiclient
node_dashboard -->|"requests repositories"| node_apiclient
node_detail -->|"loads repository"| node_apiclient
node_analysisui -->|"loads findings"| node_apiclient
node_chatu -->|"indexes and chats"| node_apiclient
node_apiclient -->|"sends API requests"| node_server
node_server -->|"mounts routes"| node_authroutes
node_server -->|"mounts routes"| node_repo_routes
node_authroutes -->|"dispatches"| node_authcontroller
node_authroutes -->|"protects session route"| node_authmw
node_repo_routes -->|"dispatches"| node_repocontroller
node_repo_routes -->|"dispatches"| node_analysiscontroller
node_repo_routes -->|"dispatches"| node_ragcontroller
node_repo_routes -->|"protects routes"| node_authmw
node_authcontroller -->|"reads and writes"| node_userdb
node_authmw -->|"looks up user"| node_userdb
node_repocontroller -->|"fetches repository data"| node_github
node_repocontroller -->|"uses fallback dataset"| node_fallback
node_repocontroller -->|"stores and queries"| node_repodb
node_analysiscontroller -->|"loads repository"| node_repodb
node_analysiscontroller -->|"runs scoring"| node_scoring
node_analysiscontroller -->|"generates insights"| node_gemini
node_analysiscontroller -->|"stores analysis"| node_analysisdb
node_scoring -->|"runs quality rules"| node_quality
node_scoring -->|"runs security rules"| node_security
node_ragcontroller -->|"loads repository"| node_repodb
node_ragcontroller -->|"indexes and answers"| node_rag
node_rag -->|"stores and retrieves chunks"| node_chunks
node_rag -->|"generates chat response"| node_gemini
node_github -.->|"fetches public data"| node_github_service
node_gemini -.->|"requests generation"| node_gemini_service
node_server -->|"connects database"| node_mongo

click node_app "https://github.com/anshulsharma48/gitinsight/blob/master/client/src/App.jsx"
click node_authui "https://github.com/anshulsharma48/gitinsight/blob/master/client/src/context/AuthContext.jsx"
click node_dashboard "https://github.com/anshulsharma48/gitinsight/blob/master/client/src/pages/Dashboard.jsx"
click node_detail "https://github.com/anshulsharma48/gitinsight/blob/master/client/src/pages/RepositoryDetail.jsx"
click node_analysisui "https://github.com/anshulsharma48/gitinsight/blob/master/client/src/pages/RepositoryAnalysis.jsx"
click node_chatu "https://github.com/anshulsharma48/gitinsight/blob/master/client/src/pages/RepositoryChat.jsx"
click node_apiclient "https://github.com/anshulsharma48/gitinsight/blob/master/client/src/services/api.js"
click node_server "https://github.com/anshulsharma48/gitinsight/blob/master/server/server.js"
click node_authroutes "https://github.com/anshulsharma48/gitinsight/blob/master/server/routes/authRoutes.js"
click node_repo_routes "https://github.com/anshulsharma48/gitinsight/blob/master/server/routes/repositoryRoutes.js"
click node_authcontroller "https://github.com/anshulsharma48/gitinsight/blob/master/server/controllers/authController.js"
click node_authmw "https://github.com/anshulsharma48/gitinsight/blob/master/server/middleware/authMiddleware.js"
click node_userdb "https://github.com/anshulsharma48/gitinsight/blob/master/server/models/User.js"
click node_repocontroller "https://github.com/anshulsharma48/gitinsight/blob/master/server/controllers/repositoryController.js"
click node_github "https://github.com/anshulsharma48/gitinsight/blob/master/server/services/github/githubService.js"
click node_fallback "https://github.com/anshulsharma48/gitinsight/blob/master/server/services/github/fallbackData.js"
click node_repodb "https://github.com/anshulsharma48/gitinsight/blob/master/server/models/Repository.js"
click node_analysiscontroller "https://github.com/anshulsharma48/gitinsight/blob/master/server/controllers/analysisController.js"
click node_scoring "https://github.com/anshulsharma48/gitinsight/blob/master/server/analyzers/scoringEngine.js"
click node_quality "https://github.com/anshulsharma48/gitinsight/blob/master/server/analyzers/quality/codeQualityAnalyzer.js"
click node_security "https://github.com/anshulsharma48/gitinsight/blob/master/server/analyzers/security/securityAnalyzer.js"
click node_analysisdb "https://github.com/anshulsharma48/gitinsight/blob/master/server/models/Analysis.js"
click node_gemini "https://github.com/anshulsharma48/gitinsight/blob/master/server/services/ai/geminiService.js"
click node_ragcontroller "https://github.com/anshulsharma48/gitinsight/blob/master/server/controllers/ragController.js"
click node_rag "https://github.com/anshulsharma48/gitinsight/blob/master/server/services/rag/ragService.js"
click node_chunks "https://github.com/anshulsharma48/gitinsight/blob/master/server/models/RepositoryChunk.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_app,node_authui,node_dashboard,node_detail,node_analysisui,node_chatu,node_apiclient,node_user toneBlue
class node_server,node_authroutes,node_repo_routes,node_authcontroller,node_authmw,node_userdb,node_mongo toneAmber
class node_repocontroller,node_github,node_fallback,node_repodb,node_analysiscontroller,node_scoring,node_quality,node_security,node_analysisdb,node_github_service toneMint
class node_gemini,node_ragcontroller,node_rag,node_chunks toneRose
class node_gemini_service toneIndigo
```

## Components

### Web application

- [App routing and landing](https://github.com/anshulsharma48/gitinsight/blob/master/client/src/App.jsx): `client/src/App.jsx`
- [Session state](https://github.com/anshulsharma48/gitinsight/blob/master/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Repository dashboard](https://github.com/anshulsharma48/gitinsight/blob/master/client/src/pages/Dashboard.jsx): `client/src/pages/Dashboard.jsx`
- [Repository details](https://github.com/anshulsharma48/gitinsight/blob/master/client/src/pages/RepositoryDetail.jsx): `client/src/pages/RepositoryDetail.jsx`
- [Health results](https://github.com/anshulsharma48/gitinsight/blob/master/client/src/pages/RepositoryAnalysis.jsx): `client/src/pages/RepositoryAnalysis.jsx`
- [Repository chat UI](https://github.com/anshulsharma48/gitinsight/blob/master/client/src/pages/RepositoryChat.jsx): `client/src/pages/RepositoryChat.jsx`
- [Authenticated API client](https://github.com/anshulsharma48/gitinsight/blob/master/client/src/services/api.js): `client/src/services/api.js`

### Identity and API

- [Express API bootstrap](https://github.com/anshulsharma48/gitinsight/blob/master/server/server.js): `server/server.js`
- [Auth routes](https://github.com/anshulsharma48/gitinsight/blob/master/server/routes/authRoutes.js): `server/routes/authRoutes.js`
- [Repository routes](https://github.com/anshulsharma48/gitinsight/blob/master/server/routes/repositoryRoutes.js): `server/routes/repositoryRoutes.js`
- [Account handlers](https://github.com/anshulsharma48/gitinsight/blob/master/server/controllers/authController.js): `server/controllers/authController.js`
- [JWT protection](https://github.com/anshulsharma48/gitinsight/blob/master/server/middleware/authMiddleware.js): `server/middleware/authMiddleware.js`
- [User records](https://github.com/anshulsharma48/gitinsight/blob/master/server/models/User.js): `server/models/User.js`

### Repository ingestion and audit

- [Repository import and access](https://github.com/anshulsharma48/gitinsight/blob/master/server/controllers/repositoryController.js): `server/controllers/repositoryController.js`
- [GitHub repository fetch](https://github.com/anshulsharma48/gitinsight/blob/master/server/services/github/githubService.js): `server/services/github/githubService.js`
- [Offline fallback data](https://github.com/anshulsharma48/gitinsight/blob/master/server/services/github/fallbackData.js): `server/services/github/fallbackData.js`
- [Repository records](https://github.com/anshulsharma48/gitinsight/blob/master/server/models/Repository.js): `server/models/Repository.js`
- [Analysis orchestration](https://github.com/anshulsharma48/gitinsight/blob/master/server/controllers/analysisController.js): `server/controllers/analysisController.js`
- [Deterministic health scoring](https://github.com/anshulsharma48/gitinsight/blob/master/server/analyzers/scoringEngine.js): `server/analyzers/scoringEngine.js`
- [Code quality rules](https://github.com/anshulsharma48/gitinsight/blob/master/server/analyzers/quality/codeQualityAnalyzer.js): `server/analyzers/quality/codeQualityAnalyzer.js`
- [Security rules](https://github.com/anshulsharma48/gitinsight/blob/master/server/analyzers/security/securityAnalyzer.js): `server/analyzers/security/securityAnalyzer.js`
- [Analysis records](https://github.com/anshulsharma48/gitinsight/blob/master/server/models/Analysis.js): `server/models/Analysis.js`

### Grounded repository chat

- [AI insights and responses](https://github.com/anshulsharma48/gitinsight/blob/master/server/services/ai/geminiService.js): `server/services/ai/geminiService.js`
- [Index and chat handlers](https://github.com/anshulsharma48/gitinsight/blob/master/server/controllers/ragController.js): `server/controllers/ragController.js`
- [Chunking and retrieval](https://github.com/anshulsharma48/gitinsight/blob/master/server/services/rag/ragService.js): `server/services/rag/ragService.js`
- [Indexed code chunks](https://github.com/anshulsharma48/gitinsight/blob/master/server/models/RepositoryChunk.js): `server/models/RepositoryChunk.js`

### Other components

- **Repository user**
- **GitHub REST API**
- **Google Gemini**
- **MongoDB**

## Connections

- Repository user → App routing and landing: uses (evidence: `README.md`)
- App routing and landing → Session state: provides session (evidence: `client/src/App.jsx`)
- App routing and landing → Repository dashboard: routes to (evidence: `client/src/App.jsx`)
- App routing and landing → Repository details: routes to (evidence: `client/src/App.jsx`)
- App routing and landing → Health results: routes to (evidence: `client/src/App.jsx`)
- App routing and landing → Repository chat UI: routes to (evidence: `client/src/App.jsx`)
- Session state → Authenticated API client: verifies session (evidence: `client/src/context/AuthContext.jsx`)
- Repository dashboard → Authenticated API client: requests repositories (evidence: `client/src/pages/Dashboard.jsx`)
- Repository details → Authenticated API client: loads repository (evidence: `client/src/pages/RepositoryDetail.jsx`)
- Health results → Authenticated API client: loads findings (evidence: `client/src/pages/RepositoryAnalysis.jsx`)
- Repository chat UI → Authenticated API client: indexes and chats (evidence: `client/src/pages/RepositoryChat.jsx`)
- Authenticated API client → Express API bootstrap: sends API requests (evidence: `README.md`)
- Express API bootstrap → Auth routes: mounts routes (evidence: `server/server.js`)
- Express API bootstrap → Repository routes: mounts routes (evidence: `server/server.js`)
- Auth routes → Account handlers: dispatches (evidence: `server/routes/authRoutes.js`)
- Auth routes → JWT protection: protects session route (evidence: `server/routes/authRoutes.js`)
- Repository routes → Repository import and access: dispatches (evidence: `server/routes/repositoryRoutes.js`)
- Repository routes → Analysis orchestration: dispatches (evidence: `server/routes/repositoryRoutes.js`)
- Repository routes → Index and chat handlers: dispatches (evidence: `server/routes/repositoryRoutes.js`)
- Repository routes → JWT protection: protects routes (evidence: `server/routes/repositoryRoutes.js`)
- Account handlers → User records: reads and writes (evidence: `server/controllers/authController.js`)
- JWT protection → User records: looks up user (evidence: `server/middleware/authMiddleware.js`)
- Repository import and access → GitHub repository fetch: fetches repository data (evidence: `server/controllers/repositoryController.js`)
- Repository import and access → Offline fallback data: uses fallback dataset (evidence: `server/controllers/repositoryController.js`)
- Repository import and access → Repository records: stores and queries (evidence: `server/controllers/repositoryController.js`)
- Analysis orchestration → Repository records: loads repository (evidence: `server/controllers/analysisController.js`)
- Analysis orchestration → Deterministic health scoring: runs scoring (evidence: `server/controllers/analysisController.js`)
- Analysis orchestration → AI insights and responses: generates insights (evidence: `server/controllers/analysisController.js`)
- Analysis orchestration → Analysis records: stores analysis (evidence: `server/controllers/analysisController.js`)
- Deterministic health scoring → Code quality rules: runs quality rules (evidence: `server/analyzers/scoringEngine.js`)
- Deterministic health scoring → Security rules: runs security rules (evidence: `server/analyzers/scoringEngine.js`)
- Index and chat handlers → Repository records: loads repository (evidence: `server/controllers/ragController.js`)
- Index and chat handlers → Chunking and retrieval: indexes and answers (evidence: `server/controllers/ragController.js`)
- Chunking and retrieval → Indexed code chunks: stores and retrieves chunks (evidence: `server/services/rag/ragService.js`)
- Chunking and retrieval → AI insights and responses: generates chat response (evidence: `server/services/rag/ragService.js`)
- GitHub repository fetch → GitHub REST API: fetches public data (evidence: `README.md`)
- AI insights and responses → Google Gemini: requests generation (evidence: `README.md`)
- Express API bootstrap → MongoDB: connects database (evidence: `server/server.js`)
