# prateek-code-dev/book-my-event architecture

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

- Interactive diagram: https://gitdiagram.com/prateek-code-dev/book-my-event
- Repository: https://github.com/prateek-code-dev/book-my-event

## Overview

##### Primary components
- Client Application:
- Built with React (using Vite and Tailwind CSS), it handles the user interface.
- Contains key elements such as pages (Home, Login, Register, Booking, Event Details), components (project-specific UI pieces like DateSelector, Modal, ReportCard, etc.), state management with Redux slices, routing (ProtectedRoute, PublicRoute), and service layer for API calls.
- Server Application:
- A Node.js/Express backend with clearly defined routes for events, bookings, payments (RazorPay integration), and user management.
- Organized with controllers, models, middleware (for authentication and authorization), and helper functions.
- Includes a configuration for connecting to the database.
- Database:
- While not explicitly named, a DB configuration file suggests a connection to a persistent data store (e.g., MongoDB or another RDBMS).
- External Services:
- RazorPay used for payment integration, as indicated by the razorPayController and route.

##### Relationships
- The Client interacts with the Server via RESTful API calls (services in the client folder call endpoints defined in the server routes).
- The Server processes these requests through controllers, applies business logic, uses middleware for security (validating tokens and admin privileges), and interacts with the database.
- Payment requests are routed to RazorPay-related controllers.
- Redux in the client maintains session/authentication state and global state (e.g., booking and event info).

##### Architectural patterns and design principles
- Separation of concerns:
- Client (UI, state management, external service integration) is kept separate from the Server (business logic, data handling, authentication, and external payment integration).
- Layered architecture:
- In the server side, there’s a clear layering: Routes → Controllers → Models and Helpers.
- Use of middleware in Express to handle authentication and authorization.
- Modular design in the client: distinct directories for components, pages, contexts, routes, and services.

## Diagram (Mermaid)

```mermaid
graph TD
    ClientApp["Client Application"]:::client
    ServerApp["Server Application"]:::server
    Database[(Database)]:::db

    subgraph "External Payment (RazorPay)"
        RPC["RazorPay Controller"]:::payment
        RPR["RazorPay Route"]:::payment
    end

    ClientApp -->|"API_Calls"| ServerApp
    ServerApp -->|"CRUD_Operations"| Database
    ServerApp -->|"Payment_Requests"| RPC
    RPC -->|"Forward_Request"| RPR
    RPR -->|"Payment_Response"| ServerApp

    click ClientApp "https://github.com/prateek-code-dev/book-my-event/tree/main/client/"
    click ServerApp "https://github.com/prateek-code-dev/book-my-event/tree/main/server/"
    click Database "https://github.com/prateek-code-dev/book-my-event/blob/main/server/config/db.js"
    click RPC "https://github.com/prateek-code-dev/book-my-event/blob/main/server/controllers/razorPayController.js"
    click RPR "https://github.com/prateek-code-dev/book-my-event/blob/main/server/routes/razorPayRoute.js"

    classDef client fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef server fill:#FADBD8,stroke:#943126,stroke-width:2px;
    classDef db fill:#D5F5E3,stroke:#28B463,stroke-width:2px;
    classDef payment fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
```
