# night3y3/event-ease-assignment architecture

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

- Interactive diagram: https://gitdiagram.com/night3y3/event-ease-assignment
- Repository: https://github.com/night3y3/event-ease-assignment

## Overview

##### Project Type and Purpose
- This is a full-stack web application (Next.js App Router) for event management, featuring role-based authentication, event creation/publishing, public RSVP forms, attendee tracking, CSV exports, and dashboards.
- Backend and frontend are co-located in a single Next.js monorepo, using TypeScript, Tailwind CSS + shadcn/ui, NextAuth.js for auth, Prisma ORM for PostgreSQL, and deployed on Vercel.

##### File Structure Analysis
- Top-level “app” directory holds:
- app/api/* – JSON API routes for admin actions, events, attendees, auth, exports
- app/dashboard/* – authenticated dashboard pages (SSR/SSG) for admins, staff, owners
- app/events/*, app/login, app/register, app/page.tsx – public and auth pages
- “components” contains reusable UI components and shadcn/ui primitives.
- “lib” has data-access functions, Prisma client, Auth providers, utilities, Google Calendar integration.
- “prisma” holds schema and migration SQL.
- “hooks” and “styles” provide custom hooks and global Tailwind CSS config.

##### Main System Components
- Client Browser (React + Next.js pages & client components)
- Next.js Server (App Router SSR handlers + API route handlers)
- Auth Service (NextAuth.js endpoints, secure sessions, role checks)
- Business Logic Layer (lib/actions.ts, lib/data.ts, form handlers)
- ORM Layer (Prisma client)
- Database (PostgreSQL)
- External Services
- Google Calendar API (lib/google-calendar.ts)
- Email provider (NextAuth’s email adapter, if configured)
- Hosting/Deployment (Vercel)

##### Component Relationships & Data Flow
- Browser → HTTP(S) → Next.js Server
- Navigates to SSR pages (dashboard, events, public pages)
- Submits form data to app/api routes (register, login, RSVP, exports)
- Next.js Server (API handlers) → Prisma ORM → PostgreSQL
- Next.js Server (Server Components) → lib/* → database or external APIs
- NextAuth.js middleware intercepts auth calls, reads/writes secure cookies, consults Prisma for user/session records
- Export routes generate CSV, stream back to client
- Google Calendar integration invoked from server code, syncing events externally

##### Architectural Patterns & Design Principles
- Monolithic full-stack using Next.js App Router (co-located front/back code)
- Clear separation between:
- Presentation (React components in “components” & “app”)
- Business logic (“lib/actions.ts”, “lib/data.ts”)
- Data persistence (Prisma + PostgreSQL)
- Role-based access control enforced at API route level and in page layouts
- Reusable UI primitives via shadcn/ui for consistency
- Utility hooks for cross-cutting concerns (use-mobile, use-toast)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        A_browser["Client Browser\n(React + Next.js Client Components)"]:::frontend
        A_page["app/page.tsx"]:::frontend
        A_events_page["app/events/page.tsx & [id]/page.tsx"]:::frontend
        A_login["app/login/page.tsx"]:::frontend
        A_register["app/register/page.tsx"]:::frontend
        A_components["components/*"]:::frontend
    end
    click A_page "https://github.com/night3y3/event-ease-assignment/blob/main/app/page.tsx"
    click A_events_page "https://github.com/night3y3/event-ease-assignment/blob/main/app/events/page.tsx"
    click A_login "https://github.com/night3y3/event-ease-assignment/blob/main/app/login/page.tsx"
    click A_register "https://github.com/night3y3/event-ease-assignment/blob/main/app/register/page.tsx"
    click A_components "https://github.com/night3y3/event-ease-assignment/tree/main/components/"

    %% Presentation Layer
    subgraph "Presentation Layer\n(Next.js Server Components & Pages)"
        direction TB
        B_layout["app/layout.tsx & globals.css"]:::presentation
        B_dashboard_layout["app/dashboard/layout.tsx & page.tsx"]:::presentation
        B_dash_events["app/dashboard/events/page.tsx\nnew/page.tsx\n[id]/page.tsx\n[id]/edit/page.tsx"]:::presentation
        B_dash_attendees["app/dashboard/attendees/page.tsx"]:::presentation
        B_dash_users["app/dashboard/users/page.tsx"]:::presentation
    end
    click B_layout "https://github.com/night3y3/event-ease-assignment/blob/main/app/layout.tsx"
    click B_dashboard_layout "https://github.com/night3y3/event-ease-assignment/blob/main/app/dashboard/layout.tsx"
    click B_dash_events "https://github.com/night3y3/event-ease-assignment/tree/main/app/dashboard/events/"
    click B_dash_attendees "https://github.com/night3y3/event-ease-assignment/blob/main/app/dashboard/attendees/page.tsx"
    click B_dash_users "https://github.com/night3y3/event-ease-assignment/blob/main/app/dashboard/users/page.tsx"

    %% API Layer
    subgraph "API Layer\n(JSON API Routes)"
        direction TB
        C_nextauth["app/api/auth/[...nextauth]/route.ts"]:::api
        C_register["app/api/auth/register/route.ts"]:::api
        C_events["app/api/events/[id]/route.ts"]:::api
        C_events_export["app/api/events/[id]/export/route.ts"]:::api
        C_attendees_export["app/api/attendees/export/route.ts"]:::api
        C_admin_events_export["app/api/admin/events/export/route.ts"]:::api
        C_attendees["app/api/attendees/route.ts"]:::api
        C_admin_events["app/api/admin/events/route.ts"]:::api
    end
    click C_nextauth "https://github.com/night3y3/event-ease-assignment/blob/main/app/api/auth/[...nextauth]/route.ts"
    click C_register "https://github.com/night3y3/event-ease-assignment/blob/main/app/api/auth/register/route.ts"
    click C_events "https://github.com/night3y3/event-ease-assignment/blob/main/app/api/events/[id]/route.ts"
    click C_events_export "https://github.com/night3y3/event-ease-assignment/blob/main/app/api/events/[id]/export/route.ts"
    click C_attendees_export "https://github.com/night3y3/event-ease-assignment/blob/main/app/api/attendees/export/route.ts"
    click C_admin_events_export "https://github.com/night3y3/event-ease-assignment/blob/main/app/api/admin/events/export/route.ts"
    click C_attendees "https://github.com/night3y3/event-ease-assignment/blob/main/app/api/attendees/route.ts"
    click C_admin_events "https://github.com/night3y3/event-ease-assignment/blob/main/app/api/admin/events/route.ts"

    %% Business Logic Layer
    subgraph "Business Logic Layer\n(lib modules)"
        direction TB
        D_actions["lib/actions.ts"]:::business
        D_data["lib/data.ts"]:::business
        D_session["lib/get-server-session.ts"]:::business
        D_utils["lib/utils.ts"]:::business
        D_types["lib/types.ts"]:::business
        D_auth_provider["lib/auth-provider.tsx"]:::business
        D_auth_lib["lib/auth.ts"]:::business
    end
    click D_actions "https://github.com/night3y3/event-ease-assignment/blob/main/lib/actions.ts"
    click D_data "https://github.com/night3y3/event-ease-assignment/blob/main/lib/data.ts"
    click D_session "https://github.com/night3y3/event-ease-assignment/blob/main/lib/get-server-session.ts"
    click D_utils "https://github.com/night3y3/event-ease-assignment/blob/main/lib/utils.ts"
    click D_types "https://github.com/night3y3/event-ease-assignment/blob/main/lib/types.ts"
    click D_auth_provider "https://github.com/night3y3/event-ease-assignment/blob/main/lib/auth-provider.tsx"
    click D_auth_lib "https://github.com/night3y3/event-ease-assignment/blob/main/lib/auth.ts"

    %% ORM Layer
    subgraph "ORM Layer\n(Prisma)"
        direction TB
        E_prisma_client["lib/prisma.ts"]:::orm
        E_schema["prisma/schema.prisma"]:::orm
        E_migrations["prisma/migrations/"]:::orm
    end
    click E_prisma_client "https://github.com/night3y3/event-ease-assignment/blob/main/lib/prisma.ts"
    click E_schema "https://github.com/night3y3/event-ease-assignment/blob/main/prisma/schema.prisma"
    click E_migrations "https://github.com/night3y3/event-ease-assignment/tree/main/prisma/migrations/"

    %% Database
    DB["PostgreSQL\n(prisma)"]:::db

    %% External Services
    subgraph "External Services"
        direction TB
        F_google["lib/google-calendar.ts"]:::external
        F_email["Email Provider"]:::external
    end
    click F_google "https://github.com/night3y3/event-ease-assignment/blob/main/lib/google-calendar.ts"

    %% Deployment & Config
    subgraph "Deployment\n& Config"
        direction TB
        G_nextconfig["next.config.mjs"]:::deployment
        G_tailwind["tailwind.config.ts"]:::deployment
        G_postcss["postcss.config.mjs"]:::deployment
        G_vercel["Vercel"]:::deployment
    end
    click G_nextconfig "https://github.com/night3y3/event-ease-assignment/blob/main/next.config.mjs"
    click G_tailwind "https://github.com/night3y3/event-ease-assignment/blob/main/tailwind.config.ts"
    click G_postcss "https://github.com/night3y3/event-ease-assignment/blob/main/postcss.config.mjs"

    %% Data Flows
    A_browser --> B_layout
    A_browser --> B_dashboard_layout
    A_browser --> B_dash_events
    A_browser --> B_dash_attendees
    A_browser --> B_dash_users
    A_browser --> C_nextauth
    A_browser --> C_register
    A_browser --> C_events
    A_browser --> C_attendees

    C_nextauth --> D_session
    C_nextauth --> D_auth_lib
    C_nextauth --> D_data
    C_register --> D_data
    C_events --> D_actions
    C_events_export --> D_data
    C_attendees_export --> D_data
    C_admin_events_export --> D_data
    C_attendees --> D_actions
    C_admin_events --> D_actions

    D_data --> E_prisma_client
    D_actions --> E_prisma_client
    D_session --> E_prisma_client
    D_auth_lib --> E_prisma_client

    E_prisma_client --> DB
    C_nextauth --> DB

    D_actions --> F_google
    C_events --> F_google

    G_vercel --> A_browser
    G_vercel --> B_layout

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085;
    classDef presentation fill:#d4edda,stroke:#155724,color:#155724;
    classDef api fill:#fff3cd,stroke:#856404,color:#856404;
    classDef business fill:#d1ecf1,stroke:#0c5460,color:#0c5460;
    classDef orm fill:#f8d7da,stroke:#721c24,color:#721c24;
    classDef db fill:#ffeeba,stroke:#856404,color:#856404,shape:cylinder;
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d,shape:cloud;
    classDef deployment fill:#f5c6cb,stroke:#721c24,color:#721c24,shape:cloud;
```
