# nv-duymanh/pythonproject architecture

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

- Interactive diagram: https://gitdiagram.com/nv-duymanh/pythonproject
- Repository: https://github.com/nv-duymanh/pythonproject
- Video tour (about a minute): https://gitdiagram.com/nv-duymanh/pythonproject/video

## Overview

CodeGate receives GitHub pull-request events, queues asynchronous analysis, evaluates changes through AI review, static analysis, and test/coverage evidence, then computes quality and risk scores, applies merge policy, and recommends reviewers. Results are persisted, published to GitHub, and explored in the dashboard. The README documents the end-to-end workflow; sampled source confirms API registration and scoring behavior, but not every service-to-service call, so uncertain wiring is omitted.

Main entry points: [`codegate/services/analysis_orchestrator.py`](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/services/analysis_orchestrator.py) (Analysis Orchestrator), [`codegate/services/analysis_service.py`](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/services/analysis_service.py) (Analysis Services), [`codegate/api/main.py`](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/api/main.py) (FastAPI API), [`codegate/api/routers/webhooks.py`](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/api/routers/webhooks.py) (Webhook Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["API &amp; Integration"]
  node_api["FastAPI API<br/>[main.py]"]
  node_webhooks["Webhook Routes<br/>[webhooks.py]"]
  node_github_service["GitHub Services<br/>[github_app.py]"]
end

subgraph group_analysis["Analysis Engines"]
  node_orchestrator["Analysis Orchestrator"]
  node_ai_review["AI Review<br/>[adapter.py]"]
  node_static_analysis["Static Analyzers<br/>[runner.py]"]
  node_testing["Test &amp; Coverage<br/>[executor.py]"]
end

subgraph group_decision["Scoring &amp; Decisions"]
  node_quality["Quality Scoring<br/>[engine.py]"]
  node_risk["Risk Scoring<br/>[engine.py]"]
  node_policy["Merge Policy<br/>[engine.py]"]
  node_reviewers["Reviewer Recommendations<br/>[engine.py]"]
  node_services["Analysis Services"]
end

subgraph group_storage["Persistence &amp; Jobs"]
  node_queue["Celery &amp; Redis<br/>[celery_app.py]"]
  node_worker["Analysis Worker<br/>[tasks.py]"]
  node_db[("PostgreSQL<br/>[session.py]")]
  node_stores["Result Stores<br/>[analysis_store.py]"]
end

subgraph group_product["User Experience"]
  node_dashboard["React Dashboard<br/>[App.tsx]"]
  node_client["Dashboard API Client<br/>[client.ts]"]
  node_analytics["Analytics Services"]
end

node_developer(("Developer"))
node_github["GitHub"]

node_developer -->|"opens PR"| node_github
node_github -->|"sends event"| node_webhooks
node_webhooks -->|"enqueues analysis"| node_queue
node_queue -->|"dispatches job"| node_worker
node_worker -->|"runs analysis"| node_orchestrator
node_orchestrator -->|"requests review"| node_ai_review
node_orchestrator -->|"scans changes"| node_static_analysis
node_orchestrator -->|"evaluates tests"| node_testing
node_orchestrator -->|"scores findings"| node_quality
node_orchestrator -->|"scores risk"| node_risk
node_orchestrator -->|"evaluates evidence"| node_policy
node_orchestrator -->|"requests recommendations"| node_reviewers
node_orchestrator -->|"coordinates results"| node_services
node_services -->|"persists results"| node_stores
node_stores -->|"reads and writes"| node_db
node_services -->|"publishes check"| node_github_service
node_github_service -->|"updates PR"| node_github
node_developer -->|"views results"| node_dashboard
node_dashboard -->|"requests data"| node_client
node_client -->|"calls API"| node_api
node_api -->|"routes analytics"| node_analytics
node_analytics -->|"queries data"| node_db

click node_api "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/api/main.py"
click node_webhooks "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/api/routers/webhooks.py"
click node_github_service "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/services/github_app.py"
click node_queue "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/worker/celery_app.py"
click node_worker "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/worker/tasks.py"
click node_orchestrator "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/services/analysis_orchestrator.py"
click node_ai_review "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/integrations/pr_agent/adapter.py"
click node_static_analysis "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/engines/analyzers/runner.py"
click node_testing "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/engines/testing/executor.py"
click node_quality "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/engines/quality/engine.py"
click node_risk "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/engines/risk/engine.py"
click node_policy "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/engines/policy/engine.py"
click node_reviewers "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/engines/reviewer/engine.py"
click node_services "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/services/analysis_service.py"
click node_db "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/database/session.py"
click node_stores "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/repositories/analysis_store.py"
click node_dashboard "https://github.com/nv-duymanh/pythonproject/blob/main/dashboard/src/App.tsx"
click node_client "https://github.com/nv-duymanh/pythonproject/blob/main/dashboard/src/api/client.ts"
click node_analytics "https://github.com/nv-duymanh/pythonproject/blob/main/codegate/services/analytics_service.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_api,node_webhooks,node_github_service toneBlue
class node_orchestrator,node_ai_review,node_static_analysis,node_testing toneAmber
class node_quality,node_risk,node_policy,node_reviewers,node_services toneMint
class node_queue,node_worker,node_db,node_stores toneRose
class node_dashboard,node_client,node_analytics,node_developer,node_github toneIndigo
```

## Components

### API & Integration

- [FastAPI API](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/api/main.py): `codegate/api/main.py`
- [Webhook Routes](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/api/routers/webhooks.py): `codegate/api/routers/webhooks.py`
- [GitHub Services](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/services/github_app.py): `codegate/services/github_app.py`

### Analysis Engines

- [Analysis Orchestrator](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/services/analysis_orchestrator.py): `codegate/services/analysis_orchestrator.py`
- [AI Review](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/integrations/pr_agent/adapter.py): `codegate/integrations/pr_agent/adapter.py`
- [Static Analyzers](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/engines/analyzers/runner.py): `codegate/engines/analyzers/runner.py`
- [Test & Coverage](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/engines/testing/executor.py): `codegate/engines/testing/executor.py`

### Scoring & Decisions

- [Quality Scoring](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/engines/quality/engine.py): `codegate/engines/quality/engine.py`
- [Risk Scoring](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/engines/risk/engine.py): `codegate/engines/risk/engine.py`
- [Merge Policy](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/engines/policy/engine.py): `codegate/engines/policy/engine.py`
- [Reviewer Recommendations](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/engines/reviewer/engine.py): `codegate/engines/reviewer/engine.py`
- [Analysis Services](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/services/analysis_service.py): `codegate/services/analysis_service.py`

### Persistence & Jobs

- [Celery & Redis](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/worker/celery_app.py): `codegate/worker/celery_app.py`
- [Analysis Worker](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/worker/tasks.py): `codegate/worker/tasks.py`
- [PostgreSQL](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/database/session.py): `codegate/database/session.py`
- [Result Stores](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/repositories/analysis_store.py): `codegate/repositories/analysis_store.py`

### User Experience

- [React Dashboard](https://github.com/nv-duymanh/pythonproject/blob/main/dashboard/src/App.tsx): `dashboard/src/App.tsx`
- [Dashboard API Client](https://github.com/nv-duymanh/pythonproject/blob/main/dashboard/src/api/client.ts): `dashboard/src/api/client.ts`
- [Analytics Services](https://github.com/nv-duymanh/pythonproject/blob/main/codegate/services/analytics_service.py): `codegate/services/analytics_service.py`

### Other components

- **Developer**
- **GitHub**

## Connections

- Developer → GitHub: opens PR
- GitHub → Webhook Routes: sends event
- Webhook Routes → Celery & Redis: enqueues analysis
- Celery & Redis → Analysis Worker: dispatches job
- Analysis Worker → Analysis Orchestrator: runs analysis
- Analysis Orchestrator → AI Review: requests review
- Analysis Orchestrator → Static Analyzers: scans changes
- Analysis Orchestrator → Test & Coverage: evaluates tests
- Analysis Orchestrator → Quality Scoring: scores findings
- Analysis Orchestrator → Risk Scoring: scores risk
- Analysis Orchestrator → Merge Policy: evaluates evidence
- Analysis Orchestrator → Reviewer Recommendations: requests recommendations
- Analysis Orchestrator → Analysis Services: coordinates results
- Analysis Services → Result Stores: persists results
- Result Stores → PostgreSQL: reads and writes
- Analysis Services → GitHub Services: publishes check
- GitHub Services → GitHub: updates PR
- Developer → React Dashboard: views results
- React Dashboard → Dashboard API Client: requests data
- Dashboard API Client → FastAPI API: calls API
- FastAPI API → Analytics Services: routes analytics
- Analytics Services → PostgreSQL: queries data
