# praveena-pawar/codeguard-ai architecture

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

- Interactive diagram: https://gitdiagram.com/praveena-pawar/codeguard-ai
- Repository: https://github.com/praveena-pawar/codeguard-ai

## Overview

CodeGuard AI accepts Python source in its React interface, then the FastAPI analysis route orchestrates issue detection, explanations, generated tests, original-code execution, fix generation and validation, rescoring, and persistence. The interface presents issues, tests, the fix, and before/after scores. README capabilities fill in the analyzer’s AST/Ruff combination; sampled source confirms the route’s orchestration and persistence calls. Some service internals and frontend request handling are only partially excerpted, so uncertain internal links are omitted.

Main entry points: [`backend/app/api/routes/analysis.py`](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/api/routes/analysis.py) (Analysis route), [`frontend/src/App.tsx`](https://github.com/praveena-pawar/codeguard-ai/blob/main/frontend/src/App.tsx) (Code editor UI), [`backend/app/main.py`](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/main.py) (FastAPI app), [`backend/app/services/analyzer.py`](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/analyzer.py) (Code analyzer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Developer interface"]
  node_frontend["Code editor UI<br/>[App.tsx]"]
  node_frontend_entry["React entry<br/>[main.tsx]"]
end

subgraph group_orchestration["Analysis API"]
  node_api["FastAPI app<br/>[main.py]"]
  node_analysis_route["Analysis route<br/>[analysis.py]"]
end

subgraph group_workflow["Analysis workflow"]
  node_analyzer["Code analyzer<br/>[analyzer.py]"]
  node_ruff["Ruff analysis<br/>[ruff_service.py]"]
  node_explainer["AI explainer<br/>[ai_service.py]"]
  node_test_generator["Test generator<br/>[test_generator.py]"]
  node_test_runner["Test runner<br/>[test_runner.py]"]
  node_fix_generator["Fix generator<br/>[ai_fix_service.py]"]
  node_fix_validator["Fix validator<br/>[fix_validator.py]"]
  node_quality_scorer["Quality scorer<br/>[quality_scorer.py]"]
end

subgraph group_persistence["Persistence"]
  node_database_helpers["Persistence helpers<br/>[database.py]"]
  node_supabase_client["Supabase client<br/>[supabase.py]"]
end

node_developer(("Developer"))
node_supabase_db[("Supabase database")]
node_groq["Groq AI"]

node_developer -->|"submits code"| node_frontend
node_frontend_entry -->|"renders"| node_frontend
node_frontend -->|"POSTs analysis"| node_api
node_api -->|"routes request"| node_analysis_route
node_analysis_route -->|"analyzes code"| node_analyzer
node_analyzer -->|"runs lint"| node_ruff
node_analysis_route -->|"explains issues"| node_explainer
node_explainer -->|"requests explanation"| node_groq
node_analysis_route -->|"generates tests"| node_test_generator
node_analysis_route -->|"runs original tests"| node_test_runner
node_analysis_route -->|"generates fix"| node_fix_generator
node_fix_generator -->|"requests correction"| node_groq
node_analysis_route -->|"validates fix"| node_fix_validator
node_analysis_route -->|"scores results"| node_quality_scorer
node_analysis_route -->|"stores analysis"| node_database_helpers
node_database_helpers -->|"uses client"| node_supabase_client
node_supabase_client -->|"connects"| node_supabase_db
node_analysis_route -->|"returns results"| node_frontend

click node_frontend "https://github.com/praveena-pawar/codeguard-ai/blob/main/frontend/src/App.tsx"
click node_frontend_entry "https://github.com/praveena-pawar/codeguard-ai/blob/main/frontend/src/main.tsx"
click node_api "https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/main.py"
click node_analysis_route "https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/api/routes/analysis.py"
click node_analyzer "https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/analyzer.py"
click node_ruff "https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/ruff_service.py"
click node_explainer "https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/ai_service.py"
click node_test_generator "https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/test_generator.py"
click node_test_runner "https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/test_runner.py"
click node_fix_generator "https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/ai_fix_service.py"
click node_fix_validator "https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/fix_validator.py"
click node_quality_scorer "https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/quality_scorer.py"
click node_database_helpers "https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/database.py"
click node_supabase_client "https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/core/supabase.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_frontend,node_frontend_entry toneBlue
class node_api,node_analysis_route,node_supabase_db toneAmber
class node_analyzer,node_ruff,node_explainer,node_test_generator,node_test_runner,node_fix_generator,node_fix_validator,node_quality_scorer toneMint
class node_database_helpers,node_supabase_client toneRose
class node_developer,node_groq toneIndigo
```

## Components

### Developer interface

- [Code editor UI](https://github.com/praveena-pawar/codeguard-ai/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [React entry](https://github.com/praveena-pawar/codeguard-ai/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`

### Analysis API

- [FastAPI app](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/main.py): `backend/app/main.py`
- [Analysis route](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/api/routes/analysis.py): `backend/app/api/routes/analysis.py`

### Analysis workflow

- [Code analyzer](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/analyzer.py): `backend/app/services/analyzer.py`
- [Ruff analysis](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/ruff_service.py): `backend/app/services/ruff_service.py`
- [AI explainer](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/ai_service.py): `backend/app/services/ai_service.py`
- [Test generator](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/test_generator.py): `backend/app/services/test_generator.py`
- [Test runner](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/test_runner.py): `backend/app/services/test_runner.py`
- [Fix generator](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/ai_fix_service.py): `backend/app/services/ai_fix_service.py`
- [Fix validator](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/fix_validator.py): `backend/app/services/fix_validator.py`
- [Quality scorer](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/quality_scorer.py): `backend/app/services/quality_scorer.py`

### Persistence

- [Persistence helpers](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/services/database.py): `backend/app/services/database.py`
- [Supabase client](https://github.com/praveena-pawar/codeguard-ai/blob/main/backend/app/core/supabase.py): `backend/app/core/supabase.py`

### Other components

- **Developer**
- **Supabase database**
- **Groq AI**

## Connections

- Developer → Code editor UI: submits code
- React entry → Code editor UI: renders
- Code editor UI → FastAPI app: POSTs analysis
- FastAPI app → Analysis route: routes request
- Analysis route → Code analyzer: analyzes code
- Code analyzer → Ruff analysis: runs lint
- Analysis route → AI explainer: explains issues
- AI explainer → Groq AI: requests explanation
- Analysis route → Test generator: generates tests
- Analysis route → Test runner: runs original tests
- Analysis route → Fix generator: generates fix
- Fix generator → Groq AI: requests correction
- Analysis route → Fix validator: validates fix
- Analysis route → Quality scorer: scores results
- Analysis route → Persistence helpers: stores analysis
- Persistence helpers → Supabase client: uses client
- Supabase client → Supabase database: connects
- Analysis route → Code editor UI: returns results
