# martin226/gitdiagram architecture

> Architecture diagram of the GitHub repository martin226/gitdiagram, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/martin226/gitdiagram
- Repository: https://github.com/martin226/gitdiagram

## Overview

##### File Structure
- Top-level:
- frontend: `src/`, `public/`, `components/`, Next.js config, Tailwind config
- backend: `backend/app/routers/`, `/services/`, `/prompts.py`, FastAPI entrypoint, Docker + nginx
- database: `src/server/db/` (Drizzle ORM, PostgreSQL schema)
- infra & CI/CD: `docker-compose.yml`, `.github/workflows/`, `deploy.sh`, `start-database.sh`
- Patterns:
- Clear separation between UI (React/Next.js + ShadCN components) and API (FastAPI)
- AI orchestration via prompt modules (`prompts.py`) and service adapters (`claude_service.py`, `o3_mini_openrouter_service.py`)
- Rate limiting and request routing in `backend/app/core/limiter.py` and `routers/generate.py`

##### README for Additional Insights
- Architecture described: Frontend (Vercel), Backend (EC2 + Docker), Database (Postgres), AI (Claude 3.5 Sonnet), CI/CD (GitHub Actions)
- Features: interactivity, fast generation, customization, private-repo auth

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        User["User"]:::user
        Frontend["Next.js App"]:::frontend
        FetchClient["Fetch Backend Client"]:::frontend
        Pages["App Pages"]:::frontend
        Components["UI Components"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        NGINX["nginx Proxy"]:::infra
        FastAPI["FastAPI Service"]:::backend
        Routers["Routers"]:::backend
        Middleware["Rate Limiter"]:::backend
        Prompts["Prompt Pipeline"]:::backend
        Services["Service Adapters"]:::backend
        Utils["Message Formatter"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Database["PostgreSQL (Drizzle ORM)"]:::database
    end

    %% Integration Layer
    subgraph "Integration Layer"
        direction TB
        AI["AI Provider (Claude/OpenRouter)"]:::external
        GitHub["GitHub API"]:::external
        Analytics["Analytics"]:::analytics
    end

    %% CI/CD & Infra
    subgraph "CI/CD & Infra"
        direction TB
        CI["GitHub Actions"]:::infra
        DeployScripts["Deployment Scripts"]:::infra
        DockerCompose["docker-compose.yml"]:::infra
    end

    %% Connections
    User -->|"interacts via HTTPS"| Frontend
    Frontend -->|"uses fetch-backend"| FetchClient
    FetchClient -->|"HTTPS"| NGINX
    NGINX -->|"proxy to"| FastAPI
    FastAPI -->|"routes requests"| Routers
    Routers -->|"middleware"| Middleware
    Middleware -->|"executes prompts"| Prompts
    Prompts -->|"calls"| Services
    Services -->|"format via"| Utils
    Services -->|"fetch tree/README"| GitHub
    Services -->|"send prompts"| AI
    FastAPI -->|"SQL via ORM"| Database
    FastAPI -->|"log events"| Analytics
    Frontend -->|"server actions"| Database

    CI -->|"deploy frontend"| Frontend
    CI -->|"deploy API"| FastAPI
    CI -->|"start services"| DockerCompose
    CI -->|"run scripts"| DeployScripts

    %% Click Events
    click Frontend "https://github.com/martin226/gitdiagram/tree/main/src/app/"
    click Pages "https://github.com/martin226/gitdiagram/blob/main/src/app/page.tsx"
    click Pages "https://github.com/martin226/gitdiagram/blob/main/src/app/layout.tsx"
    click Pages "https://github.com/martin226/gitdiagram/blob/main/src/app/[username]/[repo]/page.tsx"
    click Components "https://github.com/martin226/gitdiagram/tree/main/src/components/"
    click FetchClient "https://github.com/martin226/gitdiagram/blob/main/src/lib/fetch-backend.ts"
    click FastAPI "https://github.com/martin226/gitdiagram/blob/main/backend/app/main.py"
    click Routers "https://github.com/martin226/gitdiagram/blob/main/backend/app/routers/generate.py"
    click Routers "https://github.com/martin226/gitdiagram/blob/main/backend/app/routers/modify.py"
    click Middleware "https://github.com/martin226/gitdiagram/blob/main/backend/app/core/limiter.py"
    click Prompts "https://github.com/martin226/gitdiagram/blob/main/backend/app/prompts.py"
    click Services "https://github.com/martin226/gitdiagram/blob/main/backend/app/services/claude_service.py"
    click Services "https://github.com/martin226/gitdiagram/blob/main/backend/app/services/o3_mini_openrouter_service.py"
    click Services "https://github.com/martin226/gitdiagram/blob/main/backend/app/services/github_service.py"
    click Utils "https://github.com/martin226/gitdiagram/blob/main/backend/app/utils/format_message.py"
    click Database "https://github.com/martin226/gitdiagram/blob/main/drizzle.config.ts"
    click Database "https://github.com/martin226/gitdiagram/blob/main/src/server/db/schema.ts"
    click Database "https://github.com/martin226/gitdiagram/blob/main/src/server/db/index.ts"
    click DockerCompose "https://github.com/martin226/gitdiagram/blob/main/docker-compose.yml"
    click DeployScripts "https://github.com/martin226/gitdiagram/blob/main/.github/workflows/deploy.yml"
    click DeployScripts "https://github.com/martin226/gitdiagram/blob/main/backend/deploy.sh"
    click DeployScripts "https://github.com/martin226/gitdiagram/blob/main/deploy.sh"
    click DeployScripts "https://github.com/martin226/gitdiagram/blob/main/start-database.sh"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef backend fill:#E8F1FF,stroke:#1F73B7,color:#1F73B7
    classDef database fill:#E8FFE8,stroke:#28A745,color:#28A745
    classDef external fill:#F3E8FF,stroke:#6F42C1,color:#6F42C1
    classDef infra fill:#FFF4E8,stroke:#D97706,color:#D97706
    classDef analytics fill:#FFE8F0,stroke:#D6336C,color:#D6336C
    classDef user fill:#FFFFD0,stroke:#D4A017,color:#D4A017
```
