# reckseba/2a5-app architecture

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

- Interactive diagram: https://gitdiagram.com/reckseba/2a5-app
- Repository: https://github.com/reckseba/2a5-app

## Overview

##### Main System Components

a) Frontend Layer (Next.js Application)
- Client-side components (components directory)
- Pages and routing (pages directory)
- API routes (pages/api directory)

b) Backend Services
- 2a5-api (external service running on port 3000)
- Database (2a5-db running on port 5432)

##### Architectural Representation

a) Client Layer
- Sub-containers for:
- Pages (Home, 404, Dynamic URL route)
- React Components (Form, Header, Footer, etc.)
- Client-side utilities (lib directory)

b) API Layer
- Connection to external 2a5-api service

c) Database Layer
- PostgreSQL database (2a5-db)

##### Component Relationships

- Client-to-API interactions
- API-to-Database flows
- Component dependencies

##### Infrastructure Elements

Containers showing:
- Docker environment
- Development server setup
- Network configuration (2a5 network)

##### Specific Implementation Details

- Next.js hybrid rendering approach
- API route implementation
- Docker containerization
- Hot reload capability

##### Technical Stack Indicators

- Next.js
- TypeScript
- Docker
- PostgreSQL
- TailwindCSS

Example Layout:

**[Client Browser] ←→ [Next.js Frontend (3001)]**
- ↓
- [Components]
- ↓
- [API Routes]
- ↓
- [2a5-api (3000)]
- ↓
- [PostgreSQL DB (5432)]

##### Development Flow

A separate section showing:
- Local development setup
- Docker compose workflow
- Hot reload mechanism

Remember to:
- Use consistent styling
- Version/environment indicators
- Document all external service dependencies

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph "Next.js Frontend"
        Pages["Pages Layer"]
        Components["Components Layer"]
        Utils["Utility Layer"]
        APIRoutes["API Routes"]
        
        subgraph "Page Components"
            MainPage["Home Page"]:::page
            DynamicRoute["Dynamic URL Route"]:::page
            NotFound["404 Page"]:::page
            AppConfig["App Config"]:::page
            DocConfig["Document Config"]:::page
        end
        
        subgraph "UI Components"
            Form["Form"]:::component
            Header["Header"]:::component
            Footer["Footer"]:::component
            CopyBtn["Copy Button"]:::component
            Wrapper["Wrapper"]:::component
        end
        
        subgraph "Utilities"
            URLUtils["URL Management"]:::util
            HostConfig["Hostname Config"]:::util
            MiscUtils["Misc Utilities"]:::util
        end
    end

    subgraph "Backend Services"
        API["2a5-api :3000"]:::backend
        DB[(PostgreSQL DB :5432)]:::database
    end

    subgraph "Infrastructure"
        Docker["Docker Environment"]:::infra
        ComposeConfig["Docker Compose"]:::infra
        CIConfig["CI/CD Workflows"]:::infra
    end

    Browser <--> Pages
    Pages --> Components
    Components --> Utils
    Pages --> APIRoutes
    APIRoutes --> API
    API --> DB

    %% Click Events
    click Components "https://github.com/reckseba/2a5-app/tree/main//components"
    click Form "https://github.com/reckseba/2a5-app/blob/main//components/Form.tsx"
    click Header "https://github.com/reckseba/2a5-app/blob/main//components/Header.tsx"
    click Footer "https://github.com/reckseba/2a5-app/blob/main//components/Footer.tsx"
    click CopyBtn "https://github.com/reckseba/2a5-app/blob/main//components/CopyButton.tsx"
    click Wrapper "https://github.com/reckseba/2a5-app/blob/main//components/Wrapper.tsx"
    
    click MainPage "https://github.com/reckseba/2a5-app/blob/main//pages/index.tsx"
    click DynamicRoute "https://github.com/reckseba/2a5-app/blob/main//pages/[urlShort].tsx"
    click NotFound "https://github.com/reckseba/2a5-app/blob/main//pages/404.tsx"
    click AppConfig "https://github.com/reckseba/2a5-app/blob/main//pages/_app.tsx"
    click DocConfig "https://github.com/reckseba/2a5-app/blob/main//pages/_document.tsx"
    
    click APIRoutes "https://github.com/reckseba/2a5-app/tree/main//pages/api"
    click URLUtils "https://github.com/reckseba/2a5-app/blob/main//lib/urls.ts"
    click HostConfig "https://github.com/reckseba/2a5-app/blob/main//lib/hostnames.ts"
    click MiscUtils "https://github.com/reckseba/2a5-app/blob/main//lib/misc.ts"
    
    click Docker "https://github.com/reckseba/2a5-app/tree/main//Dockerfile"
    click ComposeConfig "https://github.com/reckseba/2a5-app/blob/main//docker-compose.yml"
    click CIConfig "https://github.com/reckseba/2a5-app/tree/main//.github/workflows"

    classDef page fill:#e1f5fe,stroke:#01579b
    classDef component fill:#e8f5e9,stroke:#2e7d32
    classDef util fill:#fff3e0,stroke:#ff6f00
    classDef backend fill:#f3e5f5,stroke:#7b1fa2
    classDef database fill:#fce4ec,stroke:#c2185b
    classDef infra fill:#efebe9,stroke:#3e2723
```
