# sahilmor/eventshorizon architecture

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

- Interactive diagram: https://gitdiagram.com/sahilmor/eventshorizon
- Repository: https://github.com/sahilmor/eventshorizon

## Overview

##### Project type and purpose
- This is a full-stack web application built with Next.js (app router).
- It provides browsing and user management functionality for “artists,” “categories,” “events,” “trending events,” “upcoming events,” user “profile,” “login,” “register,” and a “wishlist.”
- It uses Supabase as the backend (authentication + PostgreSQL database + storage), Recoil for client state, and a custom React Context for user data.

##### File structure
- Top-level config and metadata:
- next.config.ts, tsconfig.json, eslint.config.mjs, postcss.config.mjs
- package.json / lockfile
- The “app” directory: each folder (artists, categories, events, trendingevents, upcomingevents, login, register, profile, etc.) corresponds to a Next.js route. Dynamic routes use [id] or [slug].
- Global layout and middleware: src/app/layout.tsx, src/app/middleware.ts
- UI elements under src/components/ui (buttons, cards, dialogs, inputs, etc.)
- Higher-level React components and providers:
- src/components/layout/MainWrapper.tsx
- src/components/providers/RecoilProvider.tsx
- State and context:
- src/atoms/*.ts (Recoil atoms)
- src/context/UserContext.tsx
- Services and utilities:
- src/lib/supabase.ts (Supabase client instantiation)
- src/lib/utils.ts
- src/services/wishlistService.ts
- Database migrations & policies: supabase/migrations/*.sql, supabase-storage-policies.sql

##### README for additional insights
- Bootstrapped with create-next-app
- Uses next/font for optimized font loading
- Deploys on Vercel by default

##### Elements
- Labels: “Browser,” “Next.js Server,” “Supabase Auth,” “PostgreSQL,” “Recoil Store,” “UserContext,” “UI Components,” etc.
→ client requests page
→ server invokes Supabase API
→ Supabase returns data
→ Recoil/Context updates UI
- Blue rectangles for frontend layers
- Green for state management
- Orange for backend services

##### Detail
- Every major directory as a logical subsystem
- How middleware.ts enforces authentication or routing rules
- How supabase.ts abstracts direct DB calls
- Migrations folder as part of “Database schema evolution”

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Browser["Browser / Client"]:::frontend

    %% Next.js App Server
    subgraph "Next.js Server (Vercel)" 
        direction TB

        subgraph "Routing & Pages" 
            direction TB
            RoutingPages["src/app"]:::frontend
            Home["Home / Main Page\npage.tsx"]:::frontend
            Login["Login\npage.tsx"]:::frontend
            Register["Register\npage.tsx"]:::frontend
            Artists["Artist Detail\n[id]/page.tsx"]:::frontend
            Categories["Category Detail\n[id]/page.tsx"]:::frontend
            Events["Event Detail\n[id]/page.tsx"]:::frontend
            Trending["Trending Event\n[id]/page.tsx"]:::frontend
            Upcoming["Upcoming Event\n[id]/page.tsx"]:::frontend
            Profile["Profile\n[slug]/page.tsx"]:::frontend
            RoutingPages --> Home
            RoutingPages --> Login
            RoutingPages --> Register
            RoutingPages --> Artists
            RoutingPages --> Categories
            RoutingPages --> Events
            RoutingPages --> Trending
            RoutingPages --> Upcoming
            RoutingPages --> Profile
        end

        subgraph "Global Config & Middleware"
            direction TB
            Layout["layout.tsx"]:::frontend
            Middleware["middleware.ts"]:::frontend
            GlobalsCSS["globals.css"]:::frontend
        end

        subgraph "UI Components"
            direction TB
            UI["src/components/ui"]:::frontend
        end

        subgraph "Layout Component"
            direction TB
            MainWrapper["MainWrapper.tsx"]:::frontend
        end

        subgraph "State Management"
            direction TB
            RecoilProv["RecoilProvider.tsx"]:::state
            UserAtom["userAtom.ts"]:::state
            ProfileAtom["profileAtom.ts"]:::state
            UserContext["UserContext.tsx"]:::state
        end

        subgraph "Services & Libs"
            direction TB
            SupabaseClient["supabase.ts"]:::backend
            Utils["utils.ts"]:::backend
            WishlistService["wishlistService.ts"]:::backend
        end

        RoutingPages -->|uses| Layout
        Layout --> MainWrapper
        MainWrapper --> UI
        UI --> RecoilProv
        RecoilProv --> UserAtom
        RecoilProv --> ProfileAtom
        UI --> UserContext
        MainWrapper --> SupabaseClient
        SupabaseClient --> WishlistService
        SupabaseClient --> Utils
    end

    %% Backend
    subgraph "Supabase Backend"
        direction TB
        Auth["Auth Service"]:::backend
        DB[(PostgreSQL)]:::database
        Storage["Storage"]:::backend
        Migrations["migrations/*.sql\npolicies.sql"]:::database
    end

    %% Interactions
    Browser -->|"HTTP Request"| RoutingPages
    SupabaseClient -->|"API Calls"| Auth
    SupabaseClient -->|"DB Queries"| DB
    SupabaseClient -->|"Storage Ops"| Storage
    Migrations --> DB

    %% Deploy
    Vercel["Vercel Deployment"]:::deployment
    RoutingPages --> Vercel

    %% Click Events
    click RoutingPages "https://github.com/sahilmor/eventshorizon/tree/main/src/app"
    click Home "https://github.com/sahilmor/eventshorizon/blob/main/src/app/page.tsx"
    click Login "https://github.com/sahilmor/eventshorizon/blob/main/src/app/login/page.tsx"
    click Register "https://github.com/sahilmor/eventshorizon/blob/main/src/app/register/page.tsx"
    click Artists "https://github.com/sahilmor/eventshorizon/blob/main/src/app/artists/[id]/page.tsx"
    click Categories "https://github.com/sahilmor/eventshorizon/blob/main/src/app/categories/[id]/page.tsx"
    click Events "https://github.com/sahilmor/eventshorizon/blob/main/src/app/events/[id]/page.tsx"
    click Trending "https://github.com/sahilmor/eventshorizon/blob/main/src/app/trendingevents/[id]/page.tsx"
    click Upcoming "https://github.com/sahilmor/eventshorizon/blob/main/src/app/upcomingevents/[id]/page.tsx"
    click Profile "https://github.com/sahilmor/eventshorizon/blob/main/src/app/profile/[slug]/page.tsx"
    click Layout "https://github.com/sahilmor/eventshorizon/blob/main/src/app/layout.tsx"
    click Middleware "https://github.com/sahilmor/eventshorizon/blob/main/src/app/middleware.ts"
    click GlobalsCSS "https://github.com/sahilmor/eventshorizon/blob/main/src/app/globals.css"
    click UI "https://github.com/sahilmor/eventshorizon/tree/main/src/components/ui"
    click MainWrapper "https://github.com/sahilmor/eventshorizon/blob/main/src/components/layout/MainWrapper.tsx"
    click RecoilProv "https://github.com/sahilmor/eventshorizon/blob/main/src/components/providers/RecoilProvider.tsx"
    click UserAtom "https://github.com/sahilmor/eventshorizon/blob/main/src/atoms/userAtom.ts"
    click ProfileAtom "https://github.com/sahilmor/eventshorizon/blob/main/src/atoms/profileAtom.ts"
    click UserContext "https://github.com/sahilmor/eventshorizon/blob/main/src/context/UserContext.tsx"
    click SupabaseClient "https://github.com/sahilmor/eventshorizon/blob/main/src/lib/supabase.ts"
    click Utils "https://github.com/sahilmor/eventshorizon/blob/main/src/lib/utils.ts"
    click WishlistService "https://github.com/sahilmor/eventshorizon/blob/main/src/services/wishlistService.ts"
    click Migrations "https://github.com/sahilmor/eventshorizon/blob/main/supabase/migrations/20240101000000_create_wishlist_table.sql"
    click Migrations "https://github.com/sahilmor/eventshorizon/blob/main/supabase/migrations/20240421000000_create_users_table.sql"
    click Migrations "https://github.com/sahilmor/eventshorizon/blob/main/supabase-storage-policies.sql"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef state fill:#E8FFD0,stroke:#6A8A00,color:#6A8A00
    classDef backend fill:#FFE8D0,stroke:#D9730D,color:#D9730D
    classDef database fill:#FFF0B3,stroke:#BF9E00,color:#BF9E00
    classDef deployment fill:#F0F0F0,stroke:#888,color:#888
```
