# souvik9205/eventsync architecture

> Architecture diagram of the GitHub repository souvik9205/eventsync, 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/souvik9205/eventsync
- Repository: https://github.com/souvik9205/eventsync

## Overview

##### Main Components
- Frontend Application: Located under apps/frontend, this Next.js app handles user interactions including authentication, event registration, attendance tracking, QR code scanning, and real-time event updates. It includes a well-organized directory structure for pages, components (modals, navigation bars, forms, etc.), hooks, helpers, and UI components.
- Backend Application: Found in apps/server, it implements the REST API endpoints that power user authentication, event management, attendance verification, OTP verification, scanning, and email notifications. Its structure is modular, separated into controllers, routers, services (business logic), and utilities (for token generation, email sending, and Prisma database connectivity).
- Database/Persistence Layer: Managed via Prisma (prisma/schema.prisma and migration files). This layer is responsible for storing events, user details, attendance records, and more.
- External Services: The application integrates with external services such as Google Calendar for scheduling, email services for OTP verification and confirmation emails, and likely an external QR code service for ticket validation.

##### Relationships and Interactions
- The Frontend communicates with the Backend through RESTful API endpoints. For instance, user authentication calls the authController via authRouter, and event actions interface with the eventController.
- The Backend, in turn, interfaces directly with the Database using Prisma (via the PrismaClient in apps/server/src/utils/PrismaClient.ts) for data persistence.
- The Backend also handles interactions with external services (email and QR code generation/verification integrations).
- Shared packages (like the UI components and ESLint/TS configurations) are used across both the frontend and potentially by parts of the backend to ensure consistency and reusability.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clearly separated frontend and backend domains, each with well-organized submodules (controllers, services, routers on the backend; pages, components, hooks on the frontend).
- MVC (or a similar layered approach) in the backend, where controllers handle request routing, services encapsulate business logic, and models (via Prisma) manage data.
- Component-based design in the frontend, with reusable components, hooks, and utilities.
- Monorepo Structure: Enables sharing of configuration and component libraries; this promotes code reuse and standardizes practices across the different modules of the project.

- Expand the Frontend to show structures such as the authentication modules, event lifecycle pages (creation, admin, user’s view, attendance), and shared UI components from the packages.
- On the side, denote external services integrations (Google Calendar, external email service) that support additional functionalities.
- Finally, include a section for shared configurations under the packages directory.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        FApp["Frontend App (Next.js)"]:::frontend
        subgraph "UI & Helpers"
            UIApp["UI Components (app)"]:::frontend
            UIComp["UI Components (components)"]:::frontend
            Helpers["Helpers"]:::frontend
            Hooks["Hooks"]:::frontend
        end
        FApp --> UIApp
        FApp --> UIComp
        FApp --> Helpers
        FApp --> Hooks
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BServer["Backend Server (API)"]:::backend
        BServer --> Routes["Routes"]:::backend
        Routes --> Controllers["Controllers"]:::backend
        Controllers --> Services["Services"]:::backend
        Services --> Utilities["Utilities"]:::backend
    end

    %% Shared Packages
    subgraph "Shared Packages"
        ESLint["ESLint Config"]:::shared
        TS["TS Config"]:::shared
        SharedUI["Shared UI Library"]:::shared
    end

    %% Database
    Database["Database (Prisma)"]:::db

    %% External Services
    External["External Services"]:::external

    %% Relationships
    FApp ---|"API_call"| BServer
    Services --->|"DB_query"| Database
    Utilities --->|"External_call"| External
    FApp ---|"Uses"| SharedUI
    FApp ---|"Configured_by"| ESLint
    FApp ---|"Configured_by"| TS

    %% Click Events
    click FApp "https://github.com/souvik9205/eventsync/tree/master/apps/frontend"
    click UIApp "https://github.com/souvik9205/eventsync/tree/master/apps/frontend/app/_components"
    click UIComp "https://github.com/souvik9205/eventsync/tree/master/apps/frontend/components/ui"
    click Helpers "https://github.com/souvik9205/eventsync/tree/master/apps/frontend/helper"
    click Hooks "https://github.com/souvik9205/eventsync/tree/master/apps/frontend/hooks"
    click BServer "https://github.com/souvik9205/eventsync/tree/master/apps/server"
    click Routes "https://github.com/souvik9205/eventsync/tree/master/apps/server/src/routes"
    click Controllers "https://github.com/souvik9205/eventsync/tree/master/apps/server/src/controller"
    click Services "https://github.com/souvik9205/eventsync/tree/master/apps/server/src/survice"
    click Utilities "https://github.com/souvik9205/eventsync/tree/master/apps/server/src/utils"
    click Database "https://github.com/souvik9205/eventsync/tree/master/apps/server/prisma"
    click ESLint "https://github.com/souvik9205/eventsync/tree/master/packages/eslint-config"
    click TS "https://github.com/souvik9205/eventsync/tree/master/packages/typescript-config"
    click SharedUI "https://github.com/souvik9205/eventsync/tree/master/packages/ui"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px,color:#004085;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px,color:#155724;
    classDef db fill:#fff3cd,stroke:#856404,stroke-width:2px,color:#856404;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px,color:#721c24;
    classDef shared fill:#e2e3e5,stroke:#6c757d,stroke-width:2px,color:#6c757d;
```
