# dharmesh53/havns architecture

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

- Interactive diagram: https://gitdiagram.com/dharmesh53/havns
- Repository: https://github.com/dharmesh53/havns

## Overview

##### Main Components
- Client/Browser: Represents the end-user interface that interacts with the application via pages (e.g., homepage, signin, signup, dashboard, hall details).
- Next.js Frontend: Built using React, this renders UI components including halls listings, maps (using Leaflet), image components, and review sections.
- API Backend: The Next.js API routes (under app/api) handle business logic such as authentication, booking management, hall details, user actions, reviews, and more.
- Database/Data Models: The “models” directory contains definitions (hall, meeting, photos, review, user) that likely interface with a persistence layer.
- External Integrations:
- Stripe for payment processing.
- Zoom integration for virtual tour management.
- Cloudinary (mentioned in the README) for handling hall images.
- Leaflet (in components/map) for map integration.
- Possibly Redis for caching/fast lookups, as indicated in utils/redis.js.
- Additional Services: Mail and token management in utils for sending emails and authentication purposes.

a. Frontend (Client:
- UI pages like dashboard, private pages for host actions (booking, listing, meeting requests) and public pages for hall information.
b. API Layer:
- Out the directory structure under app/api with relevant endpoints (auth, booking, zoom, stripe, wishlist, etc.). Each route corresponds to a service (e.g., authentication routes, booking endpoints, hall data CRUD operations).
c. Data Storage:
- A DB or persistence layer associated with the models. Represent how API endpoints read/write data to these models.
d. External Services:
- API back-end to external systems like Stripe for checkout, Zoom for meeting management, and Cloudinary for image storage.
- Integration with mapping services (Leaflet) for hall location details.
e. Context & State Management:
- That React context and hooks (as seen in the context/ and hooks/ directories) manage state that is shared across components.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project cleanly separates frontend presentation (components and pages) from API logic.
- Modular API: Each API endpoint has its own route.js file and follows a modular structure (authentication, booking, meeting, etc.).
- Server-Side Rendering (SSR) and Client-Side Routing: Given that it’s a Next.js application, some pages are pre-rendered, while others might be client-managed.
- External integrations are abstracted through util functions (e.g., sendmail.js, token.js) ensuring loose coupling.

##### Elements
- Clear labels for:
- Client Browser / UI (Next.js pages, React components such as Nav, Feed, Hallcard)
- API Backend Layers (each API folder such as auth, booking, zoom, stripe)
- Database models (hall.js, user.js, etc.)
- External integrations (Stripe, Zoom, Cloudinary, Leaflet maps)
- From client to API endpoints
- From API endpoints to Database and External Services

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Layer
    subgraph "Client Layer"
        UI1["Homepage"]:::client
        UI2["Dashboard"]:::client
        UI3["Hall Details"]:::client
        UI4["Signin"]:::client
        UI5["Signup"]:::client
        UI6["Verify"]:::client
    end

    %% Next.js Frontend
    subgraph "Next.js Frontend"
        FE1["Components"]:::frontend
        FE2["Context Provider"]:::frontend
    end

    %% API Backend
    subgraph "API Backend"
        API1["Auth API"]:::api
        API2["Booking API"]:::api
        API3["Hall API"]:::api
        API4["Meeting API"]:::api
        API5["Review API"]:::api
        API6["Wishlist API"]:::api
        API7["Zoom API"]:::api
        API8["Stripe API"]:::api
    end

    %% Data Storage
    subgraph "Data Storage"
        DB["Database Models"]:::db
    end

    %% External Integrations
    subgraph "External Integrations"
        EXT1["Stripe Payment Gateway"]:::external
        EXT2["Zoom Virtual Tour API"]:::external
        EXT3["Cloudinary Image Service"]:::external
        EXT4["Leaflet Map Service"]:::external
    end

    %% Additional Services
    subgraph "Additional Services"
        UTIL1["Redis Caching"]:::util
        UTIL2["Email & Token Management"]:::util
    end

    %% Relationships from Client to Frontend
    UI1 -->|"renders"| FE1
    UI2 -->|"renders"| FE1
    UI3 -->|"renders"| FE1
    UI4 -->|"renders"| FE1
    UI5 -->|"renders"| FE1
    UI6 -->|"renders"| FE1

    %% Frontend calls API Backend endpoints
    FE1 -->|"fetches"| API1
    FE1 -->|"fetches"| API2
    FE1 -->|"fetches"| API3
    FE1 -->|"fetches"| API4
    FE1 -->|"fetches"| API5
    FE1 -->|"fetches"| API6
    FE1 -->|"fetches"| API7
    FE1 -->|"fetches"| API8

    %% API Backend to Data Storage
    API1 -->|"CRUD"| DB
    API2 -->|"CRUD"| DB
    API3 -->|"CRUD"| DB
    API4 -->|"CRUD"| DB
    API5 -->|"CRUD"| DB
    API6 -->|"CRUD"| DB

    %% API Backend to External Integrations
    API7 -->|"calls"| EXT2
    API8 -->|"calls"| EXT1
    API3 -->|"uploads"| EXT3

    %% Frontend Map Integration
    FE1 -->|"integrates"| EXT4

    %% API Backend to Additional Services
    API1 -->|"authToken"| UTIL2
    API2 -->|"cache"| UTIL1

    %% Styles
    classDef client fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef frontend fill:#D6EAF8,stroke:#1B4F72,stroke-width:2px;
    classDef api fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef db fill:#82E0AA,stroke:#28B463,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef util fill:#CCD1D1,stroke:#5D6D7E,stroke-width:2px;

    %% Click Events for Client/Browser UI Pages
    click UI1 "https://github.com/dharmesh53/havns/blob/master/app/page.jsx"
    click UI2 "https://github.com/dharmesh53/havns/tree/master/app/dashboard"
    click UI3 "https://github.com/dharmesh53/havns/tree/master/app/hall"
    click UI4 "https://github.com/dharmesh53/havns/tree/master/app/signin"
    click UI5 "https://github.com/dharmesh53/havns/tree/master/app/signup"
    click UI6 "https://github.com/dharmesh53/havns/tree/master/app/verify"
    click UI1 "https://github.com/dharmesh53/havns/tree/master/app/"

    %% Click Events for Next.js Frontend Components & Context
    click FE1 "https://github.com/dharmesh53/havns/tree/master/components/"
    click FE1 "https://github.com/dharmesh53/havns/blob/master/components/Nav.jsx"
    click FE1 "https://github.com/dharmesh53/havns/blob/master/components/Hallcard.jsx"
    click FE1 "https://github.com/dharmesh53/havns/blob/master/components/map/map.jsx"
    click FE2 "https://github.com/dharmesh53/havns/blob/master/context/Provider.js"

    %% Click Events for API Backend Endpoints
    click API1 "https://github.com/dharmesh53/havns/tree/master/app/api/auth"
    click API2 "https://github.com/dharmesh53/havns/tree/master/app/api/booking"
    click API3 "https://github.com/dharmesh53/havns/tree/master/app/api/hall"
    click API4 "https://github.com/dharmesh53/havns/tree/master/app/api/meeting"
    click API5 "https://github.com/dharmesh53/havns/tree/master/app/api/review"
    click API6 "https://github.com/dharmesh53/havns/tree/master/app/api/wishlist"
    click API7 "https://github.com/dharmesh53/havns/tree/master/app/api/zoom"
    click API8 "https://github.com/dharmesh53/havns/tree/master/app/api/stripe"
    click API8 "https://github.com/dharmesh53/havns/tree/master/app/api/stripe/checkout"
    click API8 "https://github.com/dharmesh53/havns/tree/master/app/api/stripe/confirmation"

    %% Click Events for Database/Data Models
    click DB "https://github.com/dharmesh53/havns/tree/master/models/"
    click DB "https://github.com/dharmesh53/havns/blob/master/models/hall.js"
    click DB "https://github.com/dharmesh53/havns/blob/master/models/meeting.js"
    click DB "https://github.com/dharmesh53/havns/blob/master/models/photos.js"
    click DB "https://github.com/dharmesh53/havns/blob/master/models/review.js"
    click DB "https://github.com/dharmesh53/havns/blob/master/models/user.js"

    %% Click Events for External Integrations
    click EXT1 "https://github.com/dharmesh53/havns/tree/master/app/api/stripe/checkout"
    click EXT1 "https://github.com/dharmesh53/havns/tree/master/app/api/stripe/confirmation"
    click EXT2 "https://github.com/dharmesh53/havns/tree/master/app/api/zoom/meeting"
    click EXT2 "https://github.com/dharmesh53/havns/tree/master/app/api/zoom/token"
    click EXT3 "https://github.com/dharmesh53/havns/blob/master/actions/uploadActions.js"
    click EXT3 "https://github.com/dharmesh53/havns/tree/master/components/upload/"
    click EXT4 "https://github.com/dharmesh53/havns/blob/master/components/map/leaflet.js"
    click EXT4 "https://github.com/dharmesh53/havns/blob/master/components/map/map.jsx"
    click EXT4 "https://github.com/dharmesh53/havns/blob/master/styles/leaflet.css"

    %% Click Events for Additional Services
    click UTIL1 "https://github.com/dharmesh53/havns/blob/master/utils/redis.js"
    click UTIL2 "https://github.com/dharmesh53/havns/blob/master/utils/sendmail.js"
    click UTIL2 "https://github.com/dharmesh53/havns/blob/master/utils/mailHtml.js"
    click UTIL2 "https://github.com/dharmesh53/havns/blob/master/utils/token.js"
    click UTIL2 "https://github.com/dharmesh53/havns/blob/master/utils/tokenCheck.js"
```
