# ajayjainn/flashdeploy architecture

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

- Interactive diagram: https://gitdiagram.com/ajayjainn/flashdeploy
- Repository: https://github.com/ajayjainn/flashdeploy

## Overview

##### Project type and purpose
- FlashDeploy is a full-stack deployment platform modeled after Vercel: it provides one-click React/Vite app deployments to AWS ECS for containerized builds, static hosting on S3, and custom subdomain routing via reverse proxy and Cloudflare DNS.

##### File structure
- Top-level directories:
- container – Dockerfile and script.js for ECS build container
- frontend – React/Vite app (TSX, Tailwind, UI components)
- server – Node.js/Express API (routes, middlewares, models, utils)
- Build scripts & configs: Dockerfile in container/, package.json in each subfolder, Vite/Tailwind configs in frontend/, .gitignore, and root README.
- server/dist holds the built static server for reverse proxying.

##### README insights
- Architecture already described: OAuth2 login in frontend → triggers backend → spawns ECS container → git clone, npm build → upload to S3 → reverse proxy maps subdomain → serves static.

##### Detail without over-fragmentation
- Distinct module: e.g., within Backend, show Auth Middleware, Routes (projects, aws, repository).
- Utility layers: JWT util, GitHub API util.
- Container’s internal steps (git clone → npm install → build → upload).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["Browser"]:::client
        GitHubOAuth["GitHub OAuth2"]:::external
    end

    %% Frontend Layer
    subgraph "Frontend (React + Vite + Tailwind)"
        ReactApp["React App"]:::frontend
        APIUtil["API Utilities"]:::frontend
        Pages["Routing & Pages"]:::frontend
        UIComponents["UI Components"]:::frontend
        AuthCallback["OAuth Callback Page"]:::frontend
    end

    %% Backend API Layer
    subgraph "Backend API (Node.js + Express)"
        ExpressAPI["Express API"]:::backend
        AuthRoutes["Auth Routes"]:::backend
        ProjectRoutes["Project Management Routes"]:::backend
        AWSRoutes["AWS Control Routes"]:::backend
        RepoRoutes["Repository Routes"]:::backend
        AuthMiddleware["Auth Middleware"]:::backend
        UserModel["User Model"]:::backend
        ProjectModel["Project Model"]:::backend
        GitHubUtil["GitHub API Utility"]:::backend
        JWTUtil["JWT Utility"]:::backend
        StaticServer["Prebuilt Static Server"]:::backend
    end

    %% Build Container Image
    subgraph "Build Container Image"
        Dockerfile["Dockerfile"]:::container
        Script["build script.js"]:::container
        Dependencies["package.json"]:::container
    end

    %% Container Task Internal Steps
    subgraph "ECS Task Steps"
        Clone["git clone"]:::container
        Install["npm install"]:::container
        BuildStep["npm run build"]:::container
        Upload["upload to S3"]:::container
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        ECS["AWS ECS Fargate"]:::infra
        S3["Amazon S3 Bucket"]:::data
        Proxy["Reverse Proxy"]:::infra
        DNS["Cloudflare DNS"]:::infra
    end

    %% Connections - Presentation to Frontend
    Browser -->|"loads"| ReactApp
    ReactApp -->|"redirect for OAuth"| GitHubOAuth
    GitHubOAuth -->|"callback"| AuthRoutes

    %% Frontend internal flows
    ReactApp -->|"calls API"| ExpressAPI
    ReactApp -->|uses| APIUtil
    ReactApp -->|navigates| Pages
    ReactApp -->|renders| UIComponents
    ReactApp -->|handles OAuth callback| AuthCallback

    %% Backend internal structure
    ExpressAPI --> AuthRoutes
    ExpressAPI --> ProjectRoutes
    ExpressAPI --> AWSRoutes
    ExpressAPI --> RepoRoutes
    AuthRoutes --> AuthMiddleware
    ProjectRoutes --> AuthMiddleware
    AWSRoutes --> AuthMiddleware
    RepoRoutes --> AuthMiddleware
    AuthRoutes --> JWTUtil
    ProjectRoutes --> UserModel
    ProjectRoutes --> ProjectModel
    AuthRoutes --> GitHubUtil
    AWSRoutes --> GitHubUtil
    ExpressAPI --> StaticServer

    %% API triggers build
    ExpressAPI -->|asynchronous trigger| ECS
    ECS -->|runs container| Dockerfile
    Dockerfile --> Dependencies
    Dockerfile --> Script
    Script --> Clone
    Clone --> Install
    Install --> BuildStep
    BuildStep --> Upload
    Upload --> S3

    %% Infrastructure serving
    Browser -->|"visit slug.domain"| DNS
    DNS --> Proxy
    Proxy -->|"serves assets"| S3

    %% Click Events
    click ReactApp "https://github.com/ajayjainn/flashdeploy/tree/main/frontend/"
    click ReactApp "https://github.com/ajayjainn/flashdeploy/blob/main/frontend/src/main.tsx"
    click Pages "https://github.com/ajayjainn/flashdeploy/tree/main/frontend/src/pages/"
    click UIComponents "https://github.com/ajayjainn/flashdeploy/tree/main/frontend/src/components/"
    click UIComponents "https://github.com/ajayjainn/flashdeploy/tree/main/frontend/src/components/ui/"
    click APIUtil "https://github.com/ajayjainn/flashdeploy/blob/main/frontend/src/lib/api.ts"
    click AuthCallback "https://github.com/ajayjainn/flashdeploy/blob/main/frontend/src/pages/AuthCallback.tsx"
    click ExpressAPI "https://github.com/ajayjainn/flashdeploy/blob/main/server/index.js"
    click AuthRoutes "https://github.com/ajayjainn/flashdeploy/blob/main/server/routes/auth.js"
    click ProjectRoutes "https://github.com/ajayjainn/flashdeploy/blob/main/server/routes/projects.js"
    click AWSRoutes "https://github.com/ajayjainn/flashdeploy/blob/main/server/routes/aws.js"
    click RepoRoutes "https://github.com/ajayjainn/flashdeploy/blob/main/server/routes/repository.js"
    click AuthMiddleware "https://github.com/ajayjainn/flashdeploy/blob/main/server/middlewares/auth.js"
    click UserModel "https://github.com/ajayjainn/flashdeploy/blob/main/server/models/User.js"
    click ProjectModel "https://github.com/ajayjainn/flashdeploy/blob/main/server/models/Project.js"
    click GitHubUtil "https://github.com/ajayjainn/flashdeploy/blob/main/server/utils/githubApi.js"
    click JWTUtil "https://github.com/ajayjainn/flashdeploy/blob/main/server/utils/jwt.js"
    click Dockerfile "https://github.com/ajayjainn/flashdeploy/tree/main/container/Dockerfile"
    click Script "https://github.com/ajayjainn/flashdeploy/blob/main/container/script.js"
    click Dependencies "https://github.com/ajayjainn/flashdeploy/blob/main/container/package.json"
    click StaticServer "https://github.com/ajayjainn/flashdeploy/tree/main/server/dist/"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#0366D6,color:#024E90;
    classDef external fill:#FFE4B5,stroke:#D2691E,color:#8B4513;
    classDef frontend fill:#E6FFFA,stroke:#2C7A7B,color:#234E52;
    classDef backend fill:#EDF2F7,stroke:#4A5568,color:#2D3748;
    classDef container fill:#F7FAFC,stroke:#A0AEC0,color:#718096;
    classDef infra fill:#FEFCBF,stroke:#D69E2E,color:#975A16;
    classDef data fill:#EBF8FF,stroke:#4299E1,color:#2B6CB0;
```
