# 16sulphur/higgs architecture

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

- Interactive diagram: https://gitdiagram.com/16sulphur/higgs
- Repository: https://github.com/16sulphur/higgs

## Overview

##### Project type and purpose
- This is a full-stack, multi-tenant booking and event management web application built on Next.js 13 (App Router).
- It provides two role-based front-ends: a “Members” dashboard for booking meeting rooms, events, tickets, support, etc., and an “Admin” dashboard for managing organizations, users, plans, room types, rooms, events, bookings, tickets, etc.
- It also exposes internal RESTful API routes (in app/api) and uses NextAuth for authentication, plus PWA features (service worker, workbox, install prompts).

##### File structure
- Top-level: package.json, next.config.ts, tsconfig.json, public assets, and globals.css.
- src/app: contains the entire UI and server-side code.
- app/(members)/dashboard: “Members” area with nested pages (book, find-room, events, profile, support, etc.).
- app/admin/dashboard: “Admin” area with nested pages for organizations, users, plans, rooms, room-types, events, bookings, tickets.
- app/api: Next.js serverless API routes under /auth, /login, /logout.
- app/login & app/admin/login: authentication pages.
- app/layout.tsx & middleware.ts: global layout, routing, and session enforcement.
- app/actions: client-side modules encapsulating API calls for each domain (bookingActions.ts, eventActions.ts, orgActions.ts, etc.).
- app/lib: shared utilities for auth, API client wrapper, session handling, date formatting, time-slot generation.
- app/components: UI components organized by domain (bookings, events, orgs, rooms, tickets, common, auth, admin, etc.).

##### README
- Confirms this is a Next.js project created with create-next-app.
- Deploys on Vercel by default (serverless or Edge Functions).

##### Capturing essential details
- Domain boundary (Auth, Booking, Events, Room Management, Ticketing, Organizations).
- PWA service worker and public asset flow.
- Middleware.ts enforcing session on protected routes.
- Where app/lib utilities are used by both pages and API handlers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client Side" 
        direction TB
        Browser["Browser (Client UI)"]:::client
        SW["Service Worker"]:::client
        WB["Workbox Script"]:::client
        Manifest["Web App Manifest"]:::client
        GlobalCSS["Global Stylesheet"]:::client
        MembersUI["Members Dashboard UI"]:::client
        AdminUI["Admin Dashboard UI"]:::client
        MemberAuthPage["Member Authentication Page"]:::client
        AdminAuthPage["Admin Authentication Page"]:::client
        RootPublic["Root Public Page"]:::client
    end

    %% Server Side
    subgraph "Server Side"
        direction TB
        NextServer["Next.js Server (App Router)"]:::server
        LayoutMiddleware["Global Layout & Routing Middleware"]:::server
        APIAuth["NextAuth API Route"]:::server
        APILogin["Login API Route"]:::server
        APILogout["Logout API Route"]:::server
        Actions["Business Logic Layer (Domain Actions)"]:::server
        Lib["Shared Utilities"]:::server
        ComponentsLib["UI Components Library"]:::server
    end

    %% Persistence & External
    subgraph "Persistence & External Services"
        direction TB
        DB["Database"]:::db
        EmailSvc["Email/SMS Service"]:::external
        CDN["CDN / Vercel Edge"]:::external
    end

    %% Connections
    Browser -->|"registers SW"| SW
    SW -->|"intercepts requests"| Browser
    Browser -->|"loads manifest"| Manifest
    Browser -->|"loads CSS"| GlobalCSS
    Browser -->|"navigates to UI"| MembersUI
    Browser -->|"navigates to UI"| AdminUI
    Browser -->|"visits auth"| MemberAuthPage
    Browser -->|"visits auth"| AdminAuthPage
    Browser -->|"visits home"| RootPublic

    MembersUI -->|"fetches data via actions"| NextServer
    AdminUI -->|"fetches data via actions"| NextServer
    MemberAuthPage -->|"posts credentials"| NextServer
    AdminAuthPage -->|"posts credentials"| NextServer
    RootPublic -->|"requests page render"| NextServer

    NextServer -->|"enforces session"| LayoutMiddleware
    NextServer -->|"routes api/auth"| APIAuth
    NextServer -->|"routes api/login"| APILogin
    NextServer -->|"routes api/logout"| APILogout
    APIAuth -->|"uses utils"| Lib
    APILogin -->|"uses actions"| Actions
    APILogout -->|"uses actions"| Actions

    NextServer -->|"renders pages using components"| ComponentsLib
    NextServer -->|"calls domain actions"| Actions
    Actions -->|"utilizes lib functions"| Lib
    Actions -->|"reads/writes"| DB

    EmailSvc -->|"sends notifications"| Actions
    CDN -->|"serves assets"| SW
    CDN -->|"serves assets"| WB

    %% Click Events
    click MembersUI "https://github.com/16sulphur/higgs/tree/master/src/app/(members)/dashboard"
    click AdminUI "https://github.com/16sulphur/higgs/tree/master/src/app/admin/dashboard"
    click MemberAuthPage "https://github.com/16sulphur/higgs/blob/master/src/app/login/page.tsx"
    click AdminAuthPage "https://github.com/16sulphur/higgs/blob/master/src/app/admin/login/page.tsx"
    click APIAuth "https://github.com/16sulphur/higgs/blob/master/src/app/api/auth/[...nextauth]/route.ts"
    click APILogin "https://github.com/16sulphur/higgs/blob/master/src/app/api/login/route.ts"
    click APILogout "https://github.com/16sulphur/higgs/blob/master/src/app/api/logout/route.ts"
    click Actions "https://github.com/16sulphur/higgs/tree/master/src/app/actions"
    click Lib "https://github.com/16sulphur/higgs/tree/master/src/app/lib"
    click ComponentsLib "https://github.com/16sulphur/higgs/tree/master/src/app/components"
    click LayoutMiddleware "https://github.com/16sulphur/higgs/blob/master/src/app/layout.tsx"
    click LayoutMiddleware "https://github.com/16sulphur/higgs/blob/master/src/app/middleware.ts"
    click SW "https://github.com/16sulphur/higgs/blob/master/public/sw.js"
    click WB "https://github.com/16sulphur/higgs/blob/master/public/workbox-38829a64.js"
    click Manifest "https://github.com/16sulphur/higgs/blob/master/src/app/manifest.json"
    click RootPublic "https://github.com/16sulphur/higgs/blob/master/src/app/page.tsx"
    click GlobalCSS "https://github.com/16sulphur/higgs/blob/master/src/app/globals.css"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef server fill:#DFFFE0,stroke:#28A745,color:#155724
    classDef db fill:#FFEFD0,stroke:#E69500,color:#AA5500
    classDef external fill:#F0F0F0,stroke:#6C757D,color:#343A40
```
