# amrit22oct/event-management-dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/amrit22oct/event-management-dashboard
- Repository: https://github.com/amrit22oct/event-management-dashboard

## Overview

##### Project type & purpose (from README + tree)
This is a **full-stack Event Management Dashboard** with:
- **React SPA frontend** (Vite) for browsing events, authentication, organizer dashboards.
- **Node.js/Express backend** exposing a REST API for auth/events/registrations.
- **MongoDB** persistence via Mongoose models.
- **JWT-based auth** + **role-based authorization** (User vs Organizer).
- **Socket.io** for **real-time updates/notifications**.

The file tree confirms a classic “React client + Express API server” split:
- `Backend/` = Express app (`server.js`, `routes/`, `controllers/`, `middleware/`, `models/`, `socket.js`)
- `Frontend/` = React app (`src/pages/`, `src/components/`, `src/context/`, `src/services/api.js`, `src/socket.js`)

##### Container / Deployment view (high-level system design)
Runtime nodes and external dependencies:
- **Browser (User/Organizer)**
- **Frontend (React + Vite dev server / static hosting)**
- **Backend API (Node/Express HTTP server)**
- **Socket.io real-time channel** (often same backend server, but separate “WebSocket” path)
- **MongoDB Atlas (or MongoDB instance)**
- Optional: “External services” (none explicit besides MongoDB)

##### Component view (inside Backend + inside Frontend)
Split each codebase into its internal architectural components as reflected by directories/files.

##### Frontend (React)
From `Frontend/src/`:
- **Entry / bootstrap**
- `main.jsx` (mount React app)
- `App.jsx` (top-level routes/layout)
- **Routing / pages (React Router)**
- `pages/Home.jsx`
- `pages/Login.jsx`, `pages/Register.jsx`
- `pages/Dashboard.jsx` (organizer/user landing post-login)
- `pages/CreateEvent.jsx`, `pages/EditEvent.jsx`, `pages/ViewEvent.jsx`
- **UI components**
- `components/Navbar.jsx`
- `components/EventCard.jsx`
- `components/ProtectedRoute.jsx` (route guard)
- **Auth state management**
- `context/AuthContext.jsx` (stores JWT/user/role, provides login/logout)
- **API client**
- `services/api.js` (Axios instance; adds base URL, likely attaches JWT header)
- **Socket client**
- `src/socket.js` (Socket.io client connection; subscribe to event updates/notifications)
- **Styling**
- Tailwind mentioned in README + `index.css`

- Pages/components → `AuthContext` (read user/role, update on login/logout)
- Pages → `api.js` (REST calls)
- Pages/components → `socket.js` (subscribe to real-time updates; update UI)

##### Backend (Node/Express)
From `Backend/`:
- **Server entrypoint**
- `server.js` (Express app init, middleware setup, route mounting, DB connect, starts listening)
- **Socket server**
- `socket.js` (Socket.io setup; emits events/notifications)
- **Routes layer**
- `routes/authRoutes.js`
- `routes/eventRoutes.js`
- `routes/registrationRoutes.js`
- **Controllers layer (business logic)**
- `controllers/authController.js`
- `controllers/eventController.js`
- `controllers/registrationController.js`
- **Middleware**
- `middleware/authMiddleware.js` (JWT verification; attaches user to request)
- `middleware/roleMiddleware.js` (checks organizer vs user; enforces authorization)
- **Data models (Mongoose)**
- `models/User.js`
- `models/Event.js`
- `models/Registration.js`
- **Environment/config**
- `.env` (PORT, `MONGO_URI`, `JWT_SECRET`, `CLIENT_URL`)

- HTTP request → Express Router → middleware (auth/role) → controller → model → MongoDB
- Controller → Socket.io server (`socket.js`) to broadcast real-time event changes/notifications
- Auth controller issues **JWT** to client; client stores and reuses in Authorization header

##### Browser → Frontend → Backend
- `POST /auth/register` (create user)
- `POST /auth/login` (validate user)
##### Backend → Frontend
- Returns **JWT + user role**

##### Events flow
- Frontend → Backend:
- `GET /events` (public or authenticated depending on implementation)
- `POST /events` (Organizer only; show `roleMiddleware`)
- `DELETE /events/:id` (Organizer only + ownership check)
- Backend → MongoDB:
- `Event` model CRUD
- Backend → Socket.io:
- Emit “event created/updated/deleted” notifications
- Socket.io → Frontend:
- Real-time UI update / notification

##### Registration flow
- Frontend → Backend:
- `POST /registrations/:eventId`
- Backend → MongoDB:
- Create `Registration` record (links `User` ↔ `Event`)
- Optionally backend emits socket notification (e.g., organizer notified of new registration)

##### Architectural patterns to highlight (explicitly
- **Layered backend**: Routes → Middleware → Controllers → Models → DB
- **Role-based access control (RBAC)**: `authMiddleware` + `roleMiddleware`
- **JWT stateless auth**
- **Real-time pub/sub channel**: Socket.io alongside REST API
- **SPA + API** separation (React as presentation/client, Express as service boundary)

##### “Don’t overthink it” detail checklist (split into as many components as possible)
- Separate **each route file** and **controller file**
- Separate **authMiddleware** and **roleMiddleware**
- Separate **each Mongoose model**
- Separate REST vs Socket.io flows
- Separate user roles (User vs Organizer) at the edge (browser) and show which endpoints/actions they can do

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% =========================
  %% Container / Deployment View
  %% =========================
  subgraph "Container / Deployment View"
    direction TB

    U["User (Browser)"]:::external
    O["Organizer (Browser)"]:::external

    FE["Frontend (React SPA)"]:::frontend
    BE["Backend (Express API)"]:::backend

    RT["Real-time Channel (Socket.io)"]:::realtime
    DB[("MongoDB (Atlas/Instance)")]:::datastore
  end

  U -->|"HTTPS:loadSPA"| FE
  O -->|"HTTPS:loadSPA"| FE

  FE -->|"HTTPREST:/auth/login|JWTissue"| BE
  FE -->|"HTTPREST:/auth/register"| BE
  FE -->|"HTTPREST:/events|JWTBearer"| BE
  FE -->|"HTTPREST:/registrations/:eventId|JWTBearer"| BE

  FE <-->|"WS:Socket.io(event-updates/notifications)"| RT
  RT ---|"hostedwith"| BE

  BE -->|"DB:MongooseCRUD"| DB

  %% =========================
  %% Frontend Component View
  %% =========================
  subgraph "Frontend (React) - Component View"
    direction TB

    FE_Main["main.jsx (Bootstrap)"]:::frontend
    FE_App["App.jsx (Router/Shell)"]:::frontend

    subgraph "Pages (React Router)"
      direction TB
      P_Home["Home.jsx"]:::frontend
      P_Login["Login.jsx"]:::frontend
      P_Register["Register.jsx"]:::frontend
      P_Dashboard["Dashboard.jsx"]:::frontend
      P_Create["CreateEvent.jsx"]:::frontend
      P_Edit["EditEvent.jsx"]:::frontend
      P_View["ViewEvent.jsx"]:::frontend
    end

    subgraph "UI Components"
      direction TB
      C_Nav["Navbar.jsx"]:::frontend
      C_Card["EventCard.jsx"]:::frontend
      C_Protected["ProtectedRoute.jsx"]:::security
    end

    FE_Auth["AuthContext.jsx (JWT/user/role)"]:::security
    FE_API["services/api.js (Axios+JWTheader)"]:::api
    FE_Sock["socket.js (Socket.io client)"]:::realtime
    FE_CSS["index.css (Tailwind/global)"]:::frontend
  end

  FE_Main -->|"mount"| FE_App
  FE_App -->|"routes"| P_Home
  FE_App -->|"routes"| P_Login
  FE_App -->|"routes"| P_Register
  FE_App -->|"routes"| P_Dashboard
  FE_App -->|"routes"| P_Create
  FE_App -->|"routes"| P_Edit
  FE_App -->|"routes"| P_View

  P_Home -->|"compose"| C_Nav
  P_Dashboard -->|"compose"| C_Nav
  P_View -->|"compose"| C_Nav
  P_Home -->|"compose"| C_Card
  P_View -->|"compose"| C_Card

  FE_App -->|"guard"| C_Protected
  C_Protected -->|"readsrole/JWT"| FE_Auth

  P_Login -->|"login()updates"| FE_Auth
  P_Register -->|"register()updates"| FE_Auth
  P_Dashboard -->|"readssession"| FE_Auth
  P_Create -->|"readssession"| FE_Auth
  P_Edit -->|"readssession"| FE_Auth

  P_Login -->|"POST/auth/login"| FE_API
  P_Register -->|"POST/auth/register"| FE_API
  P_Home -->|"GET/events"| FE_API
  P_View -->|"GET/events/:id"| FE_API
  P_Create -->|"POST/events(OrganizerOnly)"| FE_API
  P_Edit -->|"PUT/events/:id(OrganizerOnly)"| FE_API
  P_View -->|"POST/registrations/:eventId"| FE_API

  P_Home -->|"subscribe"| FE_Sock
  P_Dashboard -->|"subscribe"| FE_Sock
  P_View -->|"subscribe"| FE_Sock

  FE_API -->|"HTTPREST(JSON)+JWTBearer"| BE
  FE_Sock <-->|"WS:Socket.io"| RT

  %% =========================
  %% Backend Component View
  %% =========================
  subgraph "Backend (Express) - Component View"
    direction TB

    BE_Server["server.js (Express bootstrap)"]:::backend
    BE_Socket["socket.js (Socket.io server)"]:::realtime
    BE_Env[".env (PORT/MONGO_URI/JWT_SECRET/CLIENT_URL)"]:::config

    subgraph "Routes Layer"
      direction TB
      R_Auth["routes/authRoutes.js"]:::api
      R_Event["routes/eventRoutes.js"]:::api
      R_Reg["routes/registrationRoutes.js"]:::api
    end

    subgraph "Middleware Layer (RBAC)"
      direction TB
      MW_Auth["middleware/authMiddleware.js (JWT verify)"]:::security
      MW_Role["middleware/roleMiddleware.js (User vs Organizer)"]:::security
    end

    subgraph "Controllers Layer (Business Logic)"
      direction TB
      CT_Auth["controllers/authController.js"]:::backend
      CT_Event["controllers/eventController.js"]:::backend
      CT_Reg["controllers/registrationController.js"]:::backend
    end

    subgraph "Models Layer (Mongoose)"
      direction TB
      M_User["models/User.js"]:::datastore
      M_Event["models/Event.js"]:::datastore
      M_Reg["models/Registration.js"]:::datastore
    end
  end

  BE_Env -->|"configure"| BE_Server
  BE_Server -->|"initSocket"| BE_Socket

  BE_Server -->|"mount:/auth"| R_Auth
  BE_Server -->|"mount:/events"| R_Event
  BE_Server -->|"mount:/registrations"| R_Reg

  R_Auth -->|"calls"| CT_Auth
  R_Event -->|"uses"| MW_Auth
  R_Event -->|"uses"| MW_Role
  R_Event -->|"calls"| CT_Event
  R_Reg -->|"uses"| MW_Auth
  R_Reg -->|"calls"| CT_Reg

  CT_Auth -->|"query/create"| M_User
  CT_Event -->|"CRUD"| M_Event
  CT_Reg -->|"createLink(User↔Event)"| M_Reg
  CT_Reg -->|"read"| M_User
  CT_Reg -->|"read"| M_Event

  M_User -->|"persist"| DB
  M_Event -->|"persist"| DB
  M_Reg -->|"persist"| DB

  CT_Event -->|"emit:event-created/updated/deleted"| BE_Socket
  CT_Reg -->|"emit:registration-created"| BE_Socket
  BE_Socket -->|"pushNotifications"| RT

  %% =========================
  %% Cross-view notes (security/dataflow)
  %% =========================
  FE_Auth -->|"storesJWT+role"| FE_API
  FE_API -->|"Authorization:Bearer<JWT>"| BE
  BE -->|"JWTverify+RBAC"| MW_Auth
  MW_Auth -->|"attachreq.user"| MW_Role

  %% =========================
  %% Click Events (from mapping)
  %% =========================
  click BE_Server "https://github.com/amrit22oct/event-management-dashboard/blob/main/Backend/server.js"
  click BE_Socket "https://github.com/amrit22oct/event-management-dashboard/blob/main/Backend/socket.js"
  click R_Auth "https://github.com/amrit22oct/event-management-dashboard/blob/main/Backend/routes/authRoutes.js"
  click R_Event "https://github.com/amrit22oct/event-management-dashboard/blob/main/Backend/routes/eventRoutes.js"
  click R_Reg "https://github.com/amrit22oct/event-management-dashboard/blob/main/Backend/routes/registrationRoutes.js"
  click CT_Auth "https://github.com/amrit22oct/event-management-dashboard/blob/main/Backend/controllers/authController.js"
  click CT_Event "https://github.com/amrit22oct/event-management-dashboard/blob/main/Backend/controllers/eventController.js"
  click CT_Reg "https://github.com/amrit22oct/event-management-dashboard/blob/main/Backend/controllers/registrationController.js"
  click MW_Auth "https://github.com/amrit22oct/event-management-dashboard/blob/main/Backend/middleware/authMiddleware.js"
  click MW_Role "https://github.com/amrit22oct/event-management-dashboard/blob/main/Backend/middleware/roleMiddleware.js"
  click M_User "https://github.com/amrit22oct/event-management-dashboard/blob/main/Backend/models/User.js"
  click M_Event "https://github.com/amrit22oct/event-management-dashboard/blob/main/Backend/models/Event.js"
  click M_Reg "https://github.com/amrit22oct/event-management-dashboard/blob/main/Backend/models/Registration.js"
  click BE_Env "https://github.com/amrit22oct/event-management-dashboard/blob/main/Backend/.env"

  click FE_Main "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/main.jsx"
  click FE_App "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/App.jsx"
  click P_Home "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/pages/Home.jsx"
  click P_Login "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/pages/Login.jsx"
  click P_Register "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/pages/Register.jsx"
  click P_Dashboard "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/pages/Dashboard.jsx"
  click P_Create "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/pages/CreateEvent.jsx"
  click P_Edit "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/pages/EditEvent.jsx"
  click P_View "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/pages/ViewEvent.jsx"
  click C_Nav "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/components/Navbar.jsx"
  click C_Card "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/components/EventCard.jsx"
  click C_Protected "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/components/ProtectedRoute.jsx"
  click FE_Auth "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/context/AuthContext.jsx"
  click FE_API "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/services/api.js"
  click FE_Sock "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/socket.js"
  click FE_CSS "https://github.com/amrit22oct/event-management-dashboard/blob/main/Frontend/src/index.css"

  %% =========================
  %% Styles
  %% =========================
  classDef external fill:#f3f4f6,stroke:#6b7280,color:#111827,stroke-width:1px
  classDef frontend fill:#dbeafe,stroke:#2563eb,color:#0b1220,stroke-width:1px
  classDef backend fill:#dcfce7,stroke:#16a34a,color:#052e16,stroke-width:1px
  classDef api fill:#e0f2fe,stroke:#0284c7,color:#0c4a6e,stroke-width:1px
  classDef security fill:#ffedd5,stroke:#f97316,color:#7c2d12,stroke-width:1px
  classDef datastore fill:#ede9fe,stroke:#7c3aed,color:#2e1065,stroke-width:1px
  classDef realtime fill:#ffe4e6,stroke:#e11d48,color:#881337,stroke-width:1px
  classDef config fill:#fef9c3,stroke:#ca8a04,color:#713f12,stroke-width:1px
```
