# gavbarosee/gitdiagram architecture

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

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

## Overview

##### Main Components
- Frontend:
- Located under the “src” directory.
- Built with Next.js, TypeScript, Tailwind CSS, and ShadCN.
- Contains dynamic routing (e.g., pages for user repositories) and UI components (found in src/components and src/app).
- Backend:
- Found in the “backend” folder.
- A FastAPI application structured as modular routers (e.g., “/routers/generate.py”, “/routers/modify.py”), services (like “claude_service.py”, GitHub and OpenAI services), and utility functions.
- Contains prompt engineering logic in backend/app/prompts.py for extracting and processing GitHub repository data.
- Database:
- PostgreSQL managed via Drizzle ORM, with schema and connection management under src/server/db.
- Reverse Proxy & Deployment Tools:
- Nginx configuration files under backend/nginx (api.conf and setup_nginx.sh) signal that Nginx is used to route incoming API requests.
- Dockerfiles, docker-compose.yml, and various shell scripts (e.g., deploy.sh, entrypoint.sh) showcase a containerized deployment and self-hosting strategy.
- External Integrations & Services:
- CI/CD:
- GitHub Actions are present (in .github/workflows) to automate deployments.

##### Relationships & Interactions
- The Frontend and Backend are decoupled but closely integrated via API calls. The frontend sends repository URLs or parameters to the backend.
- The backend also communicates with the PostgreSQL database for storing any persistent data or caching (as managed in src/server/db).
- Docker and Nginx act as orchestration and reverse proxy layers to ensure proper traffic distribution and service isolation.
- CI/CD pipelines ensure continuous integration and deployment, coordinating code changes across these layers.

##### Architectural Patterns and Key Technologies
- The project exhibits a clear separation of concerns between the frontend (UI, routing, React components) and backend (API endpoints, microservices architecture within the backend/app directory).
- Use of containerization (Docker) and reverse proxy (Nginx) indicates a microservices or loosely-coupled service architecture.
- The use of server actions in the backend and Next.js’s dynamic pages in the frontend are key design patterns.
- Integration with external services (GitHub, OpenAI) highlights an event-driven and API-first approach.

##### Elements
- Clear labels for:
- “Frontend (Next.js/TypeScript/Tailwind)” representing the src directory.
- “Backend (FastAPI/Python)” covering the app’s routers, services (o3-mini, Claude, GitHub service modules), and prompt engine.
- “Database (PostgreSQL/Drizzle ORM)” with an indication of the src/server/db structure.
- “Reverse Proxy/Deployment (Nginx, Docker Compose)” as seen in the backend/nginx and docker-compose.yml.
- “External Integrations” (GitHub API, OpenAI/Claude APIs).
- Data flow from the Frontend to the Backend APIs.
- Internal calls within the backend (e.g., from generate router to various service modules).
- Interactions with the Database and External Services.
- Components representing CI/CD (GitHub Actions workflows) as supporting infrastructure.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend (Next.js/TypeScript/Tailwind)"
        FE1("src/app: Pages & Dynamic Routing"):::frontend
        FE2("src/components: UI Components"):::frontend
    end

    %% Backend Layer
    subgraph "Backend (FastAPI/Python API & Prompt Engineering)"
        BE1("backend/app/main.py: API Gateway"):::backend
        BE2("backend/app/prompts.py: Prompt Engine"):::backend
        BE3("backend/app/routers/generate.py: Generate Router"):::backend
        BE4("backend/app/routers/modify.py: Modify Router"):::backend
        BE5("backend/app/services: Service Modules"):::backend
    end

    %% Database Layer
    subgraph "Database (PostgreSQL/Drizzle ORM)"
        DB1("src/server/db/index.ts: Connection"):::database
        DB2("src/server/db/schema.ts: Schema"):::database
    end

    %% Deployment & Infrastructure Layer
    subgraph "Deployment & Infrastructure"
        DEP1("backend/nginx/api.conf: Nginx Config"):::deployment
        DEP2("backend/nginx/setup_nginx.sh: Nginx Setup"):::deployment
        DEP3("docker-compose.yml: Container Orchestration"):::deployment
        DEP4("backend/Dockerfile: Build Config"):::deployment
        DEP5("backend/deploy.sh: Deployment Script"):::deployment
        DEP6("backend/entrypoint.sh: Entrypoint Script"):::deployment
    end

    %% External Integrations
    subgraph "External Integrations"
        EX1("GitHub API"):::external
        EX2("OpenAI/Claude API"):::external
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        CI1(".github/workflows/deploy.yml: GitHub Actions"):::cicd
    end

    %% Data Flow / Relationships
    FE1 -->|"sends_request"| BE1
    FE2 -->|"sends_UI_events"| BE1

    BE1 -->|"routes_generate"| BE3
    BE1 -->|"routes_modify"| BE4

    BE3 -->|"calls_prompt_engine"| BE2
    BE4 -->|"calls_prompt_engine"| BE2

    BE3 -->|"invokes_services"| BE5
    BE4 -->|"invokes_services"| BE5

    BE1 -->|"db_operations"| DB1
    BE1 -->|"db_operations"| DB2

    BE5 -->|"calls_GitHub_API"| EX1
    BE5 -->|"calls_AI_service"| EX2

    DEP1 -->|"reverse_proxy"| BE1

    CI1 -->|"triggers_deployment"| DEP3

    %% Click Events for Component Mapping
    click FE1 "https://github.com/gavbarosee/gitdiagram/tree/main/src/app"
    click FE2 "https://github.com/gavbarosee/gitdiagram/tree/main/src/components"
    click BE1 "https://github.com/gavbarosee/gitdiagram/blob/main/backend/app/main.py"
    click BE2 "https://github.com/gavbarosee/gitdiagram/blob/main/backend/app/prompts.py"
    click BE3 "https://github.com/gavbarosee/gitdiagram/blob/main/backend/app/routers/generate.py"
    click BE4 "https://github.com/gavbarosee/gitdiagram/blob/main/backend/app/routers/modify.py"
    click BE5 "https://github.com/gavbarosee/gitdiagram/tree/main/backend/app/services/"
    click DB1 "https://github.com/gavbarosee/gitdiagram/blob/main/src/server/db/index.ts"
    click DB2 "https://github.com/gavbarosee/gitdiagram/blob/main/src/server/db/schema.ts"
    click DEP1 "https://github.com/gavbarosee/gitdiagram/blob/main/backend/nginx/api.conf"
    click DEP2 "https://github.com/gavbarosee/gitdiagram/blob/main/backend/nginx/setup_nginx.sh"
    click DEP3 "https://github.com/gavbarosee/gitdiagram/blob/main/docker-compose.yml"
    click DEP4 "https://github.com/gavbarosee/gitdiagram/tree/main/backend/Dockerfile"
    click DEP5 "https://github.com/gavbarosee/gitdiagram/blob/main/backend/deploy.sh"
    click DEP6 "https://github.com/gavbarosee/gitdiagram/blob/main/backend/entrypoint.sh"
    click CI1 "https://github.com/gavbarosee/gitdiagram/blob/main/.github/workflows/deploy.yml"

    %% Styling
    classDef frontend fill:#FAD02E,stroke:#333,stroke-width:2px;
    classDef backend fill:#A2D2FF,stroke:#333,stroke-width:2px;
    classDef database fill:#CDEAC0,stroke:#333,stroke-width:2px;
    classDef deployment fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef cicd fill:#E7A1A1,stroke:#333,stroke-width:2px;
```
