How amrit22oct/event-management-dashboard works
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