# saufi-opi/event-management-app architecture

> Architecture diagram of the GitHub repository saufi-opi/event-management-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saufi-opi/event-management-app
- Repository: https://github.com/saufi-opi/event-management-app

## Overview

##### Project type and purpose
- This is a full-stack web application (“Event Management App”) built on Next.js (App Router), Prisma ORM, and NextAuth.
- Purpose: allow authenticated users to create/manage events (dashboard), and allow participants to register or join public event pages.

##### File structure
- Top level:
- prisma/schema.prisma → database schema definitions (PostgreSQL/MySQL)
- src/app → Next.js App Router routes
– (dashboard) subfolder: authenticated UI for event & participant management
– (home) subfolder: login & landing pages
– api/auth → NextAuth API route
– participate → public event participation pages
- src/components → reusable UI elements (forms, table, navigation, primitives)
- src/server → server-side business logic
– actions/*.action.ts → data-mutation functions
– data/*.data.ts → query helpers
– db.ts → Prisma client instantiation
– auth.ts & permission/permission.ts → auth & ACL
- src/providers/next-auth-provider.tsx → client-side NextAuth context
- middleware.ts → request middleware (auth guard, redirects)
- env.js, .env.example → environment variables
- Configuration: next.config.js, tailwind.config.ts, tsconfig.json, lint/format configs.

##### README for insights
- Confirmation of Next.js + Prisma tech stack.
- Feature set: event creation, participant management, sign-in.

##### Main system components & their interactions
a. Frontend (Next.js App Router)
- Layout & page components under src/app drive SSR/SSG UI
- Client-side React components under src/components render forms, tables, navigation
- NextAuth React hooks (supplied by next-auth-provider) manage session state
b. API / Server Layer
- Next.js API route at /api/auth/[...nextauth] handles OAuth/session flows
- Server Actions (inside src/server/actions) exposed via form submissions / fetch calls
- Middleware routes requests; enforces auth/permissions via src/server/auth + permission
c. Database Layer
- Prisma client (src/server/db.ts) connects to relational database defined in prisma/schema.prisma
- Data access functions (src/server/data) encapsulate Prisma queries for events & participants
d. External Services
- OAuth providers configured by NextAuth (e.g., Google, GitHub—implicit in env)
- Optional external email/SMS services if notifications were added (not explicit here)

##### Architectural patterns & design principles
- Monolithic, single-repo full-stack: UI + API + DB in one Next.js project
- Separation by concern:
- Presentation: src/app + src/components
- Business logic: src/server/actions + src/server/data
- Persistence: Prisma + schema
- Cross-cutting: middleware, auth, permissions
- React server components vs. client components (Next.js 13 App Router)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers and Components
    Browser["User Browser"]:::external

    subgraph "Next.js Frontend (src/app)"
        direction TB
        DashboardUI["Dashboard UI"]:::frontend
        HomeUI["Home & Auth UI"]:::frontend
        ParticipateUI["Public Participation UI"]:::frontend
        NextAuthProvider["NextAuth Client Provider"]:::frontend
    end

    subgraph "Server/API Layer"
        direction TB
        APIAuth["NextAuth API Route"]:::backend
        Middleware["Request Middleware"]:::backend
        subgraph "Business Logic (src/server)"
            direction TB
            PrismaClient["Prisma Client"]:::backend
            EventActions["Event Actions"]:::backend
            ParticipantActions["Participant Actions"]:::backend
            EventData["Event Data Helpers"]:::backend
            ParticipantData["Participant Data Helpers"]:::backend
            AuthUtil["Auth Utilities"]:::backend
            PermissionUtil["Permissions"]:::backend
        end
    end

    subgraph "Database Layer"
        direction TB
        DBSchema["Prisma Schema"]:::db
        Database["PostgreSQL DB"]:::db
    end

    ExternalOAuth["OAuth Provider"]:::external

    %% Connections
    Browser -->|HTTP GET/SSR| DashboardUI
    Browser -->|HTTP GET/SSR| HomeUI
    Browser -->|HTTP GET/SSR| ParticipateUI
    DashboardUI -->|uses| NextAuthProvider
    HomeUI -->|uses| NextAuthProvider
    ParticipateUI -->|uses| NextAuthProvider

    DashboardUI -->|fetch /api/events| APIAuth
    DashboardUI -->|fetch /api/participants| APIAuth
    HomeUI -->|fetch /api/auth| APIAuth
    ParticipateUI -->|fetch /api/participate| APIAuth

    APIAuth -->|calls| Middleware
    Middleware -->|enforce auth| AuthUtil
    Middleware -->|enforce perms| PermissionUtil
    Middleware -->|routes requests| EventActions
    Middleware -->|routes requests| ParticipantActions

    EventActions -->|uses| EventData
    ParticipantActions -->|uses| ParticipantData
    EventData -->|Prisma query| PrismaClient
    ParticipantData -->|Prisma query| PrismaClient

    PrismaClient -->|reads/writes| Database
    DBSchema -->|defines schema| Database

    APIAuth -->|OAuth handshake| ExternalOAuth

    %% Click Events
    click DashboardUI "https://github.com/saufi-opi/event-management-app/blob/main/src/app/(dashboard)/dashboard/layout.tsx"
    click DashboardUI "https://github.com/saufi-opi/event-management-app/blob/main/src/app/(dashboard)/dashboard/page.tsx"
    click EventList "https://github.com/saufi-opi/event-management-app/blob/main/src/app/(dashboard)/dashboard/event/page.tsx"
    click EventDetail "https://github.com/saufi-opi/event-management-app/blob/main/src/app/(dashboard)/dashboard/event/[eventId]/page.tsx"
    click ParticipantList "https://github.com/saufi-opi/event-management-app/blob/main/src/app/(dashboard)/dashboard/participant/page.tsx"
    click ParticipantDetail "https://github.com/saufi-opi/event-management-app/blob/main/src/app/(dashboard)/dashboard/participant/[participantId]/page.tsx"
    click HomeUI "https://github.com/saufi-opi/event-management-app/blob/main/src/app/(home)/layout.tsx"
    click HomeUI "https://github.com/saufi-opi/event-management-app/blob/main/src/app/(home)/page.tsx"
    click HomeUI "https://github.com/saufi-opi/event-management-app/blob/main/src/app/(home)/login/page.tsx"
    click ParticipateUI "https://github.com/saufi-opi/event-management-app/blob/main/src/app/participate/[eventId]/page.tsx"
    click ParticipateUI "https://github.com/saufi-opi/event-management-app/blob/main/src/app/participate/[eventId]/not-found.tsx"
    click APIAuth "https://github.com/saufi-opi/event-management-app/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click DBSchema "https://github.com/saufi-opi/event-management-app/blob/main/prisma/schema.prisma"
    click PrismaClient "https://github.com/saufi-opi/event-management-app/blob/main/src/server/db.ts"
    click EventActions "https://github.com/saufi-opi/event-management-app/blob/main/src/server/actions/event.action.ts"
    click ParticipantActions "https://github.com/saufi-opi/event-management-app/blob/main/src/server/actions/participant.action.ts"
    click EventData "https://github.com/saufi-opi/event-management-app/blob/main/src/server/data/event.data.ts"
    click ParticipantData "https://github.com/saufi-opi/event-management-app/blob/main/src/server/data/participant.data.ts"
    click AuthUtil "https://github.com/saufi-opi/event-management-app/blob/main/src/server/auth.ts"
    click PermissionUtil "https://github.com/saufi-opi/event-management-app/blob/main/src/server/permission/permission.ts"
    click NextAuthProvider "https://github.com/saufi-opi/event-management-app/blob/main/src/providers/next-auth-provider.tsx"
    click Middleware "https://github.com/saufi-opi/event-management-app/blob/main/src/middleware.ts"
    click ComponentsDir "https://github.com/saufi-opi/event-management-app/tree/main/src/components"
    click EnvJS "https://github.com/saufi-opi/event-management-app/blob/main/src/env.js"
    click EnvExample "https://github.com/saufi-opi/event-management-app/blob/main/.env.example"

    %% Styles
    classDef frontend fill:#CEF6F5,stroke:#008B8B,stroke-width:1px
    classDef backend fill:#FFE5B4,stroke:#FF8C00,stroke-width:1px
    classDef db fill:#D0F0C0,stroke:#228B22,stroke-width:1px
    classDef external fill:#E6E6FA,stroke:#9370DB,stroke-width:1px
```
