# sekhar08/gitdiagram architecture

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

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

## Overview

##### File Structure
- The file tree reveals two major parts:
- Frontend: The “src” directory holds the Next.js application using TypeScript and Tailwind CSS. This includes pages, server actions (in src/app/_actions), components (common UI and interactive elements), and hooks.
- Backend: The “backend” directory contains FastAPI code (Python) – organized under “backend/app” with routers (e.g., generate.py, modify.py), services (e.g., multiple OpenAI services, GitHub services), and prompt logic. Additionally, there are Docker and shell script files (Dockerfile, deploy.sh, entrypoint.sh) and an Nginx configuration for reverse proxying.
- Other notable elements:
- Configuration for CI/CD (the .github directory with workflows).
- A Docker Compose file orchestrating multi-container deployment (likely tying together backend and database).
- Database initialization files/scripts (start-database.sh and src/server/db).
- Development configurations (tailwind.config, tsconfig, drizzle.config) indicating use of PostgreSQL via Drizzle ORM.

##### Key Components
- Frontend Web Application:
- Backend API Server:
- Core modules include prompt management (in prompts.py), API routers (generate and modify), and services integrating external APIs.
- Nginx, as configured in “backend/nginx”, acts as a reverse proxy routing incoming requests appropriately.
- Database:
- PostgreSQL (with Drizzle ORM) is used to store application data. The database is managed via scripts like start-database.sh and the schema under “src/server/db”.
- External Services and Integrations:
- GitHub APIs (and potentially other external sources) to extract repository information.
- Deployment and CI/CD:
- Docker and Docker Compose provide containerization for both backend services and the PostgreSQL database.
- CI/CD pipelines through GitHub Actions automate testing, deployment (refer to backend deploy.sh and .github/workflows), and monitoring.

##### Relationships and Interactions
- The Backend also interacts with the PostgreSQL database to store/retrieve persistent data.
- Nginx acts as a gateway to the backend services, directing traffic efficiently.
- CI/CD pipelines manage code integration and deployment to platforms such as Vercel for the Frontend and EC2 for the Backend.

##### Architectural Patterns and Technologies
- Separation of concerns is evident: clear delineation between the Frontend (Next.js) and Backend (FastAPI).
- Microservice-like separation within the backend where routers, services, and utility modules handle distinct responsibilities.
- Use of containerization (Docker, Docker Compose) supports modular deployments.

## Diagram (Mermaid)

```mermaid
flowchart TD

  %% Frontend Layer
  subgraph "Frontend"
    FEApp["Frontend Web Application"]:::frontend
    FEComponents["Server Actions & UI Components"]:::frontend
  end

  %% Reverse Proxy
  Nginx["Nginx Reverse Proxy"]:::backend

  %% Backend Layer
  subgraph "Backend"
    BEApi["Backend API Server"]:::backend
    BERouters["API Routers"]:::backend
    BEPrompts["Prompt Engineering Module"]:::backend
  end

  %% External Services
  subgraph "External Services"
    ESClaude["Claude Service"]:::external
    ESGithub["GitHub Service"]:::external
    ESO1["OpenAI Service (O1 Mini)"]:::external
    ESO3["OpenAI Service (O3 Mini)"]:::external
    ESO3Router["Open Router Service (O3 Mini)"]:::external
  end

  %% Database Cluster
  subgraph "Database"
    DBMain["PostgreSQL Database"]:::database
    DBSchema["DB Schema"]:::database
    DBInit["DB Init Script"]:::database
  end

  %% Deployment & CI/CD
  subgraph "Deployment & CI/CD"
    DC1["Dockerfile"]:::deployment
    DC2["Docker Compose"]:::deployment
    CI1["Deploy Script"]:::deployment
    CI2["GitHub Actions"]:::deployment
  end

  %% Connections - Frontend to Backend via Nginx
  FEApp -->|"sends_request"| Nginx
  FEComponents -->|"triggers_actions"| Nginx
  Nginx -->|"routes_requests"| BEApi

  %% Internal Backend Flow
  BEApi -->|"delegates_to"| BERouters
  BEApi -->|"processes_with"| BEPrompts
  BEPrompts -->|"calls"| ESClaude
  BEPrompts -->|"calls"| ESGithub
  BEPrompts -->|"calls"| ESO1
  BEPrompts -->|"calls"| ESO3
  BEPrompts -->|"calls"| ESO3Router
  BEApi -->|"stores_data"| DBMain

  %% Database Initialization connections
  DBMain -->|"initialized_by"| DBSchema
  DBMain -->|"initialized_by"| DBInit

  %% Deployment & CI/CD Connections
  DC1 -->|"deploys"| BEApi
  DC2 -->|"deploys"| BEApi
  DC1 -->|"deploys"| DBMain
  DC2 -->|"deploys"| DBMain
  CI1 -->|"automates_deploy"| BEApi
  CI2 -->|"automates_deploy"| BEApi

  %% Click Events
  click FEApp "https://github.com/sekhar08/gitdiagram/tree/main/src/"
  click FEComponents "https://github.com/sekhar08/gitdiagram/tree/main/src/app/_actions"
  click FEComponents "https://github.com/sekhar08/gitdiagram/tree/main/src/components"
  click BEApi "https://github.com/sekhar08/gitdiagram/tree/main/backend/app/"
  click BERouters "https://github.com/sekhar08/gitdiagram/tree/main/backend/app/routers"
  click BEPrompts "https://github.com/sekhar08/gitdiagram/blob/main/backend/app/prompts.py"
  click ESClaude "https://github.com/sekhar08/gitdiagram/blob/main/backend/app/services/claude_service.py"
  click ESGithub "https://github.com/sekhar08/gitdiagram/blob/main/backend/app/services/github_service.py"
  click ESO1 "https://github.com/sekhar08/gitdiagram/blob/main/backend/app/services/o1_mini_openai_service.py"
  click ESO3 "https://github.com/sekhar08/gitdiagram/blob/main/backend/app/services/o3_mini_openai_service.py"
  click ESO3Router "https://github.com/sekhar08/gitdiagram/blob/main/backend/app/services/o3_mini_openrouter_service.py"
  click Nginx "https://github.com/sekhar08/gitdiagram/tree/main/backend/nginx"
  click DBSchema "https://github.com/sekhar08/gitdiagram/tree/main/src/server/db"
  click DBInit "https://github.com/sekhar08/gitdiagram/blob/main/start-database.sh"
  click DC1 "https://github.com/sekhar08/gitdiagram/tree/main/backend/Dockerfile"
  click DC2 "https://github.com/sekhar08/gitdiagram/blob/main/docker-compose.yml"
  click CI1 "https://github.com/sekhar08/gitdiagram/blob/main/backend/deploy.sh"
  click CI2 "https://github.com/sekhar08/gitdiagram/blob/main/.github/workflows/deploy.yml"

  %% Styles
  classDef frontend fill:#FDE68A,stroke:#B45309,stroke-width:2px;
  classDef backend fill:#BFDBFE,stroke:#1D4ED8,stroke-width:2px;
  classDef external fill:#FBCFE8,stroke:#9D174D,stroke-width:2px;
  classDef database fill:#C7F0BD,stroke:#166534,stroke-width:2px,stroke-dasharray: 5 5;
  classDef deployment fill:#FCD34D,stroke:#92400E,stroke-width:2px;
```
