# daggieblanqx/gitdiagram architecture

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

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

## Overview

##### Main Components

a) Client-Side (Frontend):
- Next.js Application Layer
- Pages and Routes (src/app directory)
- Components (src/components)
- Server Actions (src/app/_actions)
- Database Integration (src/server/db)

b) Server-Side (Backend):
- FastAPI Application
- Core Services
- API Routers
- Rate Limiter
- Nginx Reverse Proxy

c) External Services:
- Claude 3.5 Sonnet AI
- GitHub API
- PostgreSQL Database
- Analytics Services (PostHog, Api-Analytics)

**[Client Layer]**
- ↕️
**[API/Backend Layer]**
- ↕️
**[External Services Layer]**

##### Specific Component Relationships

a) Frontend Flow:
- How the Next.js pages (src/app) interact with components
- Server actions connecting to the backend
- Demonstrate database interactions through Drizzle ORM

b) Backend Flow:
- FastAPI routes (/generate and /modify)
- Rate limiting middleware
- Service integrations (Claude and GitHub)

##### Key Elements to Highlight

- Authentication flow for GitHub integration
- Rate limiting mechanism
- AI processing pipeline
- Database operations
- Caching mechanisms

##### Deployment Architecture

- Vercel (Frontend hosting)
- EC2 (Backend hosting)
- PostgreSQL database connection
- Nginx configuration

##### Important Details

- CI/CD pipeline with GitHub Actions
- Environment configuration flow
- Error handling pathways
- Security measures and rate limiting
- Data flow between components

## Diagram (Mermaid)

```mermaid
graph TD
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef database fill:#e67e22,stroke:#d35400,color:white
    classDef infrastructure fill:#95a5a6,stroke:#7f8c8d,color:white

    subgraph ClientLayer[Client Layer]
        NextPages["Next.js Pages"]
        UIComponents["UI Components"]
        CoreComponents["Core Components"]
        ServerActions["Server Actions"]
        DbClient["Database Client"]
    end

    subgraph BackendLayer[Backend Layer]
        FastAPI["FastAPI Server"]
        RateLimiter["Rate Limiter"]
        APIRouters["API Routers"]
        Services["Services"]
        NginxProxy["Nginx Reverse Proxy"]
    end

    subgraph ExternalLayer[External Services]
        Claude["Claude 3.5 Sonnet"]
        GitHub["GitHub API"]
        PostgreSQL["PostgreSQL"]
        Analytics["PostHog/Api-Analytics"]
    end

    %% Relationships
    NextPages --> UIComponents
    NextPages --> CoreComponents
    UIComponents --> ServerActions
    CoreComponents --> ServerActions
    ServerActions --> DbClient
    ServerActions --> FastAPI
    
    FastAPI --> RateLimiter
    RateLimiter --> APIRouters
    APIRouters --> Services
    NginxProxy --> FastAPI
    
    Services --> Claude
    Services --> GitHub
    DbClient --> PostgreSQL
    Services --> Analytics

    %% Click Events
    click NextPages "https://github.com/DaggieBlanqx/gitdiagram/blob/main/src/app/[username]/[repo]/page.tsx"
    click UIComponents "https://github.com/DaggieBlanqx/gitdiagram/tree/main/src/components/ui/"
    click CoreComponents "https://github.com/DaggieBlanqx/gitdiagram/blob/main/src/components/mermaid-diagram.tsx"
    click ServerActions "https://github.com/DaggieBlanqx/gitdiagram/tree/main/src/app/_actions/"
    click DbClient "https://github.com/DaggieBlanqx/gitdiagram/tree/main/src/server/db/"
    click FastAPI "https://github.com/DaggieBlanqx/gitdiagram/blob/main/backend/app/main.py"
    click RateLimiter "https://github.com/DaggieBlanqx/gitdiagram/blob/main/backend/app/core/limiter.py"
    click APIRouters "https://github.com/DaggieBlanqx/gitdiagram/tree/main/backend/app/routers/"
    click Services "https://github.com/DaggieBlanqx/gitdiagram/tree/main/backend/app/services/"
    click NginxProxy "https://github.com/DaggieBlanqx/gitdiagram/tree/main/backend/nginx/"

    %% Style Applications
    class NextPages,UIComponents,CoreComponents,ServerActions,DbClient frontend
    class FastAPI,RateLimiter,APIRouters,Services,NginxProxy backend
    class Claude,GitHub,Analytics external
    class PostgreSQL database
```
