# uoawdcc/uabc-portal architecture

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

- Interactive diagram: https://gitdiagram.com/uoawdcc/uabc-portal
- Repository: https://github.com/uoawdcc/uabc-portal

## Overview

##### Main Components
- Frontend Component:
- Next.js “app” layer found in src/app. Break this into sub-components such as authentication pages, booking flows, session selection, onboarding, and the admin interface.
- UI components from src/components (including specialized sub-directories like auth, admin, booking, payment, and UI primitives).
- That Storybook stories (in .storybook and src/stories) support component development.

- Backend API:
- That these endpoints use Next.js server routes and are responsible for business logic, handling registration, session generation, payments, and email confirmation.

- Database and Data Layer:
- Database interaction layer: files under src/lib/db (schema, relations, seed, and index) and configuration files (drizzle.config.ts). This suggests use of an ORM-like tool (Drizzle) for managing database interactions.

- Background Tasks / Cron Jobs:
- A block for scheduled tasks found in the “cron” directory and the API’s “cron” endpoints. These are likely used to generate sessions and trigger time-based events.

- External Services and Email Integration:
- An external email service component given the email templates in src/emails (for confirmations, forgot password, member onboarding, etc.).
- Potential payment integrations using components found in src/components/payment and services in src/services.

- Testing & CI/CD Pipeline:
- Testing frameworks like Jest and Playwright (located within src/tests and playwright directories). Although these aren’t part of the production runtime, they are critical to quality assurance.

##### Relationships and Interactions
- Clear connections between the Frontend and the Backend API via HTTP REST endpoints.
- How Authentication flows occur through the API (using NextAuth in src/app/api/auth).
- Cron Jobs periodically triggering API endpoints that perform scheduled actions.
- Testing pipelines and deployment processes as parts of the overall system lifecycle.

##### Architectural Patterns & Design Principles
- RESTful Service Design: The API routes are organized into resource-based endpoints (e.g., auth, users, bookings, schedules).
- Modular Component Design: Both UI components and functional modules (services, hooks, utilities) are organized in a modular directory structure.
- Infrastructure as Code: Represent CI/CD (GitHub workflows, Docker, and Fly.io configurations) that supports automated testing and deployment.

##### Technologies and Tools
- Next.js and React (pages in src/app and components in src/components).
- Typescript for type safety (as seen from tsconfig.json and .ts files throughout the project).
- Drizzle ORM (indicated by drizzle.config.ts and the database schema & seed scripts).
- Testing tools: Jest, Playwright, and Storybook.
- Tailwind CSS for styling (tailwind.config.ts and postcss.config.js).
- GitHub Actions for CI/CD (under .github/workflows) and Docker/Fly.io for containerization and deployment.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        UI_Pages["Frontend UI - Next.js Pages"]
        UI_Components["Frontend Components - UI Elements"]
    end

    %% Backend Layer
    subgraph "Backend Layer"
        Backend_API["Backend API Endpoints"]
    end

    %% Data Layer
    subgraph "Data Layer"
        DB_Layer["Database Layer - Drizzle ORM"]
    end

    %% Background Tasks
    subgraph "Background Tasks"
        Cron_Dir["Cron Jobs (Directory)"]
        Cron_API["Cron Endpoints (API)"]
    end

    %% External Integrations
    subgraph "External Integrations"
        Email_Service["Email Service Integration"]
        Payment_Integration["Payment Integration"]
    end

    %% Testing & CI/CD
    subgraph "Testing & CI/CD"
        Testing_Jest["Testing Suite - Jest"]
        Testing_Playwright["Testing Suite - Playwright"]
        CI_CD["CI/CD Pipeline - GitHub Actions"]
        Containerization["Containerization - Docker"]
        Deployment_Prod["Deployment - Fly.io Production"]
        Deployment_Staging["Deployment - Fly.io Staging"]
    end

    %% Relationships
    UI_Pages -->|"HTTPcalls"| Backend_API
    UI_Components -->|"UIinteract"| Backend_API
    Backend_API -->|"CRUDops"| DB_Layer
    Backend_API -->|"Notifies"| Email_Service
    Backend_API -->|"PaymentReq"| Payment_Integration
    Cron_Dir -->|"Triggers"| Cron_API
    Cron_API -->|"Calls"| Backend_API
    Testing_Jest -->|"Tests"| CI_CD
    Testing_Playwright -->|"Tests"| CI_CD
    CI_CD -->|"BuildDeploy"| Containerization
    Containerization -->|"DeploysTo"| Deployment_Prod
    Containerization -->|"DeploysTo"| Deployment_Staging

    %% Click Events for Component Mapping
    click UI_Pages "https://github.com/uoawdcc/uabc-portal/tree/main/src/app"
    click UI_Components "https://github.com/uoawdcc/uabc-portal/tree/main/src/components"
    click Backend_API "https://github.com/uoawdcc/uabc-portal/tree/main/src/app/api"
    click DB_Layer "https://github.com/uoawdcc/uabc-portal/tree/main/src/lib/db"
    click Cron_Dir "https://github.com/uoawdcc/uabc-portal/tree/main/cron"
    click Cron_API "https://github.com/uoawdcc/uabc-portal/tree/main/src/app/api/cron"
    click Email_Service "https://github.com/uoawdcc/uabc-portal/tree/main/src/emails"
    click Payment_Integration "https://github.com/uoawdcc/uabc-portal/tree/main/src/components/payment"
    click Testing_Jest "https://github.com/uoawdcc/uabc-portal/tree/main/src/tests"
    click Testing_Playwright "https://github.com/uoawdcc/uabc-portal/tree/main/playwright"
    click CI_CD "https://github.com/uoawdcc/uabc-portal/tree/main/.github/workflows"
    click Containerization "https://github.com/uoawdcc/uabc-portal/tree/main/Dockerfile"
    click Deployment_Prod "https://github.com/uoawdcc/uabc-portal/blob/main/fly.production.toml"
    click Deployment_Staging "https://github.com/uoawdcc/uabc-portal/blob/main/fly.staging.toml"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:1px,color:#000;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:1px,color:#000;
    classDef data fill:#dda0dd,stroke:#000,stroke-width:1px,color:#000;
    classDef cron fill:#ffcc99,stroke:#000,stroke-width:1px,color:#000;
    classDef external fill:#ffff99,stroke:#000,stroke-width:1px,color:#000;
    classDef testing fill:#d3d3d3,stroke:#000,stroke-width:1px,color:#000;
    classDef cicd fill:#f4a460,stroke:#000,stroke-width:1px,color:#000;

    class UI_Pages,UI_Components frontend;
    class Backend_API backend;
    class DB_Layer data;
    class Cron_Dir,Cron_API cron;
    class Email_Service,Payment_Integration external;
    class Testing_Jest,Testing_Playwright testing;
    class CI_CD,Containerization,Deployment_Prod,Deployment_Staging cicd;
```
