# 66my/gitdiagram architecture

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

- Interactive diagram: https://gitdiagram.com/66my/gitdiagram
- Repository: https://github.com/66my/gitdiagram

## Overview

##### Main Components
- Database: A PostgreSQL instance managed by Drizzle ORM (configuration and schema found under src/server/db) that stores any persistent data required.
- External Integrations:
- GitHub: To obtain repository data (both public and private).
- Additional services such as API analytics (PostHog, Api-Analytics) and possibly GitHub Actions for CI/CD.
- Deployment & DevOps: Docker (Dockerfile, docker-compose.yml, and deployment scripts for backend) and Nginx (located under backend/nginx) used to containerize and route requests. CI/CD is powered by GitHub Actions (see .github/workflows).

##### Mapping Relationships and Interactions
- Frontend sends requests (via API calls) to the Backend.
- The Backend fetches repository structures from GitHub, processes the data (via various services and prompts), and accesses the Database if necessary.
- Flow from a user’s browser to the frontend, API, external services (GitHub and AI), and then back.

##### Architectural Patterns
- Modular separation within the backend:
- Routers (defining API endpoints),
- Services (handling business logic and external API interactions), and
- Utilities (supporting functions like format_message).
- For the frontend, note the component-based structure (components, hooks, lib, and server directories) typical of Next.js applications.

##### With Technologies & Frameworks
- Next.js, TypeScript, Tailwind CSS, and ShadCN for the frontend.
- FastAPI, Python, and Server Actions in the backend.
- PostgreSQL managed via Drizzle ORM for database management.
- Docker, Nginx, and GitHub Actions for deployment and CI/CD.
- External integrations: GitHub APIs and AI services (OpenAI o3-mini / Anthropic API).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User Browser"]:::user

    subgraph "Frontend Layer"
        F["Next.js UI (Interactive Diagram Rendering)"]:::frontend
    end

    subgraph "Backend Layer"
        B1["API Router & Endpoints"]:::backend
        B2["Prompt Processing (/backend/app/prompts.py)"]:::backend
        B3["Business Logic & Services"]:::backend
    end

    Database["PostgreSQL Database (Drizzle ORM)"]:::database
    ExternalIntegrations["External Integrations (GitHub & AI Services)"]:::external

    subgraph "Deployment & DevOps"
        D1["Docker & Containerization"]:::devops
        D2["Nginx (Routing)"]:::devops
        D3["CI/CD (GitHub Actions)"]:::devops
    end

    User -->|"UIRequest"| F
    F -->|"APIRequest"| B1
    B1 -->|"CallPrompts"| B2
    B1 -->|"DelegateServices"| B3
    B2 -->|"ProcessRequest"| B3
    B3 -->|"DatabaseQuery"| Database
    B3 -->|"FetchData"| ExternalIntegrations
    B3 -->|"SendDiagram"| F
    B3 -->|"DeployedVia"| D1
    B3 -->|"RoutedBy"| D2
    B3 -->|"CI/CDDeploy"| D3

    %% Click Events for Frontend (UI Layer)
    click F "https://github.com/66my/gitdiagram/tree/main/src/app"
    click F "https://github.com/66my/gitdiagram/tree/main/src/components"
    click F "https://github.com/66my/gitdiagram/tree/main/src/hooks"
    click F "https://github.com/66my/gitdiagram/tree/main/src/lib"
    click F "https://github.com/66my/gitdiagram/blob/main/src/app/page.tsx"
    click F "https://github.com/66my/gitdiagram/blob/main/src/components/mermaid-diagram.tsx"

    %% Click Events for Backend (API & Processing Layer)
    click B1 "https://github.com/66my/gitdiagram/tree/main/backend/app"
    click B1 "https://github.com/66my/gitdiagram/blob/main/backend/app/main.py"
    click B1 "https://github.com/66my/gitdiagram/tree/main/backend/app/routers"
    click B2 "https://github.com/66my/gitdiagram/blob/main/backend/app/prompts.py"
    click B3 "https://github.com/66my/gitdiagram/tree/main/backend/app/services"
    click B3 "https://github.com/66my/gitdiagram/tree/main/backend/app/utils"

    %% Click Events for Database
    click Database "https://github.com/66my/gitdiagram/tree/main/src/server/db"
    click Database "https://github.com/66my/gitdiagram/blob/main/src/server/db/index.ts"
    click Database "https://github.com/66my/gitdiagram/blob/main/src/server/db/schema.ts"

    %% Click Events for External Integrations
    click ExternalIntegrations "https://github.com/66my/gitdiagram/blob/main/backend/app/services/github_service.py"
    click ExternalIntegrations "https://github.com/66my/gitdiagram/blob/main/backend/app/services/o3_mini_openai_service.py"
    click ExternalIntegrations "https://github.com/66my/gitdiagram/blob/main/backend/app/services/claude_service.py"

    %% Click Events for Deployment & DevOps
    click D1 "https://github.com/66my/gitdiagram/tree/main/backend/Dockerfile"
    click D1 "https://github.com/66my/gitdiagram/blob/main/docker-compose.yml"
    click D2 "https://github.com/66my/gitdiagram/tree/main/backend/nginx"
    click D3 "https://github.com/66my/gitdiagram/blob/main/.github/workflows/deploy.yml"

    %% Styles
    classDef user fill:#ffeedd,stroke:#d35400,stroke-width:2px;
    classDef frontend fill:#cce5ff,stroke:#3399ff,stroke-width:2px;
    classDef backend fill:#e6ffe6,stroke:#27ae60,stroke-width:2px;
    classDef database fill:#fff0b3,stroke:#f39c12,stroke-width:2px;
    classDef external fill:#fddde6,stroke:#e74c3c,stroke-width:2px;
    classDef devops fill:#f0e6ff,stroke:#8e44ad,stroke-width:2px;
```
