# anuj-gill/eventspro architecture

> Architecture diagram of the GitHub repository anuj-gill/eventspro, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anuj-gill/eventspro
- Repository: https://github.com/anuj-gill/eventspro

## Overview

##### Main Components
- Frontend (Client):
- Contains UI components (organized into folders such as components, pages, hooks, store, etc.).
- Implements features like user authentication (Google OAuth), event registration, committee management, and visual effects (custom UI components, animated testimonials, backgrounds, etc.).
- Uses Recoil for state management.
- Backend (Server):
- Implements core business logic and APIs divided into controllers, services, and routes (e.g., auth, events, committee, QR code functionalities).
- Includes middleware for error handling, JWT authentication, and role-based access.
- Uses Prisma for ORM to interact with a PostgreSQL database.
- Database:
- PostgreSQL, accessible via Prisma. Represented by the Prisma schema and connected to via the provided DATABASE_URL.
- External Services:
- Google OAuth for authentication.
- Email service (mail utility in the backend) for sending event tickets/notifications.
- Docker is optionally used for containerizing PostgreSQL.

##### Relationships and Interactions
- Frontend and Backend:
- Frontend makes API calls (using Axios defined in the client/api directory) to the backend.
- Backend and Database:
- External Integrations:
- Integration with Google OAuth: The frontend initiates OAuth flows, and the backend validates tokens and manages user sessions.
- Integration with the email service (backend utility for sending emails).

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- The code is clearly separated by responsibilities (UI components, API routes, controllers, services, middleware).
- MVC-like Structure on the Backend:
- Routes, controllers, and services illustrate a modular design.
- Layered Architecture on the Frontend:
- Components, hooks, and state management (Recoil) show thoughtful separation and reusability.

##### Relevant Technologies and Frameworks
- Frontend: React, TypeScript, Tailwind CSS, Vite (as the build tool), Recoil for state management.
- Backend: Node.js, Express.js, TypeScript, Prisma ORM.
- Database: PostgreSQL.
- Other: Docker (for containerized deployment), Google OAuth (for authentication), and additional libraries for QR code generation, mailing, etc.

##### Essential Elements
- Clear Component Labels:
- Components as “Frontend (Client)”, “Backend (Server)”, “Database (PostgreSQL)”, “Google OAuth”, “Email Service”, etc.
- Data flow from the Frontend to API endpoints in the Backend.
- Distinguishing Visuals:

##### Putting It All Together
1. The Presentation Layer (Frontend):
- Displays components, pages, and state management.
2. The Application/Business Logic Layer (Backend):
- Includes grouped functionalities such as authentication, event management, committee management, QR code generation, and error handling middleware.
3. The Data Layer:
- Represents the PostgreSQL database managed via Prisma.
- Communication protocols (HTTP/HTTPS API calls) between the client and server, and note any middleware handling (authentication, authorization via JWT, etc.) on the server.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Client)"
        F1["UI Components"]:::frontend
        F2["API Calls & Services"]:::frontend
        F3["State Management (Recoil & Store)"]:::frontend
        F4["Authentication (Google OAuth & User Auth Forms)"]:::frontend
        F5["Event Management"]:::frontend
        F6["Visual Effects & Custom UI"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Server)"
        B1["API Routes"]:::backend
        B4["Middleware (Error, JWT, Roles)"]:::backend
        B2["Controllers"]:::backend
        B3["Business Logic / Services"]:::backend
        B5["Mail Utility"]:::backend
        B6["QR Controller"]:::backend
        B7["QR Utility"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        DB["PostgreSQL Database"]:::database
    end

    %% External Services
    ext1["Google OAuth"]:::external
    ext2["Email Service"]:::external

    %% Connections between Frontend and Backend
    F2 -->|"HTTPRequests"| B1

    %% Internal Backend Flow
    B1 -->|"uses"| B4
    B4 -->|"routes to"| B2
    B2 -->|"calls"| B3
    B3 -->|"ORMoperations"| DB

    %% External Integrations
    F4 -->|"OAuthInitiation"| ext1
    ext1 -->|"tokenValidation"| B2

    B2 -->|"triggersEmail"| B5
    B5 -->|"deliversEmail"| ext2

    B2 -->|"QRhandling"| B6
    B6 -->|"QRgeneration"| B7

    %% Click Events
    click F1 "https://github.com/anuj-gill/eventspro/tree/main/client/src/components"
    click F2 "https://github.com/anuj-gill/eventspro/tree/main/client/src/api"
    click F3 "https://github.com/anuj-gill/eventspro/tree/main/client/src/store"
    click F4 "https://github.com/anuj-gill/eventspro/tree/main/client/src/components/Auth"
    click F5 "https://github.com/anuj-gill/eventspro/tree/main/client/src/components/Event"
    click F6 "https://github.com/anuj-gill/eventspro/tree/main/client/src/components/ui"
    click B1 "https://github.com/anuj-gill/eventspro/tree/main/server/src/routes"
    click B2 "https://github.com/anuj-gill/eventspro/tree/main/server/src/controllers"
    click B3 "https://github.com/anuj-gill/eventspro/tree/main/server/src/services"
    click B4 "https://github.com/anuj-gill/eventspro/tree/main/server/src/middlewares"
    click DB "https://github.com/anuj-gill/eventspro/blob/main/server/prisma/schema.prisma"
    click B5 "https://github.com/anuj-gill/eventspro/blob/main/server/src/util/mail.ts"
    click B6 "https://github.com/anuj-gill/eventspro/blob/main/server/src/controllers/qrController.ts"
    click B7 "https://github.com/anuj-gill/eventspro/blob/main/server/src/util/qrCode.ts"

    %% Styles
    classDef frontend fill:#FAD4D4,stroke:#C0392B,stroke-width:2px;
    classDef backend fill:#D6EAF8,stroke:#2874A6,stroke-width:2px;
    classDef database fill:#D5F5E3,stroke:#27AE60,stroke-width:2px,stroke-dasharray: 5,5;
    classDef external fill:#FCF3CF,stroke:#F1C40F,stroke-width:2px;
```
