# iamanshkumar/book-my-event architecture

> Architecture diagram of the GitHub repository iamanshkumar/book-my-event, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iamanshkumar/book-my-event
- Repository: https://github.com/iamanshkumar/book-my-event

## Overview

1. **Repository shape**
   - This is a **single Next.js App Router monolith**: one frontend, one set of Route Handlers API endpoints, and one shared server-side backend layer.
   - The main persistence layer is **MySQL via Prisma ORM**, with schema and migration history under `prisma/`.

2. **Top-level runtime boundaries**
   - `src/app/` contains all route segments for pages and APIs.
   - `src/backend/` contains the domain/service layer and Prisma/auth utilities.
   - `src/components/` holds reusable UI and role-specific layout shells.
   - `src/proxy.ts` acts as the authentication/authorization boundary before requests reach protected areas.

3. **Public vs authenticated areas**
   - The app is divided into distinct UX zones:
     - Public event discovery and event detail pages.
     - Auth flows under `/(auth)` for login, register, forgot/reset password, OTP verification.
     - Attendee dashboard under `/dashboard`.
     - Organizer workspace under `/organizer`.
     - Admin console under `/admin`.
   - Each area has its own nested `layout.tsx`, which is important for diagramming separate shells and access scopes.

4. **API-first internal architecture**
   - Most behavior is implemented through **Next.js Route Handlers** in `src/app/api/...`.
   - The page layer and the API layer are decoupled: UI pages call route handlers, and route handlers delegate to backend services.
   - Key API namespaces are:
     - `api/auth`
     - `api/users`
     - `api/events`
     - `api/bookings`
     - `api/payments`
     - `api/organizer`
     - `api/admin`

5. **Backend service layer**
   - `src/backend/services/` is the main business-logic boundary.
   - The services map cleanly to domains:
     - `AuthService`
     - `BookingService`
     - `EventService`
     - `DashboardService`
     - `PaymentService`
   - This suggests a layered structure: **route handler → service → Prisma/database**, rather than direct DB access from UI code.

6. **Authentication and role enforcement**
   - Authentication is custom token-based, not a separate external identity provider.
   - The proxy middleware verifies user context and forwards it through headers such as `x-user-id` and `x-user-role`.
   - Role-based access control is central to the architecture, with three main roles:
     - Customer/Attendee
     - Organizer
     - Admin
   - Protected routes are separated both by URL namespace and by backend authorization checks.

7. **Core data model**
   - Prisma migrations show the schema has evolved around:
     - users and roles
     - events
     - ticket tiers
     - bookings
     - password reset tokens
     - event trailer URLs
   - The schema is designed for event listings with rich metadata, including categories, country/pincode fields, and multiple trailer/media links.

8. **Event discovery and organizer event management**
   - Public endpoints support listing, search, and event detail retrieval.
   - Organizer endpoints support creating and editing owned events, plus media uploads.
   - Event media is not just a single image: the readme indicates banner/thumbnail upload and multiple trailer sources, so event content is a structured asset bundle rather than a simple record.

9. **Booking and payment flow**
   - Booking is a transactional subsystem:
     - seats are reserved through booking creation
     - bookings can be cancelled, which releases seat inventory
     - payment webhooks update payment state asynchronously
   - `api/payments/webhooks` is the key external ingress point for payment status changes, so the booking/payment boundary is event-driven at least at webhook time.

10. **Account lifecycle**
   - Auth endpoints cover registration, login, logout, current-user lookup, password change, forgot-password, and reset-password.
   - The presence of password reset token migrations indicates token persistence in the database rather than purely stateless reset links.
   - Attendee profile editing is a separate user profile path from credential changes, which is important for diagramming account management flows.

11. **Organizer and admin workspaces**
   - Organizer APIs and pages focus on owned events, bookings, and revenue/fill-rate style dashboards.
   - Admin APIs and pages operate across the whole platform: system stats, user management, role updates, and force deletion of events.
   - This creates a clear split between **tenant-like ownership scopes** for organizers and **global authority** for admins.

12. **Shared UI and client shells**
   - `src/components/AttendeeLayoutClient.tsx`, `OrganizerLayoutClient.tsx`, and `AdminLayoutClient.tsx` indicate distinct client-side layout wrappers per role.
   - Reusable UI primitives live under `src/components/ui/`, with Tailwind-based styling and utility helpers in `src/lib/utils.ts`.
   - `ThemeToggle` is a shared cross-cutting UI concern, not a domain subsystem.

13. **Local infrastructure and deployment assumptions**
   - `docker-compose.yml` and `.env.example` show the repo expects a local MySQL environment for development.
   - Prisma migrations are part of the deployment story, so schema changes are managed through migration files rather than ad hoc SQL.
   - The app is built and served as a Next.js production bundle, not as separated frontend/backend services.

14. **How to draw the architecture**
   - A good diagram would show:
     - Browser/users entering Next.js pages
     - Proxy/middleware enforcing auth and role context
     - Route Handlers as the API layer
     - Backend services as the business logic tier
     - Prisma/MySQL as the persistence tier
     - Payment webhook as an external callback into the booking/payment flow
     - Separate UI/workspace boundaries for customer, organizer, and admin paths

Main entry points: [`src/backend/lib/prisma.ts`](https://github.com/iamanshkumar/book-my-event/blob/main/src/backend/lib/prisma.ts) (Prisma client), [`src/proxy.ts`](https://github.com/iamanshkumar/book-my-event/blob/main/src/proxy.ts) (Proxy), [`src/app/dashboard`](https://github.com/iamanshkumar/book-my-event/tree/main/src/app/dashboard) (Attendee area), [`src/app/api/admin`](https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/admin) (Admin API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend shells"]
  node_public_home["Home<br/>public page<br/>[page.tsx]"]
  node_event_pages["Event pages<br/>public routes"]
  node_auth_pages["Auth flows<br/>auth routes"]
  node_attendee_dashboard["Attendee area<br/>customer workspace"]
  node_organizer_workspace["Organizer area<br/>organizer workspace"]
  node_admin_console["Admin area<br/>admin workspace"]
end

subgraph group_api["Route handlers"]
  node_auth_api["Auth API<br/>route handlers"]
  node_event_api["Event API<br/>route handlers"]
  node_booking_api["Booking API<br/>route handlers"]
  node_payment_api{{"Payment webhooks<br/>ingress route"}}
  node_organizer_api["Organizer API<br/>route handlers"]
  node_admin_api["Admin API<br/>route handlers"]
  node_user_api["User API<br/>route handlers"]
end

subgraph group_backend["Backend services"]
  node_auth_service["AuthService<br/>[AuthService.ts]"]
  node_event_service["EventService<br/>[EventService.ts]"]
  node_booking_service["BookingService<br/>[BookingService.ts]"]
  node_payment_service["PaymentService<br/>[PaymentService.ts]"]
  node_dashboard_service["DashboardService"]
end

subgraph group_data["Data and auth"]
  node_proxy_boundary{{"Proxy<br/>auth gate<br/>[proxy.ts]"}}
  node_prisma_client[("Prisma client<br/>db access<br/>[prisma.ts]")]
  node_schema_migrations["Schema<br/>[schema.prisma]"]
end

node_proxy_boundary -->|"protects"| node_auth_pages
node_proxy_boundary -->|"protects"| node_attendee_dashboard
node_proxy_boundary -->|"protects"| node_organizer_workspace
node_proxy_boundary -->|"protects"| node_admin_console
node_public_home -->|"navigates"| node_event_pages
node_auth_pages -->|"calls"| node_auth_api
node_attendee_dashboard -->|"calls"| node_booking_api
node_attendee_dashboard -->|"calls"| node_user_api
node_organizer_workspace -->|"calls"| node_organizer_api
node_admin_console -->|"calls"| node_admin_api
node_public_home -->|"calls"| node_event_api
node_event_pages -->|"calls"| node_event_api
node_auth_api -->|"delegates"| node_auth_service
node_event_api -->|"delegates"| node_event_service
node_booking_api -->|"delegates"| node_booking_service
node_payment_api -->|"updates"| node_payment_service
node_organizer_api -->|"reads"| node_dashboard_service
node_admin_api -->|"reads"| node_dashboard_service
node_admin_api -->|"delegates"| node_event_service
node_user_api -->|"delegates"| node_auth_service
node_auth_service -->|"uses"| node_prisma_client
node_event_service -->|"uses"| node_prisma_client
node_booking_service -->|"uses"| node_prisma_client
node_payment_service -->|"uses"| node_prisma_client
node_dashboard_service -->|"uses"| node_prisma_client
node_prisma_client -->|"backed by"| node_schema_migrations

click node_public_home "https://github.com/iamanshkumar/book-my-event/blob/main/src/app/page.tsx"
click node_event_pages "https://github.com/iamanshkumar/book-my-event/tree/main/src/app/events"
click node_auth_pages "https://github.com/iamanshkumar/book-my-event/tree/main/src/app/(auth)"
click node_attendee_dashboard "https://github.com/iamanshkumar/book-my-event/tree/main/src/app/dashboard"
click node_organizer_workspace "https://github.com/iamanshkumar/book-my-event/tree/main/src/app/organizer"
click node_admin_console "https://github.com/iamanshkumar/book-my-event/tree/main/src/app/admin"
click node_proxy_boundary "https://github.com/iamanshkumar/book-my-event/blob/main/src/proxy.ts"
click node_auth_api "https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/auth"
click node_event_api "https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/events"
click node_booking_api "https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/bookings"
click node_payment_api "https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/payments/webhooks"
click node_organizer_api "https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/organizer"
click node_admin_api "https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/admin"
click node_user_api "https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/users"
click node_auth_service "https://github.com/iamanshkumar/book-my-event/blob/main/src/backend/services/AuthService.ts"
click node_event_service "https://github.com/iamanshkumar/book-my-event/blob/main/src/backend/services/EventService.ts"
click node_booking_service "https://github.com/iamanshkumar/book-my-event/blob/main/src/backend/services/BookingService.ts"
click node_payment_service "https://github.com/iamanshkumar/book-my-event/blob/main/src/backend/services/PaymentService.ts"
click node_dashboard_service "https://github.com/iamanshkumar/book-my-event/blob/main/src/backend/services/DashboardService.ts"
click node_prisma_client "https://github.com/iamanshkumar/book-my-event/blob/main/src/backend/lib/prisma.ts"
click node_schema_migrations "https://github.com/iamanshkumar/book-my-event/blob/main/prisma/schema.prisma"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_home,node_event_pages,node_auth_pages,node_attendee_dashboard,node_organizer_workspace,node_admin_console toneBlue
class node_auth_api,node_event_api,node_booking_api,node_payment_api,node_organizer_api,node_admin_api,node_user_api toneAmber
class node_auth_service,node_event_service,node_booking_service,node_payment_service,node_dashboard_service toneMint
class node_proxy_boundary,node_prisma_client,node_schema_migrations toneRose
```

## Components

### Frontend shells

Next.js pages and role-specific UI layouts

- [Home](https://github.com/iamanshkumar/book-my-event/blob/main/src/app/page.tsx): public page · Landing and discovery entry point · `src/app/page.tsx`
- [Event pages](https://github.com/iamanshkumar/book-my-event/tree/main/src/app/events): public routes · Public event listing and detail screens · `src/app/events`
- [Auth flows](https://github.com/iamanshkumar/book-my-event/tree/main/src/app/(auth)): auth routes · Login, register, OTP, and password recovery screens · `src/app/(auth)`
- [Attendee area](https://github.com/iamanshkumar/book-my-event/tree/main/src/app/dashboard): customer workspace · Dashboard, profile, tickets, and credential management · `src/app/dashboard`
- [Organizer area](https://github.com/iamanshkumar/book-my-event/tree/main/src/app/organizer): organizer workspace · Owned events, bookings, and organizer dashboard · `src/app/organizer`
- [Admin area](https://github.com/iamanshkumar/book-my-event/tree/main/src/app/admin): admin workspace · Platform-wide admin dashboard, events, and users · `src/app/admin`

### Route handlers

HTTP entrypoints grouped by domain

- [Auth API](https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/auth): route handlers · Login, register, logout, current user, and password lifecycle · `src/app/api/auth`
- [Event API](https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/events): route handlers · Public discovery plus organizer event creation and editing · `src/app/api/events`
- [Booking API](https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/bookings): route handlers · Booking creation, lookup, and cancellation · `src/app/api/bookings`
- [Payment webhooks](https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/payments/webhooks): ingress route · External payment status callbacks · `src/app/api/payments/webhooks`
- [Organizer API](https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/organizer): route handlers · Organizer dashboards, bookings, and owned events · `src/app/api/organizer`
- [Admin API](https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/admin): route handlers · Global stats, user management, and event moderation · `src/app/api/admin`
- [User API](https://github.com/iamanshkumar/book-my-event/tree/main/src/app/api/users): route handlers · Profile editing and user-centric operations · `src/app/api/users`

### Backend services

Shared business logic and persistence helpers

- [AuthService](https://github.com/iamanshkumar/book-my-event/blob/main/src/backend/services/AuthService.ts): service · Token auth, session context, and account lifecycle · `src/backend/services/AuthService.ts`
- [EventService](https://github.com/iamanshkumar/book-my-event/blob/main/src/backend/services/EventService.ts): service · Event discovery, ownership, media, and ticket tiers · `src/backend/services/EventService.ts`
- [BookingService](https://github.com/iamanshkumar/book-my-event/blob/main/src/backend/services/BookingService.ts): service · Seat reservation, booking cancellation, and inventory release · `src/backend/services/BookingService.ts`
- [PaymentService](https://github.com/iamanshkumar/book-my-event/blob/main/src/backend/services/PaymentService.ts): service · Payment state updates driven by webhooks · `src/backend/services/PaymentService.ts`
- [DashboardService](https://github.com/iamanshkumar/book-my-event/blob/main/src/backend/services/DashboardService.ts): service · Role-aware aggregates for attendee, organizer, and admin views · `src/backend/services/DashboardService.ts`

### Data and auth

Proxy, Prisma schema, and MySQL persistence

- [Proxy](https://github.com/iamanshkumar/book-my-event/blob/main/src/proxy.ts): auth gate · Pre-route auth and role context enforcement · `src/proxy.ts`
- [Prisma client](https://github.com/iamanshkumar/book-my-event/blob/main/src/backend/lib/prisma.ts): db access · Shared database access layer · `src/backend/lib/prisma.ts`
- [Schema](https://github.com/iamanshkumar/book-my-event/blob/main/prisma/schema.prisma): prisma schema · Models and migration history for users, events, bookings, and tokens · `prisma/schema.prisma`

## Connections

- Proxy → Auth flows: protects · Enforces role-aware access before protected UI loads
- Proxy → Attendee area: protects · Gates customer dashboard routes
- Proxy → Organizer area: protects · Gates organizer routes
- Proxy → Admin area: protects · Gates admin routes
- Home → Event pages: navigates · Discovery leads into event detail flows
- Auth flows → Auth API: calls · Auth UI uses route handlers for account operations
- Attendee area → Booking API: calls · Ticket and booking actions are API-backed
- Attendee area → User API: calls · Profile and account edits use user endpoints
- Organizer area → Organizer API: calls · Organizer UI drives dashboard and owned-event actions
- Admin area → Admin API: calls · Admin UI drives system management actions
- Home → Event API: calls · Public event discovery is API-backed
- Event pages → Event API: calls · Event detail and search data comes from event handlers
- Auth API → AuthService: delegates · Route handlers forward auth logic to the service layer
- Event API → EventService: delegates · Event routes delegate business logic to services
- Booking API → BookingService: delegates · Booking routes rely on transactional booking logic
- Payment webhooks → PaymentService: updates · Webhook callbacks reconcile payment state
- Organizer API → DashboardService: reads · Organizer metrics and aggregates are computed centrally
- Admin API → DashboardService: reads · Admin system stats come from shared aggregates
- Admin API → EventService: delegates · Admin event moderation uses event domain logic
- User API → AuthService: delegates · Profile and credential flows reuse auth/account logic
- AuthService → Prisma client: uses · Service layer persists and reads through Prisma
- EventService → Prisma client: uses · Event domain data flows through Prisma
- BookingService → Prisma client: uses · Booking transactions hit the database through Prisma
- PaymentService → Prisma client: uses · Payment updates persist through Prisma
- DashboardService → Prisma client: uses · Aggregations query shared persistence
- Prisma client → Schema: backed by · Client operates over the versioned Prisma schema
