# miguelvalenzuela6/camaras-page architecture

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

- Interactive diagram: https://gitdiagram.com/miguelvalenzuela6/camaras-page
- Repository: https://github.com/miguelvalenzuela6/camaras-page

## Overview

##### Project Type and Purpose
- This is a Turborepo monorepo hosting:
- A Next.js public + admin **web** application (apps/web)
- A Node.js **background worker** (apps/backend-worker)
- A shared **API service** (packages/api)
- Supporting packages: **database** (Prisma), **auth**, **S3**, **UI library**, **TS configs**, etc.
- Purpose: public booking pages, user authentication, admin dashboards for coupons, packages, schedules; background tasks; persistent storage.

##### File Structure (Top-level Clusters)
- **apps/**
– web (Next.js frontend)
– backend-worker (Node worker)
- **packages/**
– api (Express-style HTTP service with domain modules)
– auth (shared auth logic & client)
– database (Prisma schema & migrations)
– s3 (file storage helpers)
– ui (shared React component library)
– typescript-config (shared tsconfigs)
- **Root configs**: turbo.json, .env.local.example, lint/build scripts.

##### README Insights
- Standard Turborepo starter, uses pnpm/turbo for builds, caching, parallel execution.
- All packages and apps are TypeScript.

##### Main Components & Their Relationships
a. **Frontend (apps/web)**
- Runs in browser (or Vercel); uses Next.js SSR.
- Imports from `@repo/ui` for components.
- Calls the **API service** over HTTPS for data (coupons, bookings, profiles, sessions).
- Uses Shared **auth** logic for login/registration flows.
b. **API service (packages/api)**
- Hosts REST endpoints (coupons, orders, packages, users, sessions, photographers, profile, images).
- Uses **Prisma** client (packages/database) to interact with the relational database.
- Uses **auth** plugin for secure routes.
- Uses **S3** helpers to upload/image retrieve URLs.
c. **Background Worker (apps/backend-worker)**
- Runs scheduled / queued tasks (e.g., cleanup, notifications).
- Imports the same domain services from packages/api modules to reuse business logic.
- Reads/writes to DB (Prisma) and S3.
d. **Database**
- PostgreSQL (or similar), managed via Prisma migrations in `packages/database`.
e. **File Storage**
- AWS S3 (or compatible) used via `packages/s3`.
f. **Shared UI Library (packages/ui)**
g. **Authentication (packages/auth)**
- Contains JWT/session logic, permission enums.

##### Architectural Patterns & Principles
- **Monorepo** with Turborepo for incremental builds & caching.
- **Modular domain services** in `packages/api/src/modules` (one module per business area).
- **Shared libraries** (UI, auth, database, S3) to avoid duplication.
- **Clear separation**: frontend, HTTP API, background processing, data storage.

##### Key Elements to Label
- **Component names** (apps/web, packages/api, prisma DB, S3 bucket)
- **Data flows** (e.g., “GET /coupons → returns JSON”)
- **Dependencies** (web imports ui, auth; api imports database, s3)
- **Environments** (Dev, Prod) and **CI/CD** (Turbo remote cache, pipeline).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    Browser["User / Browser"]:::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        WebApp["Next.js Web App"]:::frontend
        UI["UI Library"]:::shared
        AuthLib["Auth Logic"]:::shared
        TSConfig["TS Config"]:::shared
    end

    %% Backend/API Layer
    subgraph "Backend/API Layer"
        API["API Service"]:::backend
    end

    %% Worker Layer
    subgraph "Worker Layer"
        Worker["Background Worker"]:::worker
    end

    %% Data Stores
    subgraph "Data Stores"
        DB["PostgreSQL via Prisma"]:::datastore
        S3["S3 Storage"]:::datastore
    end

    %% Connections
    Browser -->|"Interacts with UI"| WebApp
    WebApp -->|"GET/POST HTTP"| API
    WebApp -->|"imports components"| UI
    WebApp -->|"uses auth hooks"| AuthLib
    WebApp -->|"inherits TS settings"| TSConfig

    API -->|"Prisma client"| DB
    API -->|"upload/download"| S3
    API -->|"uses auth middleware"| AuthLib

    Worker -->|"reuses API modules"| API
    Worker -->|"Prisma client"| DB
    Worker -->|"upload/download"| S3

    %% Click Events
    click WebApp "https://github.com/miguelvalenzuela6/camaras-page/tree/main/apps/web"
    click Worker "https://github.com/miguelvalenzuela6/camaras-page/tree/main/apps/backend-worker"
    click API "https://github.com/miguelvalenzuela6/camaras-page/tree/main/packages/api"
    click DB "https://github.com/miguelvalenzuela6/camaras-page/tree/main/packages/database"
    click S3 "https://github.com/miguelvalenzuela6/camaras-page/tree/main/packages/s3"
    click AuthLib "https://github.com/miguelvalenzuela6/camaras-page/tree/main/packages/auth"
    click UI "https://github.com/miguelvalenzuela6/camaras-page/tree/main/packages/ui"
    click TSConfig "https://github.com/miguelvalenzuela6/camaras-page/tree/main/packages/typescript-config"

    %% Styles
    classDef frontend fill:#D0E4FD,stroke:#333,stroke-width:1px
    classDef backend fill:#D5ECD5,stroke:#333,stroke-width:1px
    classDef worker fill:#FFE5B4,stroke:#333,stroke-width:1px
    classDef datastore fill:#E0E0E0,stroke:#333,stroke-width:1px
    classDef shared fill:#FFF3B0,stroke:#333,stroke-width:1px
    classDef external fill:#E8DAEF,stroke:#333,stroke-width:1px
```
