# kruthikb/eventz-planner-frontend architecture

> Architecture diagram of the GitHub repository kruthikb/eventz-planner-frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kruthikb/eventz-planner-frontend
- Repository: https://github.com/kruthikb/eventz-planner-frontend

## Overview

##### Project type and purpose
- EventZ Planner is a full-stack MERN (MongoDB, Express, React, Node.js) event-management application.
- It provides user authentication, event CRUD operations, ticket booking, and QR-code ticket generation.

##### File structure
- Top level: public/ (static assets), src/ (React app), package.json, README.md
- src/components/ holds granular UI components (Add_Event, EventDetailsPage, Login, Signup, Navbar, etc.)
- src/context/AuthContext.js implements React Context for auth state (JWT, user roles)
- No backend code in this repo, but README refers to a separate backend folder with Express, Mongo models, controllers, routes.

##### README for additional insights
- Confirms MERN stack: React frontend, Node/Express API, MongoDB database
- Backend exposes REST endpoints for auth, events, bookings
- QR code generation and ticket PDF creation happen server-side
- JWT for stateless auth

##### Main components & interactions
a. Frontend SPA (React)
- Components talk to AuthContext to store/manage JWT and user info
- Uses fetch or axios to call API endpoints for login, signup, events, booking
b. Backend API (Node.js + Express)
- Auth routes: /api/auth/register, /api/auth/login → issues JWT
- Event routes: /api/events CRUD
- Booking routes: /api/bookings → issues ticket data + QR code
c. Database (MongoDB)
- Collections: users, events, bookings
d. External services
- QR code library or microservice (could be a Node module or external)
- Optional file storage (e.g., AWS S3 for event photos)

Interactions:
1. User → Frontend → AuthContext → Backend.auth → MongoDB
2. Frontend (with JWT header) → Backend.events → MongoDB
3. Frontend → Backend.bookings → MongoDB + QR code generator → returns ticket

##### Architectural patterns & design principles
- Separation of concerns: UI vs API vs Data store
- Stateless REST API with JWT-based auth
- React Context for global auth state
- Componentized UI (atomic components, pages)
- Potential MVC on backend (models/controllers/routes)

##### Detailed capture of essential elements
- Lifecycle of a request: User clicks “Book Ticket” → React Book component dispatches fetch → Express booking route verifies JWT → stores booking in MongoDB → generates QR code → returns ticket JSON → React displays confirmation
- Authentication flow: React Login → API validates credentials → issues JWT → stored in local storage → used by ProtectedRoute component to guard routes
- React Context: all components that need auth state consume AuthContext

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% React Frontend
    subgraph "Browser/React SPA"
        direction TB
        ReactApp["React App"]:::frontend
        AuthContext["AuthContext"]:::frontend
        Add_Event["Add_Event Component"]:::frontend
        EventDetailsPage["EventDetailsPage Component"]:::frontend
        EventBookingPage["EventBookingPage Component"]:::frontend
        EventsList["Events List Component"]:::frontend
        Login["Login Component"]:::frontend
        Signup["Signup Component"]:::frontend
        Navbar["Navbar Component"]:::frontend
        ProtectedRoute["ProtectedRoute Component"]:::frontend
        TicketBooking["TicketBooking Component"]:::frontend
        Contact["Contact Component"]:::frontend
        Dashboard["Dashboard Component"]:::frontend
        StaticAssets["Static Assets"]:::frontend
        Tests["Test Setup & Utilities"]:::frontend
    end

    %% Backend API
    subgraph "Node.js/Express API"
        direction TB
        AuthController["Auth Controller"]:::backend
        EventsController["Events Controller"]:::backend
        BookingsController["Bookings Controller"]:::backend
        QRCodeService["QR Code Service"]:::external
        S3Storage["AWS S3 Storage"]:::external
    end

    %% Database
    subgraph "MongoDB Database"
        direction TB
        MongoDB["MongoDB"]:::database
    end

    %% Interactions
    ReactApp -->|"POST /api/auth/login"| AuthController
    ReactApp -->|"POST /api/auth/register"| AuthController
    ReactApp -->|"GET/POST /api/events"| EventsController
    ReactApp -->|"POST /api/bookings"| BookingsController
    AuthController -->|"read/write users"| MongoDB
    EventsController -->|"read/write events"| MongoDB
    BookingsController -->|"read/write bookings"| MongoDB
    BookingsController -->|"generate QR code"| QRCodeService
    BookingsController -->|"upload photos"| S3Storage

    %% Click Events
    click ReactApp "https://github.com/kruthikb/eventz-planner-frontend/blob/main/src/index.js"
    click AuthContext "https://github.com/kruthikb/eventz-planner-frontend/blob/main/src/context/AuthContext.js"
    click Add_Event "https://github.com/kruthikb/eventz-planner-frontend/blob/main/src/components/Add_Event/add_event.js"
    click EventDetailsPage "https://github.com/kruthikb/eventz-planner-frontend/blob/main/src/components/EventDetailsPage/EventsDetailsPage.js"
    click EventBookingPage "https://github.com/kruthikb/eventz-planner-frontend/blob/main/src/components/EventBookingPage/EventBookingPage.js"
    click EventsList "https://github.com/kruthikb/eventz-planner-frontend/blob/main/src/components/Events/events.js"
    click Login "https://github.com/kruthikb/eventz-planner-frontend/blob/main/src/components/Login/Login.js"
    click Signup "https://github.com/kruthikb/eventz-planner-frontend/blob/main/src/components/Signup/Signup.js"
    click Navbar "https://github.com/kruthikb/eventz-planner-frontend/blob/main/src/components/Navbar/Navbar.js"
    click ProtectedRoute "https://github.com/kruthikb/eventz-planner-frontend/blob/main/src/components/ProtectedRoute.js"
    click TicketBooking "https://github.com/kruthikb/eventz-planner-frontend/blob/main/src/components/TicketBooking/TicketBooking.js"
    click Contact "https://github.com/kruthikb/eventz-planner-frontend/blob/main/src/components/contact/contact.js"
    click Dashboard "https://github.com/kruthikb/eventz-planner-frontend/blob/main/src/components/dashboard/dashboard.js"
    click StaticAssets "https://github.com/kruthikb/eventz-planner-frontend/blob/main/public/index.html"
    click Tests "https://github.com/kruthikb/eventz-planner-frontend/blob/main/src/setupTests.js"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef database fill:#FFDB58,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
