# berzz26/odoo-final-9 architecture

> Architecture diagram of the GitHub repository berzz26/odoo-final-9, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/berzz26/odoo-final-9
- Repository: https://github.com/berzz26/odoo-final-9

## Overview

##### Project type and purpose
- This is a full-stack travel-planning web application (“GlobeTrotter”) that lets authenticated users create multi-city itineraries with stops, activities, budgets, calendars and share them publicly or with friends.
- Tech stack (from README):
- Frontend: Vite + React + Tailwind + shadcn/ui
- Backend: Node.js + Express + TypeScript + Prisma
- Database/Auth/Storage: Supabase (Postgres, RLS, Buckets)

##### File structure
Top level:
- backend/ – Express API in TypeScript using Prisma ORM
– src/routes → controller endpoints for auth, trips, stops, budgets, activities, chat, community, uploads
– src/controllers → business logic entry points
– src/services → data-access + domain logic (calls Prisma client)
– src/middlewares → JWT auth, role-based access (RLS), Zod validation
– prisma/schema.prisma + seed.ts → database schema & initial data
– config/db.ts + utils/prisma.ts → Prisma initialization
- frontend/ – React SPA
– src/pages → dynamic route pages (Login, Signup, Dashboard, TripDetails, Community, etc.)
– src/components/ui → design system (avatar, button, input, calendar, card, etc.)
– src/lib/utils.js → shared JS utilities
– public/index.html + Vite config → build & serve steps

##### Pull additional architectural insights from README
- JWT authentication via Supabase
- Users, Trips, Stops, Activities, Budgets modeled in a relational DB
- Supabase Storage Buckets for avatar & other file uploads
- Real-time/community feed & chat likely via polling or websockets (chat.controller)
- Responsive UI with optimistic updates & skeleton loaders

a. Main components
1. Browser client (React SPA)
2. CDN / Static asset host (delivers index.html, JS bundles, CSS)
3. Backend API (Express/TypeScript)
4. Database (Supabase Postgres via Prisma)
5. Auth & RLS (Supabase Auth service)
6. Storage (Supabase Buckets for avatars & trip media)
7. Optional: Real-time chat/message broker (if using websockets or polling)
b. Relationships & data flows
- User → Browser → loads SPA from CDN
- SPA ↔ Supabase Auth (sign-up, sign-in, JWT issuance)
- After login, SPA calls Backend API (/api/auth, /api/trips, /api/uploads, etc.) with JWT
- Backend verifies JWT (middleware) then:
- Calls Prisma client → Postgres DB for CRUD on users, trips, stops, activities, budgets
- Calls Supabase Storage API (or internal upload service) for file uploads
- Backend may publish/subscribe chat messages (WebSocket or long-polling)
c. Architectural patterns & principles
- Layered architecture on backend: Routes → Controllers → Services → Data (Prisma)
- Zod for request validation at the boundary
- Middleware chain enforcing authentication & RBAC
- Single-page application on frontend with componentized UI (atomic design via shadcn/ui)
- Externalizing configuration (env vars for Supabase, DB URL)
d. Key technologies to annotate
- React, Vite, Tailwind, shadcn/ui
- Express, TypeScript, Prisma, Zod, JWT, Multer (upload)
- Supabase (Auth, Postgres, Storage, RLS)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Domain
    subgraph "Client Domain" 
        direction TB
        Browser["React SPA"]:::frontend
        Vite["Vite Config"]:::frontend
        HTML["Index.html"]:::frontend
        UI["UI Design System"]:::frontend
        Components["Shared UI Components"]:::frontend
        Pages["Frontend Pages"]:::frontend
        Utils["Frontend Utilities"]:::frontend
    end

    %% API Domain
    subgraph "API Domain"
        direction TB
        Server["Express API\n(server.ts)"]:::backend
        Middlewares["Middleware Chain\n(auth, rbac, zod)"]:::backend
        Routes["API Routing Layer"]:::backend
        Controllers["Controllers"]:::backend
        Services["Services"]:::backend
        Schemas["Zod Schemas"]:::backend
        PrismaUtil["Prisma Client Utility"]:::backend
        DBConfig["DB Config"]:::backend
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        direction TB
        Postgres[(PostgreSQL)]:::database
    end

    %% External Services
    subgraph "External Services"
        direction TB
        AuthService["Supabase Auth"]:::external
        Storage["Supabase Storage"]:::external
    end

    %% File modules
    subgraph "Modules"
        direction TB
        AuthRoutes["Auth Module\nRoutes"]:::backend
        AuthCtrl["Auth Controller"]:::backend
        AuthSvc["Auth Service"]:::backend
        AuthSchema["Auth Schemas"]:::backend

        TripRoutes["Trips Module\nRoutes"]:::backend
        TripCtrl["Trip Controller"]:::backend
        TripSvc["Trip Service"]:::backend
        TripSchema["Trip Schemas"]:::backend

        UploadRoutes["Upload Module\nRoutes"]:::backend
        UploadCtrl["Upload Controller"]:::backend
        UploadSvc["Upload Service"]:::backend
    end

    %% Client flows
    Browser -->|"serves app"| HTML
    Browser -->|"bundles via"| Vite
    Browser -->|"uses components"| UI
    Browser -->|"uses components"| Components
    Browser -->|"routes to pages"| Pages
    Browser -->|"calls utils"| Utils

    Browser -->|"requests JWT"| AuthService
    Browser -->|"API calls with JWT"| Server

    %% API internal
    Server --> Middlewares
    Middlewares --> Routes
    Routes --> Controllers
    Controllers --> Services
    Controllers --> Schemas
    Services --> PrismaUtil
    PrismaUtil --> Postgres
    Services --> Storage
    Controllers --> AuthService

    %% Module connections
    Routes --> AuthRoutes
    Routes --> TripRoutes
    Routes --> UploadRoutes

    AuthRoutes --> AuthCtrl
    AuthCtrl --> AuthSvc
    AuthCtrl --> AuthSchema

    TripRoutes --> TripCtrl
    TripCtrl --> TripSvc
    TripCtrl --> TripSchema

    UploadRoutes --> UploadCtrl
    UploadCtrl --> UploadSvc

    %% External
    Server -->|"file uploads"| Storage

    %% Click Events
    click Browser "https://github.com/berzz26/odoo-final-9/tree/master/frontend/src"
    click Vite "https://github.com/berzz26/odoo-final-9/blob/master/frontend/vite.config.js"
    click HTML "https://github.com/berzz26/odoo-final-9/blob/master/frontend/index.html"
    click UI "https://github.com/berzz26/odoo-final-9/tree/master/frontend/src/components/ui"
    click Components "https://github.com/berzz26/odoo-final-9/tree/master/frontend/src/components"
    click Pages "https://github.com/berzz26/odoo-final-9/tree/master/frontend/src/pages"
    click Utils "https://github.com/berzz26/odoo-final-9/blob/master/frontend/src/lib/utils.js"
    click Server "https://github.com/berzz26/odoo-final-9/blob/master/backend/src/server.ts"
    click Routes "https://github.com/berzz26/odoo-final-9/tree/master/backend/src/routes"
    click Controllers "https://github.com/berzz26/odoo-final-9/tree/master/backend/src/controllers"
    click Services "https://github.com/berzz26/odoo-final-9/tree/master/backend/src/services"
    click Middlewares "https://github.com/berzz26/odoo-final-9/tree/master/backend/src/middlewares"
    click Schemas "https://github.com/berzz26/odoo-final-9/tree/master/backend/src/schemas"
    click PrismaUtil "https://github.com/berzz26/odoo-final-9/blob/master/backend/src/utils/prisma.ts"
    click DBConfig "https://github.com/berzz26/odoo-final-9/blob/master/backend/src/config/db.ts"
    click AuthRoutes "https://github.com/berzz26/odoo-final-9/blob/master/backend/src/routes/auth.routes.ts"
    click AuthCtrl "https://github.com/berzz26/odoo-final-9/blob/master/backend/src/controllers/auth.controller.ts"
    click AuthSvc "https://github.com/berzz26/odoo-final-9/blob/master/backend/src/services/auth.service.ts"
    click AuthSchema "https://github.com/berzz26/odoo-final-9/blob/master/backend/src/schemas/auth.schema.ts"
    click TripRoutes "https://github.com/berzz26/odoo-final-9/blob/master/backend/src/routes/trip.routes.ts"
    click TripCtrl "https://github.com/berzz26/odoo-final-9/blob/master/backend/src/controllers/trip.controller.ts"
    click TripSvc "https://github.com/berzz26/odoo-final-9/blob/master/backend/src/services/trip.service.ts"
    click TripSchema "https://github.com/berzz26/odoo-final-9/blob/master/backend/src/schemas/trip.schema.ts"
    click UploadRoutes "https://github.com/berzz26/odoo-final-9/blob/master/backend/src/routes/upload.routes.ts"
    click UploadCtrl "https://github.com/berzz26/odoo-final-9/blob/master/backend/src/controllers/upload.controller.ts"
    click UploadSvc "https://github.com/berzz26/odoo-final-9/blob/master/backend/src/services/upload.service.ts"
    click DBConfig "https://github.com/berzz26/odoo-final-9/blob/master/backend/prisma/schema.prisma"
    click DBConfig "https://github.com/berzz26/odoo-final-9/blob/master/backend/prisma/seed.ts"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#00796B,color:#004D40;
    classDef backend fill:#E8F5E9,stroke:#2E7D32,color:#1B5E20;
    classDef database fill:#FFF3E0,stroke:#FB8C00,color:#E65100;
    classDef external fill:#F3E5F5,stroke-dasharray: 5 5,stroke:#8E24AA,color:#6A1B9A;
```
