# oussamcsc/codebase-intelligence architecture

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

- Interactive diagram: https://gitdiagram.com/oussamcsc/codebase-intelligence
- Repository: https://github.com/oussamcsc/codebase-intelligence

## Overview

Codebase Intelligence accepts a GitHub repository through its React interface or CLI, gathers static evidence, filters and synthesizes a review, then exposes progress and results. The documented web workflow runs through FastAPI, which also handles GitHub authentication and job results. The graph includes the four analyzers, UI views, configuration, and documented persistence and optional RAG. Some backend pipeline wiring is documented in the README rather than shown in sampled API source; those relationships cite the README.

Main entry points: [`api.py`](https://github.com/oussamcsc/codebase-intelligence/blob/main/api.py) (FastAPI jobs), [`Code_reviewer.py`](https://github.com/oussamcsc/codebase-intelligence/blob/main/Code_reviewer.py) (Review orchestration), [`web/src/App.js`](https://github.com/oussamcsc/codebase-intelligence/blob/main/web/src/App.js) (App workflow), [`web/src/components/AnalysisResults.js`](https://github.com/oussamcsc/codebase-intelligence/blob/main/web/src/components/AnalysisResults.js) (Review results)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web interface"]
  node_app["App workflow<br/>[App.js]"]
  node_github_view["Repository input<br/>[GitHubAnalyzer.js]"]
  node_progress["Job progress<br/>[ProgressTracker.js]"]
  node_results["Review results<br/>[AnalysisResults.js]"]
  node_frontend_config["API settings<br/>[config.js]"]
end

subgraph group_backend["API and review"]
  node_api["FastAPI jobs<br/>[api.py]"]
  node_auth["GitHub OAuth<br/>[github_auth.py]"]
  node_cli["CLI review<br/>[cli.py]"]
  node_reviewer["Review orchestration<br/>[Code_reviewer.py]"]
  node_config["Runtime settings<br/>[config.py]"]
end

subgraph group_analysis["Static analysis"]
  node_repo_scan["File discovery<br/>[scan_project.py]"]
  node_graph_analysis["Dependency impact"]
  node_patterns["AST patterns<br/>[pattern_matcher.py]"]
  node_types["Type signals<br/>[type_analyzer.py]"]
  node_duplicates["Duplicate detection"]
end

subgraph group_services["State and context"]
  node_sqlite[("Results database<br/>[api.py]")]
  node_rag["RAG context<br/>[Code_reviewer.py]"]
end

node_browser(("Developer"))
node_github["GitHub"]
node_openai["OpenAI"]
node_chroma[("ChromaDB")]

node_browser -->|"uses"| node_app
node_app -->|"renders"| node_github_view
node_app -->|"renders"| node_progress
node_app -->|"renders"| node_results
node_github_view -->|"starts analysis"| node_api
node_progress -->|"polls job"| node_api
node_api -->|"returns results"| node_results
node_results -->|"exports and shares"| node_api
node_frontend_config -->|"sets API URL"| node_api
node_api -->|"uses OAuth"| node_auth
node_auth -->|"exchanges token"| node_github
node_api -->|"runs review"| node_reviewer
node_cli -->|"runs review"| node_reviewer
node_reviewer -->|"runs graph analysis"| node_graph_analysis
node_reviewer -->|"runs pattern checks"| node_patterns
node_reviewer -->|"runs type checks"| node_types
node_reviewer -->|"runs duplicate checks"| node_duplicates
node_reviewer -->|"synthesizes review"| node_openai
node_api -->|"stores job results"| node_sqlite
node_reviewer -->|"retrieves context"| node_rag
node_rag -->|"queries vectors"| node_chroma
node_api -->|"discovers files"| node_repo_scan
node_config -->|"configures"| node_api

click node_app "https://github.com/oussamcsc/codebase-intelligence/blob/main/web/src/App.js"
click node_github_view "https://github.com/oussamcsc/codebase-intelligence/blob/main/web/src/components/GitHubAnalyzer.js"
click node_progress "https://github.com/oussamcsc/codebase-intelligence/blob/main/web/src/components/ProgressTracker.js"
click node_results "https://github.com/oussamcsc/codebase-intelligence/blob/main/web/src/components/AnalysisResults.js"
click node_frontend_config "https://github.com/oussamcsc/codebase-intelligence/blob/main/web/src/config.js"
click node_api "https://github.com/oussamcsc/codebase-intelligence/blob/main/api.py"
click node_auth "https://github.com/oussamcsc/codebase-intelligence/blob/main/github_auth.py"
click node_cli "https://github.com/oussamcsc/codebase-intelligence/blob/main/cli.py"
click node_reviewer "https://github.com/oussamcsc/codebase-intelligence/blob/main/Code_reviewer.py"
click node_config "https://github.com/oussamcsc/codebase-intelligence/blob/main/config.py"
click node_repo_scan "https://github.com/oussamcsc/codebase-intelligence/blob/main/scan_project.py"
click node_graph_analysis "https://github.com/oussamcsc/codebase-intelligence/blob/main/Codebase_analyzer.py"
click node_patterns "https://github.com/oussamcsc/codebase-intelligence/blob/main/pattern_matcher.py"
click node_types "https://github.com/oussamcsc/codebase-intelligence/blob/main/type_analyzer.py"
click node_duplicates "https://github.com/oussamcsc/codebase-intelligence/blob/main/duplicate_detector.py"
click node_sqlite "https://github.com/oussamcsc/codebase-intelligence/blob/main/api.py"
click node_rag "https://github.com/oussamcsc/codebase-intelligence/blob/main/Code_reviewer.py"

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_github_view,node_progress,node_results,node_frontend_config toneBlue
class node_api,node_auth,node_cli,node_reviewer,node_config,node_chroma toneAmber
class node_repo_scan,node_graph_analysis,node_patterns,node_types,node_duplicates toneMint
class node_sqlite,node_rag toneRose
class node_browser,node_github,node_openai toneIndigo
```

## Components

### Web interface

- [App workflow](https://github.com/oussamcsc/codebase-intelligence/blob/main/web/src/App.js): `web/src/App.js`
- [Repository input](https://github.com/oussamcsc/codebase-intelligence/blob/main/web/src/components/GitHubAnalyzer.js): `web/src/components/GitHubAnalyzer.js`
- [Job progress](https://github.com/oussamcsc/codebase-intelligence/blob/main/web/src/components/ProgressTracker.js): `web/src/components/ProgressTracker.js`
- [Review results](https://github.com/oussamcsc/codebase-intelligence/blob/main/web/src/components/AnalysisResults.js): `web/src/components/AnalysisResults.js`
- [API settings](https://github.com/oussamcsc/codebase-intelligence/blob/main/web/src/config.js): `web/src/config.js`

### API and review

- [FastAPI jobs](https://github.com/oussamcsc/codebase-intelligence/blob/main/api.py): `api.py`
- [GitHub OAuth](https://github.com/oussamcsc/codebase-intelligence/blob/main/github_auth.py): `github_auth.py`
- [CLI review](https://github.com/oussamcsc/codebase-intelligence/blob/main/cli.py): `cli.py`
- [Review orchestration](https://github.com/oussamcsc/codebase-intelligence/blob/main/Code_reviewer.py): `Code_reviewer.py`
- [Runtime settings](https://github.com/oussamcsc/codebase-intelligence/blob/main/config.py): `config.py`

### Static analysis

- [File discovery](https://github.com/oussamcsc/codebase-intelligence/blob/main/scan_project.py): `scan_project.py`
- [Dependency impact](https://github.com/oussamcsc/codebase-intelligence/blob/main/Codebase_analyzer.py): `Codebase_analyzer.py`
- [AST patterns](https://github.com/oussamcsc/codebase-intelligence/blob/main/pattern_matcher.py): `pattern_matcher.py`
- [Type signals](https://github.com/oussamcsc/codebase-intelligence/blob/main/type_analyzer.py): `type_analyzer.py`
- [Duplicate detection](https://github.com/oussamcsc/codebase-intelligence/blob/main/duplicate_detector.py): `duplicate_detector.py`

### State and context

- [Results database](https://github.com/oussamcsc/codebase-intelligence/blob/main/api.py): `api.py`
- [RAG context](https://github.com/oussamcsc/codebase-intelligence/blob/main/Code_reviewer.py): `Code_reviewer.py`

### Other components

- **Developer**
- **GitHub**
- **OpenAI**
- **ChromaDB**

## Connections

- Developer → App workflow: uses (evidence: `README.md`)
- App workflow → Repository input: renders (evidence: `web/src/App.js`)
- App workflow → Job progress: renders (evidence: `web/src/App.js`)
- App workflow → Review results: renders (evidence: `web/src/App.js`)
- Repository input → FastAPI jobs: starts analysis (evidence: `web/src/components/GitHubAnalyzer.js`)
- Job progress → FastAPI jobs: polls job (evidence: `web/src/components/ProgressTracker.js`)
- FastAPI jobs → Review results: returns results
- Review results → FastAPI jobs: exports and shares (evidence: `web/src/components/AnalysisResults.js`)
- API settings → FastAPI jobs: sets API URL (evidence: `web/src/config.js`)
- FastAPI jobs → GitHub OAuth: uses OAuth (evidence: `api.py`)
- GitHub OAuth → GitHub: exchanges token (evidence: `github_auth.py`)
- FastAPI jobs → Review orchestration: runs review (evidence: `README.md`)
- CLI review → Review orchestration: runs review (evidence: `cli.py`)
- Review orchestration → Dependency impact: runs graph analysis (evidence: `Code_reviewer.py`)
- Review orchestration → AST patterns: runs pattern checks (evidence: `Code_reviewer.py`)
- Review orchestration → Type signals: runs type checks (evidence: `Code_reviewer.py`)
- Review orchestration → Duplicate detection: runs duplicate checks (evidence: `Code_reviewer.py`)
- Review orchestration → OpenAI: synthesizes review (evidence: `Code_reviewer.py`)
- FastAPI jobs → Results database: stores job results (evidence: `README.md`)
- Review orchestration → RAG context: retrieves context (evidence: `README.md`)
- RAG context → ChromaDB: queries vectors (evidence: `README.md`)
- FastAPI jobs → File discovery: discovers files (evidence: `README.md`)
- Runtime settings → FastAPI jobs: configures (evidence: `api.py`)
