# joshik27/automation architecture

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

- Interactive diagram: https://gitdiagram.com/joshik27/automation
- Repository: https://github.com/joshik27/automation

## Overview

##### Main Components

a) Client Layer:
- Next.js Frontend (React)
- Key frontend features:
- Visual Workflow Builder (using XY Flow)
- Authentication UI (NextAuth.js)
- Payment Integration (Stripe)
- Redux Store for state management

b) API Layer:
- FastAPI Backend
- NextAuth API Routes
- Stripe API Integration

c) Processing Layer:
- Celery Workers
- Redis Queue

d) Data Layer:
- PostgreSQL Database
- Redis Cache

**[Client Layer]**
- ↓ ↑
**[API Gateway Layer]**
- ↓ ↑
**[Processing Layer]**
- ↓ ↑
**[Data Layer]**

##### Component Details

Frontend Components (Top):
- Core Features Module (workflow builder, history)
- User Module (profile, authentication)
- Payment Module (checkout, success/cancel flows)
- State Management (Redux store)

API Gateway (Middle-Top):
- FastAPI endpoints:
- User Management (/api/endpoints/users)
- Workflow Management (/api/endpoints/workflows)
- Webhook Handling (/api/endpoints/webhooks)
- Core Features (/api/endpoints/corefeatures)

Processing Layer (Middle-Bottom):
- Celery Workers for:
- AI Tasks (captions, thumbnails, summaries)
- Face Swap Operations
- Background Processing

Data Layer (Bottom):
- PostgreSQL Tables:
- Users
- Workflows
- Task Status
- Redis:
- Session Storage
- Task Queue
- Caching

##### Additional Elements

Supporting components:
- Load balancers (if applicable)
- CDN for static assets
- External AI service connections
- Stripe payment flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef frontend fill:#3498db,color:white
    classDef api fill:#2ecc71,color:white
    classDef processing fill:#e67e22,color:white
    classDef data fill:#9b59b6,color:white
    classDef external fill:#e74c3c,color:white

    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        VWB["Visual Workflow Builder"]:::frontend
        Auth["Authentication UI"]:::frontend
        Payment["Payment Integration"]:::frontend
        Redux["Redux Store"]:::frontend
        Profile["User Profile"]:::frontend
        History["Workflow History"]:::frontend
        
        subgraph AIComponents["AI Task Components"]
            Captions["Captions Generator"]:::frontend
            Summaries["Summaries Generator"]:::frontend
            Thumbnails["Thumbnails Generator"]:::frontend
            FaceSwap["Face Swap"]:::frontend
        end
    end

    %% API Gateway Layer
    subgraph APILayer["API Gateway Layer"]
        FastAPI["FastAPI Backend"]:::api
        NextAuthAPI["NextAuth API"]:::api
        StripeAPI["Stripe API"]:::api
        
        subgraph Endpoints["API Endpoints"]
            UserAPI["User Management API"]:::api
            WorkflowAPI["Workflow Management API"]:::api
            WebhookAPI["Webhook Handling"]:::api
            CoreAPI["Core Features API"]:::api
        end
    end

    %% Processing Layer
    subgraph ProcessingLayer["Processing Layer"]
        CeleryWorkers["Celery Workers"]:::processing
        TaskQueue["Redis Queue"]:::processing
    end

    %% Data Layer
    subgraph DataLayer["Data Layer"]
        PostgreSQL[("PostgreSQL DB")]:::data
        RedisCache[("Redis Cache")]:::data
    end

    %% External Services
    StripeService["Stripe Service"]:::external

    %% Connections
    ClientLayer --> APILayer
    APILayer --> ProcessingLayer
    ProcessingLayer --> DataLayer
    
    FastAPI --> PostgreSQL
    CeleryWorkers --> RedisCache
    Payment --> StripeAPI
    StripeAPI --> StripeService

    %% Click Events
    click VWB "https://github.com/JOSHIK27/automation/blob/main/frontend/src/app/(core-features)/build-workflow/page.tsx"
    click Redux "https://github.com/JOSHIK27/automation/blob/main/frontend/src/app/store/store.ts"
    click Payment "https://github.com/JOSHIK27/automation/blob/main/frontend/src/app/(payments)/checkout/page.tsx"
    click Auth "https://github.com/JOSHIK27/automation/blob/main/frontend/src/app/api/[...nextauth]/route.ts"
    click FastAPI "https://github.com/JOSHIK27/automation/blob/main/backend/main.py"
    click CeleryWorkers "https://github.com/JOSHIK27/automation/blob/main/backend/api/endpoints/celery/celery.py"
    click PostgreSQL "https://github.com/JOSHIK27/automation/blob/main/backend/db/db.py"
    click UserAPI "https://github.com/JOSHIK27/automation/blob/main/backend/api/endpoints/users/users.py"
    click WorkflowAPI "https://github.com/JOSHIK27/automation/blob/main/backend/api/endpoints/workflows/workflows.py"
    click WebhookAPI "https://github.com/JOSHIK27/automation/blob/main/backend/api/endpoints/webhooks/webhooks.py"
    click CoreAPI "https://github.com/JOSHIK27/automation/blob/main/backend/api/endpoints/corefeatures.py"
    click Captions "https://github.com/JOSHIK27/automation/blob/main/frontend/src/components/actionFormElementsUi/generate-captions.tsx"
    click Summaries "https://github.com/JOSHIK27/automation/blob/main/frontend/src/components/actionFormElementsUi/generate-summary.tsx"
    click Thumbnails "https://github.com/JOSHIK27/automation/blob/main/frontend/src/components/actionFormElementsUi/generate-thumbnail.tsx"
    click FaceSwap "https://github.com/JOSHIK27/automation/blob/main/frontend/src/components/actionFormElementsUi/swap-face.tsx"
    click History "https://github.com/JOSHIK27/automation/blob/main/frontend/src/app/(core-features)/workflow-history/page.tsx"
    click StripeAPI "https://github.com/JOSHIK27/automation/blob/main/frontend/src/app/api/create-checkout-session/route.ts"
    click Profile "https://github.com/JOSHIK27/automation/blob/main/frontend/src/app/(user)/profile/page.tsx"
```
