# sonali2109/capital architecture

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

- Interactive diagram: https://gitdiagram.com/sonali2109/capital
- Repository: https://github.com/sonali2109/capital

## Overview

##### Project type and purpose
- This is a full-stack, monorepo-based event ticketing platform (“Capital”).
- Frontend: Next.js (apps/web) delivering pages/routes and UI components.
- Backend: Node HTTP service (apps/http) exposing RESTful endpoints.
- Shared packages: database layer, cache, notification service, types, UI primitives, lint/TS configs.
- Infrastructure: Docker-Compose for orchestrating HTTP, Web, Postgres, Redis, etc.

##### File structure
- Top-level “apps/” folder splits into:
- apps/http – the standalone Node service (src/app.ts, routes/*.ts, server.ts)
- apps/web – Next.js app leveraging app/ router, client/server components, API routes
- “packages/” contains discrete libraries:
- packages/db – Prisma schema, migrations, seed scripts
- packages/cache – Redis caching wrappers
- packages/notifications – email templating & dispatch
- packages/types – shared TypeScript interfaces
- packages/ui – design system primitives for React
- lint/config tooling
- Dev tooling: turbo.json (monorepo task runner), Dockerfiles, docker-compose.yml

##### README for additional insights
- Purpose: Secure, cryptographically tamper-proof tickets, account-bound, real-time validation

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Infrastructure Layer
    subgraph "Infrastructure (Docker Compose)" 
        direction TB
        DC["docker-compose.yml"]:::infra
        DFWeb["Dockerfile.web"]:::infra
        DFHttp["Dockerfile.http"]:::infra
    end

    %% Monorepo Code
    subgraph "Monorepo Code"
        direction TB

        %% Client Tier
        subgraph "Client Tier" 
            direction TB
            NextJS["Next.js Frontend"]:::frontend
            Pages["Pages & Routes"]:::frontend
            UIComp["UI Components"]:::frontend
            Hooks["Hooks & Utilities"]:::frontend
            Primitives["UI Primitives (packages/ui)"]:::frontend
            TypesSP["Shared Types (packages/types)"]:::integration
            NextJS -->|"uses"| Pages
            NextJS -->|"uses"| UIComp
            NextJS -->|"uses"| Hooks
            NextJS -->|"imports"| Primitives
            NextJS -->|"imports"| TypesSP
        end

        %% API Tier
        subgraph "API Tier"
            direction TB
            HTTPService["HTTP Service"]:::backend
            Routes["Route Handlers"]:::backend
            ServerBoot["Server Bootstrap"]:::backend
            HTTPService -->|"contains"| Routes
            HTTPService -->|"bootstrapped by"| ServerBoot
            HTTPService -->|"imports"| TypesSP
        end

        %% Data & Integration Tier
        subgraph "Data & Integration Tier"
            direction TB
            DB["Database Layer (packages/db)"]:::data
            Cache["Cache Layer (packages/cache)"]:::data
            Notifications["Notification Service"]:::integration
            HTTPService -->|"Prisma queries"| DB
            HTTPService -->|"Cache read/write"| Cache
            HTTPService -->|"enqueue emails"| Notifications
        end

        %% Shared Configs
        Turbo["turbo.json"]:::config
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Postgres[(PostgreSQL)]:::data
        Redis[(Redis)]:::data
        SMTP[(SMTP Provider)]:::external
        DB -->|"connects to"| Postgres
        Cache -->|"connects to"| Redis
        Notifications -->|"sends via"| SMTP
    end

    %% Client to API
    NextJS -->|"REST calls (fetch/axios)"| HTTPService

    %% Orchestration Links
    DC --> NextJS
    DC --> HTTPService
    DC --> Postgres
    DC --> Redis
    DC --> SMTP
    Turbo --- DC

    %% Click Events
    click NextJS "https://github.com/sonali2109/capital/tree/main/apps/web"
    click Pages "https://github.com/sonali2109/capital/tree/main/apps/web/app"
    click UIComp "https://github.com/sonali2109/capital/tree/main/apps/web/components/custom"
    click Hooks "https://github.com/sonali2109/capital/tree/main/apps/web/hooks"
    click Hooks "https://github.com/sonali2109/capital/tree/main/apps/web/lib"
    click Primitives "https://github.com/sonali2109/capital/tree/main/packages/ui"
    click TypesSP "https://github.com/sonali2109/capital/tree/main/packages/types"
    click HTTPService "https://github.com/sonali2109/capital/tree/main/apps/http"
    click Routes "https://github.com/sonali2109/capital/tree/main/apps/http/src/routes"
    click ServerBoot "https://github.com/sonali2109/capital/blob/main/apps/http/src/app.ts"
    click ServerBoot "https://github.com/sonali2109/capital/blob/main/apps/http/src/server.ts"
    click DB "https://github.com/sonali2109/capital/tree/main/packages/db"
    click Cache "https://github.com/sonali2109/capital/tree/main/packages/cache"
    click Notifications "https://github.com/sonali2109/capital/tree/main/packages/notifications"
    click Turbo "https://github.com/sonali2109/capital/blob/main/turbo.json"
    click DC "https://github.com/sonali2109/capital/blob/main/docker-compose.yml"
    click DFWeb "https://github.com/sonali2109/capital/blob/main/docker/Dockerfile.web"
    click DFHttp "https://github.com/sonali2109/capital/blob/main/docker/Dockerfile.http"

    %% Styles
    classDef frontend fill:#cfe2ff,stroke:#0366d6,stroke-width:1px
    classDef backend fill:#d4edda,stroke:#22863a,stroke-width:1px
    classDef data fill:#fff3cd,stroke:#bf8700,stroke-width:1px
    classDef integration fill:#e2e3e5,stroke:#6a737d,stroke-width:1px
    classDef external fill:#f0f6fc,stroke:#57606a,stroke-width:1px
    classDef infra fill:#f8f9fa,stroke:#444c56,stroke-width:1px
    classDef config fill:#fdecea,stroke:#cb2431,stroke-width:1px
```
