# md-shoaib18/codebase-analyzer architecture

> Architecture diagram of the GitHub repository md-shoaib18/codebase-analyzer, 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/md-shoaib18/codebase-analyzer
- Repository: https://github.com/md-shoaib18/codebase-analyzer

## Overview

Codebase Analyzer is a web application for authenticated analysis of public GitHub repositories. A user submits a repository from the dashboard; the API queues a job, a background worker clones and analyzes the code, and the UI polls for completion and displays the report. Analysis includes complexity, dependency recognition, duplicate detection, and secret scanning. The graph also shows registration/login, report persistence, and history/deletion APIs. Worker-to-service calls and persistence are visible in excerpts; some frontend-to-API and async queue behavior is documented in the README, so those links cite it.

Main entry points: [`backend/workers/analysisWorker.js`](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/workers/analysisWorker.js) (Analysis worker), [`backend/server.js`](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/server.js) (Express server), [`frontend/src/pages/Dashboard.jsx`](https://github.com/md-shoaib18/codebase-analyzer/blob/main/frontend/src/pages/Dashboard.jsx) (Dashboard), [`frontend/src/context/AuthContext.jsx`](https://github.com/md-shoaib18/codebase-analyzer/blob/main/frontend/src/context/AuthContext.jsx) (Auth context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_auth_ui["Login and register<br/>[Login.jsx]"]
  node_auth_context["Auth context<br/>[AuthContext.jsx]"]
  node_api_client["API client<br/>[axiosConfig.js]"]
  node_report_view["Report view<br/>[ReportView.jsx]"]
end

subgraph group_api["API and identity"]
  node_express["Express server<br/>[server.js]"]
  node_analysis_routes["Analysis routes<br/>[analyzeRoute.js]"]
  node_analysis_controller["Analysis controller"]
  node_auth_routes["User routes<br/>[userRoutes.js]"]
  node_auth_controller["Auth controller<br/>[authController.js]"]
  node_auth_middleware["JWT middleware<br/>[authMiddleware.js]"]
end

subgraph group_processing["Analysis processing"]
  node_worker["Analysis worker<br/>[analysisWorker.js]"]
  node_repository_clone["Repository clone<br/>[repoService.js]"]
  node_file_scan["File discovery<br/>[scanService.js]"]
  node_complexity["Complexity analysis"]
  node_insights["Complexity insights<br/>[insightService.js]"]
  node_duplicates["Duplicate detection"]
  node_security["Secret scanning<br/>[securityService.js]"]
  node_dependencies["Tech recognition"]
end

subgraph group_persistence["Persistence and queue"]
  node_mongo[("MongoDB analyses<br/>[analysisModel.js]")]
  node_users[("MongoDB users<br/>[userModel.js]")]
  node_job_queue["Redis job queue<br/>[queue.js]"]
end

node_user(("Developer"))
node_github(("Public GitHub repository"))

node_user -->|"submits repository"| node_dashboard
node_dashboard -->|"uses API"| node_api_client
node_dashboard -->|"renders report"| node_report_view
node_dashboard -->|"submits and polls"| node_express
node_auth_ui -->|"authenticates through"| node_auth_context
node_auth_context -->|"calls"| node_api_client
node_auth_context -->|"registers or logs in"| node_express
node_express -->|"mounts"| node_analysis_routes
node_express -->|"mounts"| node_auth_routes
node_analysis_routes -->|"protects routes"| node_auth_middleware
node_analysis_routes -->|"routes to"| node_analysis_controller
node_auth_routes -->|"routes to"| node_auth_controller
node_auth_controller -->|"reads and creates users"| node_users
node_auth_middleware -->|"loads user"| node_users
node_analysis_controller -->|"enqueues and checks jobs"| node_job_queue
node_express -->|"starts worker"| node_worker
node_job_queue -->|"dispatches jobs"| node_worker
node_worker -->|"clones repository"| node_repository_clone
node_repository_clone -->|"clones from"| node_github
node_worker -->|"discovers files"| node_file_scan
node_worker -->|"scores files"| node_complexity
node_worker -->|"summarizes scores"| node_insights
node_worker -->|"detects repeated code"| node_duplicates
node_worker -->|"scans secrets"| node_security
node_worker -->|"recognizes dependencies"| node_dependencies
node_worker -->|"saves report"| node_mongo
node_analysis_controller -->|"reads history and deletes"| node_mongo
node_worker -->|"returns job result"| node_job_queue

click node_dashboard "https://github.com/md-shoaib18/codebase-analyzer/blob/main/frontend/src/pages/Dashboard.jsx"
click node_auth_ui "https://github.com/md-shoaib18/codebase-analyzer/blob/main/frontend/src/pages/Login.jsx"
click node_auth_context "https://github.com/md-shoaib18/codebase-analyzer/blob/main/frontend/src/context/AuthContext.jsx"
click node_api_client "https://github.com/md-shoaib18/codebase-analyzer/blob/main/frontend/src/api/axiosConfig.js"
click node_report_view "https://github.com/md-shoaib18/codebase-analyzer/blob/main/frontend/src/components/ReportView.jsx"
click node_express "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/server.js"
click node_analysis_routes "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/routes/analyzeRoute.js"
click node_analysis_controller "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/controllers/analyzeController.js"
click node_auth_routes "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/routes/userRoutes.js"
click node_auth_controller "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/controllers/authController.js"
click node_auth_middleware "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/utils/authMiddleware.js"
click node_worker "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/workers/analysisWorker.js"
click node_repository_clone "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/services/repoService.js"
click node_file_scan "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/services/scanService.js"
click node_complexity "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/services/complexityService.js"
click node_insights "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/services/insightService.js"
click node_duplicates "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/services/duplicateService.js"
click node_security "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/services/securityService.js"
click node_dependencies "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/services/dependencyService.js"
click node_mongo "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/models/analysisModel.js"
click node_users "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/models/userModel.js"
click node_job_queue "https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/config/queue.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_dashboard,node_auth_ui,node_auth_context,node_api_client,node_report_view toneBlue
class node_express,node_analysis_routes,node_analysis_controller,node_auth_routes,node_auth_controller,node_auth_middleware toneAmber
class node_worker,node_repository_clone,node_file_scan,node_complexity,node_insights,node_duplicates,node_security,node_dependencies toneMint
class node_mongo,node_users,node_job_queue toneRose
class node_user,node_github toneIndigo
```

## Components

### Web application

- [Dashboard](https://github.com/md-shoaib18/codebase-analyzer/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Login and register](https://github.com/md-shoaib18/codebase-analyzer/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Auth context](https://github.com/md-shoaib18/codebase-analyzer/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [API client](https://github.com/md-shoaib18/codebase-analyzer/blob/main/frontend/src/api/axiosConfig.js): `frontend/src/api/axiosConfig.js`
- [Report view](https://github.com/md-shoaib18/codebase-analyzer/blob/main/frontend/src/components/ReportView.jsx): `frontend/src/components/ReportView.jsx`

### API and identity

- [Express server](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/server.js): `backend/server.js`
- [Analysis routes](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/routes/analyzeRoute.js): `backend/routes/analyzeRoute.js`
- [Analysis controller](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/controllers/analyzeController.js): `backend/controllers/analyzeController.js`
- [User routes](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/routes/userRoutes.js): `backend/routes/userRoutes.js`
- [Auth controller](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [JWT middleware](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/utils/authMiddleware.js): `backend/utils/authMiddleware.js`

### Analysis processing

- [Analysis worker](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/workers/analysisWorker.js): `backend/workers/analysisWorker.js`
- [Repository clone](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/services/repoService.js): `backend/services/repoService.js`
- [File discovery](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/services/scanService.js): `backend/services/scanService.js`
- [Complexity analysis](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/services/complexityService.js): `backend/services/complexityService.js`
- [Complexity insights](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/services/insightService.js): `backend/services/insightService.js`
- [Duplicate detection](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/services/duplicateService.js): `backend/services/duplicateService.js`
- [Secret scanning](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/services/securityService.js): `backend/services/securityService.js`
- [Tech recognition](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/services/dependencyService.js): `backend/services/dependencyService.js`

### Persistence and queue

- [MongoDB analyses](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/models/analysisModel.js): `backend/models/analysisModel.js`
- [MongoDB users](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/models/userModel.js): `backend/models/userModel.js`
- [Redis job queue](https://github.com/md-shoaib18/codebase-analyzer/blob/main/backend/config/queue.js): `backend/config/queue.js`

### Other components

- **Developer**
- **Public GitHub repository**

## Connections

- Developer → Dashboard: submits repository (evidence: `README.md`)
- Dashboard → API client: uses API (evidence: `frontend/src/pages/Dashboard.jsx`)
- Dashboard → Report view: renders report (evidence: `frontend/src/pages/Dashboard.jsx`)
- Dashboard → Express server: submits and polls (evidence: `README.md`)
- Login and register → Auth context: authenticates through (evidence: `frontend/src/context/AuthContext.jsx`)
- Auth context → API client: calls (evidence: `frontend/src/context/AuthContext.jsx`)
- Auth context → Express server: registers or logs in (evidence: `README.md`)
- Express server → Analysis routes: mounts (evidence: `backend/server.js`)
- Express server → User routes: mounts (evidence: `backend/server.js`)
- Analysis routes → JWT middleware: protects routes (evidence: `backend/routes/analyzeRoute.js`)
- Analysis routes → Analysis controller: routes to (evidence: `backend/routes/analyzeRoute.js`)
- User routes → Auth controller: routes to (evidence: `backend/routes/userRoutes.js`)
- Auth controller → MongoDB users: reads and creates users (evidence: `backend/controllers/authController.js`)
- JWT middleware → MongoDB users: loads user (evidence: `backend/utils/authMiddleware.js`)
- Analysis controller → Redis job queue: enqueues and checks jobs (evidence: `backend/controllers/analyzeController.js`)
- Express server → Analysis worker: starts worker (evidence: `backend/server.js`)
- Redis job queue → Analysis worker: dispatches jobs (evidence: `README.md`)
- Analysis worker → Repository clone: clones repository (evidence: `backend/workers/analysisWorker.js`)
- Repository clone → Public GitHub repository: clones from (evidence: `README.md`)
- Analysis worker → File discovery: discovers files (evidence: `backend/workers/analysisWorker.js`)
- Analysis worker → Complexity analysis: scores files (evidence: `backend/workers/analysisWorker.js`)
- Analysis worker → Complexity insights: summarizes scores (evidence: `backend/workers/analysisWorker.js`)
- Analysis worker → Duplicate detection: detects repeated code (evidence: `backend/workers/analysisWorker.js`)
- Analysis worker → Secret scanning: scans secrets (evidence: `backend/workers/analysisWorker.js`)
- Analysis worker → Tech recognition: recognizes dependencies (evidence: `backend/workers/analysisWorker.js`)
- Analysis worker → MongoDB analyses: saves report (evidence: `backend/workers/analysisWorker.js`)
- Analysis controller → MongoDB analyses: reads history and deletes (evidence: `backend/controllers/analyzeController.js`)
- Analysis worker → Redis job queue: returns job result (evidence: `README.md`)
