How julian049/eventsproject works
1. Overall shape
- This is a two-tier event management system: a Node.js/Express backend exposes a REST API, and a React + Vite frontend consumes it as a SPA.
- Persistent storage is PostgreSQL, typically started via Docker Compose.
2. Backend entry and runtime
- backend/index.js is the server entry point and likely wires together Express, routes, middleware, and database connectivity from backend/database.js.
- The backend listens on a configurable port and uses environment variables for DB credentials and JWT secrets.
3. Backend layering
- The backend is organized into a classic layered structure:
- routes define HTTP endpoints,
- controllers handle request/response orchestration,
- services contain business rules,
- models encapsulate SQL/data access.
- This separation is consistent across auth, users, events, categories, ticket types, purchases, tickets, and dashboard features.
4. Core domain subsystems
- The main business entities are users, events, categories, ticket types, event-ticket-type assignments, purchases, and tickets.
- eventTicketType acts as the bridge between a base ticket type and a specific event, carrying event-specific pricing/capacity data.
- dashboard is a read-only aggregation subsystem for metrics like sales and popular events.
5. Authentication and authorization
- Authentication is JWT-based, with helpers in backend/utils/jwt.js and password hashing in backend/utils/bcrypt.js.
- backend/middlewares/authMiddleware.js protects routes that require identity or role checks.
- backend/constants/role.js suggests role-based access control, so some create/admin actions are gated.
6. Event lifecycle and scheduled behavior
- eventController, eventService, and eventModel manage event creation, pagination, detail views, favorites, and interest tracking.
- backend/cron/eventCron.js indicates periodic background work related to event state, likely cleanup or status updates independent of direct user requests.
7. Purchase and ticket flow
- The purchase path runs through purchaseRoute → purchaseController → purchaseService → purchaseModel.
- A successful purchase results in ticket records managed by ticketController / ticketService, and users can later fetch their own tickets.
- This is the main transactional flow in the app: selecting an event, choosing ticket types, purchasing, then retrieving issued tickets.
8. Database and persistence model
- backend/database/init.sql defines the schema; seed.sql provides initial data.
- The project uses soft deletes via a status flag instead of removing rows physically.
- The presence of separate model files with both singular and *Model.js variants suggests SQL-centric persistence with thin domain wrappers.
9. Frontend structure
- The frontend is a React SPA built with Vite.
- frontend/src/main.jsx boots the app, App.jsx likely defines routing/layout, and AuthContext.jsx holds global authentication state.
- Reusable UI is centralized in components/ for forms, modals, navbar, and loading states.
10. Frontend page composition
- The pages map directly to major user journeys: browsing events, event details, categories, favorites, checkout, tickets, profile, login/register, and reporting.
- EventForm suggests an admin/editor flow for creating or editing events inside the UI.
- ReportPage corresponds to the backend dashboard/metrics subsystem.
11. Frontend-to-backend integration
- frontend/src/services/ contains API clients grouped by backend domain: auth, events, categories, checkout, ticket types, users, and dashboard.
- AuthContext likely injects the JWT into requests and controls route access in the UI.
- The frontend is therefore a thin presentation layer; most business logic lives on the backend.
12. Infrastructure and deployment boundaries
- docker-compose.yml is used to provision PostgreSQL, keeping the database outside the application process.
- The root-level and backend-specific package files indicate separate dependency/runtime boundaries for frontend and backend.
- GitHub Actions CI is present, so the repo includes automated validation in addition to local dev startup.
Main entry points: backend/index.js Server · services/index.js API Client · App.jsx App Shell · purchaseService.js Purchase Logic
Components 24
Backend
Express API, business logic, and PostgreSQL persistence
- Server · Backend entry point wiring routes, middleware, and server startup
backend/index.js - DB Conn · Database connection and shared SQL access setup
backend/database.js - Auth API · Login and registration endpoints
backend/routes/authRoute.js - Events API · Event browsing and event lifecycle endpoints
backend/routes/eventRoute.js - Purchases API · Checkout and purchase endpoints
backend/routes/purchaseRoute.js - Tickets API · Issued ticket retrieval endpoints
backend/routes/ticketRoute.js - Dashboard API · Read-only reporting and metrics endpoints
backend/routes/dashboardRoute.js - Auth Logic · Credential handling, JWT issuance, and auth flows
backend/services/authService.js - Event Logic · Event creation, paging, favorites, and interest rules
backend/services/eventService.js - Purchase Logic · Transactional purchase orchestration
backend/services/purchaseService.js - Ticket Logic · Ticket issuance and retrieval rules
backend/services/ticketService.js - Metrics Logic · Aggregates sales and popularity metrics
backend/services/dashboardService.js - Event Model · Event data access and persistence
backend/models/eventModel.js - User Model · User data access and persistence
backend/models/userModel.js - Purchase Model · Purchase persistence and lookup
backend/models/purchaseModel.js - Ticket Model · Ticket persistence and lookup
backend/models/ticketModel.js
Frontend
React SPA and API client layer
- App Shell · Top-level SPA composition and routing
frontend/src/App.jsx - Auth State · Global authentication state and token handling
frontend/src/context/AuthContext.jsx - API Client · Domain API clients for backend integration
frontend/src/services/index.js - Pages · User journeys for browsing, checkout, profile, and reporting
frontend/src/pages/EventsPage/EventsPage.jsx - UI Kit · Reusable forms, modals, navbar, and spinner components
frontend/src/components/Navbar/Navbar.jsx
Connections 30
- Server → DB Conn: connects · Initializes and uses the shared database layer
- Server → Auth API: mounts · Registers auth endpoints
- Server → Events API: mounts · Registers event endpoints
- Server → Purchases API: mounts · Registers purchase endpoints
- Server → Tickets API: mounts · Registers ticket endpoints
- Server → Dashboard API: mounts · Registers reporting endpoints
- Auth API → Auth Logic: calls · Delegates auth requests to business logic
- Events API → Event Logic: calls · Delegates event requests to business logic
- Purchases API → Purchase Logic: calls · Delegates checkout flow to business logic
- Tickets API → Ticket Logic: calls · Delegates ticket requests to business logic
- Dashboard API → Metrics Logic: calls · Delegates metrics requests to business logic
- Auth Logic → User Model: uses · Reads and writes user records
- Event Logic → Event Model: uses · Reads and writes event records
- Purchase Logic → Purchase Model: uses · Persists purchase transactions
- Purchase Logic → Ticket Model: issues · Creates ticket records after purchase
- Ticket Logic → Ticket Model: uses · Fetches issued tickets
- Metrics Logic → Event Model: aggregates · Builds metrics from event and sales data
- App Shell → Auth State: uses · Shares login state across the SPA
- App Shell → API Client: calls · Uses API clients for backend requests
- App Shell → Pages: renders · Composes the main page flows
- App Shell → UI Kit: uses · Reuses common UI building blocks
- API Client → Auth API: auth api · Calls auth endpoints
- API Client → Events API: events api · Calls event endpoints
- API Client → Purchases API: checkout api · Calls purchase endpoints
- API Client → Tickets API: tickets api · Calls ticket endpoints
- API Client → Dashboard API: dashboard api · Calls reporting endpoints
- Compose → Schema: provisions · Starts PostgreSQL with initialized schema/data
- DB Conn → Schema: depends on · Uses the defined schema and seed data
- CI → Server: validates · Runs backend checks in CI
- CI → App Shell: validates · Runs frontend checks in CI