# shubho0908/deployninja architecture

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

- Interactive diagram: https://gitdiagram.com/shubho0908/deployninja
- Repository: https://github.com/shubho0908/deployninja

## Overview

##### Main Components

A. Client-Side Layer:
- Next.js Frontend Application
- Redux State Management
- Authentication Flow (GitHub OAuth)

B. Server-Side Components:
- Next.js API Routes
- Build Server (Containerized)
- S3 Reverse Proxy

C. External Services:
- AWS Services (S3, ECR, ECS)
- Database Systems (PostgreSQL, ClickHouse)
- Message Broker (Apache Kafka)
- GitHub Integration

**┌─ Client Layer**
- API Layer
- Service Layer
- Data Layer
- External Services Layer

##### Component Relationships to Highlight

a) Frontend Flow:
- Next.js pages connecting to Redux store
- API call paths to backend services
- Authentication flow with GitHub

b) Backend Services:
- API routes organization (user, project, build)
- Build server workflow
- Demonstrate S3 reverse proxy handling
- Kafka message flow for build logs

##### Detailed Component Breakdown

a) Deployment App (Next.js):
- Frontend Components
- Pages (projects, deployments, login)
- Redux Store
- Authentication Handler

- API Routes
- User Management
- Project Management
- Deployment Operations
- GitHub Webhook Handler

b) Build Server:
- Docker Container
- Build Process
- S3 Artifact Upload
- Log Streaming

c) S3 Reverse Proxy:
- Request Handler
- S3 Integration
- Domain Management

##### Infrastructure Elements

AWS services configuration:
- ECS cluster for build server
- S3 bucket for artifacts
- ECR for container registry

##### The security and authentication flow

Remember to maintain a balance between detail and clarity, focusing on the architectural decisions that make this platform unique, such as the build pipeline, log streaming, and custom domain handling.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#f1c40f,stroke:#f39c12,color:black
    classDef database fill:#e74c3c,stroke:#c0392b,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef infra fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        NextApp["Next.js Frontend"]:::frontend
        Redux["Redux Store"]:::frontend
        AuthHandler["Auth Handler"]:::frontend
        UIComponents["UI Components"]:::frontend
    end
    click NextApp "https://github.com/shubho0908/DeployNinja/tree/main/deployment-app/src/app"
    click Redux "https://github.com/shubho0908/DeployNinja/tree/main/deployment-app/src/redux"
    click AuthHandler "https://github.com/shubho0908/DeployNinja/blob/main/deployment-app/src/app/api/auth/[...nextauth]/route.ts"
    click UIComponents "https://github.com/shubho0908/DeployNinja/tree/main/deployment-app/src/components/ui"

    %% API Layer
    subgraph APILayer["API Layer"]
        ProjectAPI["Project API"]:::api
        BuildAPI["Build API"]:::api
        UserAPI["User API"]:::api
        GithubWebhook["GitHub Webhook Handler"]:::api
    end
    click ProjectAPI "https://github.com/shubho0908/DeployNinja/tree/main/deployment-app/src/app/api/(project)"
    click BuildAPI "https://github.com/shubho0908/DeployNinja/tree/main/deployment-app/src/app/api/(build)"
    click UserAPI "https://github.com/shubho0908/DeployNinja/tree/main/deployment-app/src/app/api/(user)"
    click GithubWebhook "https://github.com/shubho0908/DeployNinja/blob/main/deployment-app/src/app/api/(build)/deploy/createGithubWebhook.ts"

    %% Service Layer
    subgraph ServiceLayer["Service Layer"]
        BuildServer["Build Server"]:::service
        S3Proxy["S3 Reverse Proxy"]:::service
        AWSIntegration["AWS Integration"]:::service
    end
    click BuildServer "https://github.com/shubho0908/DeployNinja/blob/main/build-server/server.js"
    click S3Proxy "https://github.com/shubho0908/DeployNinja/blob/main/s3-reverse-proxy/server.js"
    click AWSIntegration "https://github.com/shubho0908/DeployNinja/blob/main/deployment-app/src/lib/aws.ts"

    %% Data Layer
    subgraph DataLayer["Data Layer"]
        PostgreSQL["PostgreSQL"]:::database
        ClickHouse["ClickHouse"]:::database
        Kafka["Apache Kafka"]:::database
    end
    click PostgreSQL "https://github.com/shubho0908/DeployNinja/blob/main/deployment-app/src/lib/prisma.ts"
    click ClickHouse "https://github.com/shubho0908/DeployNinja/blob/main/deployment-app/src/lib/clickhouse.ts"

    %% External Services
    subgraph ExternalLayer["External Services"]
        GitHub["GitHub"]:::external
        S3["AWS S3"]:::external
        ECR["AWS ECR"]:::external
        ECS["AWS ECS"]:::external
    end

    %% Relationships
    NextApp --> Redux
    NextApp --> AuthHandler
    NextApp --> UIComponents
    AuthHandler --> GitHub
    
    NextApp --> ProjectAPI
    NextApp --> BuildAPI
    NextApp --> UserAPI
    
    ProjectAPI --> BuildServer
    ProjectAPI --> PostgreSQL
    ProjectAPI --> AWSIntegration
    
    BuildAPI --> BuildServer
    BuildAPI --> Kafka
    BuildServer --> ECR
    BuildServer --> ECS
    BuildServer --> S3
    
    S3Proxy --> S3
    
    Kafka --> ClickHouse
    
    GithubWebhook --> GitHub
    GitHub --> BuildServer
    
    AWSIntegration --> S3
    AWSIntegration --> ECR
    AWSIntegration --> ECS

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        APIComp["API Component"]:::api
        ServiceComp["Service Component"]:::service
        DBComp["Database Component"]:::database
        ExtComp["External Service"]:::external
    end
```
