# mrhacker8468/eontrack architecture

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

- Interactive diagram: https://gitdiagram.com/mrhacker8468/eontrack
- Repository: https://github.com/mrhacker8468/eontrack

## Overview

##### Main Components
- Web Client/UI Layer: This covers the pages and components served to users such as the dynamic booking pages, the dashboard, onboarding, and success pages. The “app” directory and subdirectories like “app/(bookingpage)”, “app/dashboard”, and “app/onboarding” host the various pages.
- UI Component Library: Note the separate “components” directory (and its subdirectory “components/ui”) which contains reusable UI primitives (Buttons, Cards, Dialogs, etc.). These components support consistent styling and behavior across the application.
- API Routes & Server Functions: The “app/api” directory hosts API endpoints for authentication (using NextAuth in the “auth” folders), OAuth exchange (`/api/oauth/exchange`), and upload functionality (`/api/uploadthing`). These endpoints outline the backend services that the front-end will interact with.
- Business Logic & Utility Libraries: The “app/lib” directory includes modules for authentication, database interactions, hooks, integrations with external services (like Nylas), time utilities, and upload handling that abstract away core functionality.
- Database Layer: Although not explicitly shown within the file tree as separate services, the presence of a “prisma” folder with a “schema.prisma” file indicates that the application uses Prisma as an ORM to interact with its database. Show the database as an external component connected to the backend parts.
- Authentication & OAuth: The integration of NextAuth and custom OAuth endpoints (including exchange routes) play a vital role in user authentication and authorization in the application.

- End User (Browser) communicates with the Web Client, which renders dynamic pages (booking pages, dashboard, settings, etc.) driven by Next.js.
- The Web Client interacts with API Routes (via HTTP calls) for authentication, file uploads, and OAuth token exchanges.
- Business logic and utilities (lib modules) support both API endpoints and UI pages.
- The Next.js server infrastructure is also responsible for server-side rendering (where applicable) and routing the requests to the corresponding API handlers.
- A persistent connection to an external Database (managed by Prisma) should be shown, connecting from services in the “app/lib/db.ts” and indirectly referenced by the API endpoints.
- The UI component library is used by various pages to ensure consistent design.

##### Architectural Patterns & Design Principles
- Next.js App Directory Pattern: Highlight the App Directory pattern that organizes both UI logic and API endpoints in a single project.
- Separation of Concerns: Clearly separate presentation (pages and UI components), business logic/utilities (lib), and data access (Prisma, DB connections).
- Dynamic Routing: Note the use of dynamic routing (e.g., [username], [eventUrl], etc.) for user-specific booking pages and dashboard functionality.
- Modularization: The project is split into modules (booking, dashboard, onboarding) which are well encapsulated and interrelated, fostering maintainability.

##### Relevant Technologies & Frameworks
- Next.js: The main framework driving both UI rendering and server-side code including API routes.
- NextAuth: For handling authentication flows, seen in the “auth” folders.
- Prisma: For managing the database schema and interactions.
- Tailwind CSS: Implied by the presence of tailwind.config.ts (used for styling).
- Vercel Deployment: Reflected by deployment guidelines in the README.
- Additional Libraries: Specific libraries like “uploadthing” for file uploads, and integration with external APIs/services (e.g., Nylas).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    CB("Client Browser"):::frontend

    %% Next.js Application
    subgraph "Next.js Application"
        %% UI Layer
        subgraph "UI Layer"
            Booking("Booking Pages"):::frontend
            Dashboard("Dashboard"):::frontend
            Onboarding("Onboarding"):::frontend
            Success("Success Page"):::frontend
            UIComponents("UI Components (Reusable)"):::component
        end
        %% API Layer
        subgraph "API Layer"
            AuthAPI("Auth API (NextAuth)"):::backend
            OAuthAPI("OAuth Exchange API"):::backend
            UploadAPI("Upload API"):::backend
        end
    end

    %% Business Logic & Utilities
    subgraph "Business Logic & Utilities"
        AuthUtil("auth.ts"):::utility
        DBUtil("db.ts"):::utility
        HooksUtil("hooks.ts"):::utility
        NylasUtil("nylas.ts"):::utility
        TimesUtil("times.ts"):::utility
        UploadUtil("uploadthing.ts"):::utility
        ZodUtil("zodSchemas.ts"):::utility
    end

    %% Database
    DB("Database (Prisma ORM)"):::database

    %% Connections from Client Browser to UI Pages
    CB -->|"requests"| Booking
    CB -->|"requests"| Dashboard
    CB -->|"requests"| Onboarding
    CB -->|"requests"| Success

    %% UI pages using UI Components for consistent design
    Booking -->|"uses"| UIComponents
    Dashboard -->|"uses"| UIComponents
    Onboarding -->|"uses"| UIComponents
    Success -->|"uses"| UIComponents

    %% UI Pages calling API Endpoints for backend services
    Booking -->|"apiCall"| AuthAPI
    Dashboard -->|"apiCall"| OAuthAPI
    Onboarding -->|"apiCall"| UploadAPI

    %% API Endpoints invoking Business Logic & Utilities
    AuthAPI -->|"executes"| AuthUtil
    AuthAPI -->|"executes"| DBUtil
    OAuthAPI -->|"executes"| NylasUtil
    UploadAPI -->|"executes"| HooksUtil

    %% Business Logic interacting with external Database
    DBUtil -->|"queries"| DB

    %% Styling Classes
    classDef frontend fill:#CFFFCF,stroke:#333,stroke-width:2px;
    classDef backend fill:#CFCFFF,stroke:#333,stroke-width:2px;
    classDef utility fill:#FFFACD,stroke:#333,stroke-width:2px;
    classDef database fill:#FFD6D6,stroke:#333,stroke-width:2px;
    classDef component fill:#D0F0FF,stroke:#333,stroke-width:2px;

    %% Click Events
    click Booking "https://github.com/mrhacker8468/eontrack/tree/main/app/(bookingpage)"
    click Dashboard "https://github.com/mrhacker8468/eontrack/tree/main/app/dashboard"
    click Onboarding "https://github.com/mrhacker8468/eontrack/tree/main/app/onboarding"
    click Success "https://github.com/mrhacker8468/eontrack/tree/main/app/success"
    click UIComponents "https://github.com/mrhacker8468/eontrack/tree/main/components/ui"
    click AuthAPI "https://github.com/mrhacker8468/eontrack/tree/main/app/api/auth"
    click OAuthAPI "https://github.com/mrhacker8468/eontrack/tree/main/app/api/oauth/exchange"
    click UploadAPI "https://github.com/mrhacker8468/eontrack/tree/main/app/api/uploadthing"
    click AuthUtil "https://github.com/mrhacker8468/eontrack/blob/main/app/lib/auth.ts"
    click DBUtil "https://github.com/mrhacker8468/eontrack/blob/main/app/lib/db.ts"
    click HooksUtil "https://github.com/mrhacker8468/eontrack/blob/main/app/lib/hooks.ts"
    click NylasUtil "https://github.com/mrhacker8468/eontrack/blob/main/app/lib/nylas.ts"
    click TimesUtil "https://github.com/mrhacker8468/eontrack/blob/main/app/lib/times.ts"
    click UploadUtil "https://github.com/mrhacker8468/eontrack/blob/main/app/lib/uploadthing.ts"
    click ZodUtil "https://github.com/mrhacker8468/eontrack/blob/main/app/lib/zodSchemas.ts"
    click DB "https://github.com/mrhacker8468/eontrack/blob/main/prisma/schema.prisma"
```
