# sri-dinesh/nexus-flow-hackthonproject architecture

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

- Interactive diagram: https://gitdiagram.com/sri-dinesh/nexus-flow-hackthonproject
- Repository: https://github.com/sri-dinesh/nexus-flow-hackthonproject

## Overview

##### Project type and purpose
- This is a front-end Single-Page Application (SPA) built with Vite + React + TypeScript, styled with Tailwind CSS and shadcn-ui.
- It leverages Supabase as a Backend-as-a-Service (BaaS) for authentication, database, and storage.
- The purpose is a real-estate listing and management portal (“Lovable”) with pages for browsing properties, managing user/company data, contacting agents, and an authenticated dashboard.

##### File structure
- Top-level config: vite.config.ts, tailwind.config.ts, tsconfig*.json, supabase/config.toml
- Public/static assets live under public/
- src/
- main.tsx + index.html: SPA entry point
- components/: all reusable UI building blocks (shadcn-ui primitives under components/ui, domain components under components/, subfolders for company and dashboard features)
- pages/: each route is a React page component (Index, Properties, Dashboard, Auth, etc.)
- contexts/: React Context for authentication state
- hooks/: custom hooks (use-mobile, use-toast)
- services/: business-logic wrappers around Supabase (propertyService, companyService)
- integrations/supabase/: Supabase client instantiation and type definitions
- data/: static mock data files
- lib/utils.ts: general utilities
- No custom server code; backend is entirely Supabase.

##### Readme insights
- Tech stack reaffirmed: Vite, TS, React, shadcn-ui, Tailwind.
- Deployment is done via Lovable platform; custom domain support.

##### Main components
a. Browser (Client)
- React SPA in user’s browser
- UI layer: pages + components
- State management: React Contexts + hooks
b. CDN / Static-hosting
- Vite-built static assets deployed to Lovable (or any static host/CDN)
c. Supabase
- Auth service
- PostgreSQL database
- Storage buckets (for images/media)
- Realtime subscriptions (if used)
d. External services (optional)
- Custom domain DNS
- Third-party analytics or toast notifications (from services like sonner)
e. Data flow & services
- propertyService & companyService modules acting as API clients
- integrations/supabase/client.ts for all low-level calls

##### Relationships & interactions
- Browser SPA → Fetch static assets from CDN → Renders UI
- UI components → Call services → services use Supabase client → talk to Supabase Auth/DB/Storage
- Context/AuthContext wraps components to enforce ProtectedRoute and manage user state
- Hooks (use-toast, use-mobile) enhance UI behaviors
- Static mock data under src/data used for development/fallback

##### Architectural patterns & design principles
- Layered architecture:
- Presentation layer (components, pages)
- Application layer (contexts, hooks)
- Service layer (services, integrations)
- Data layer (Supabase)
- Separation of concerns: UI vs business-logic vs data-access
- Component-based design (React)
- “BaaS” outsourcing backend responsibilities to Supabase
- Strong typing (TypeScript) across layers

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Configuration
    subgraph "Configuration"
        ViteCfg["vite.config.ts"]:::client
        TailwindCfg["tailwind.config.ts"]:::client
        SupConfig["supabase/config.toml"]:::external
    end

    %% Client Side
    subgraph "Client Side"
        Browser["User Browser"]:::client
        subgraph "Presentation Layer"
            Main["src/main.tsx"]:::client
            HTML["index.html"]:::client
            UIprims["src/components/ui/"]:::client
            UIcomp["src/components/"]:::client
            CompanyComp["src/components/company/"]:::client
            DashComp["src/components/dashboard/"]:::client
            Pages["src/pages/"]:::client
            AuthPage["Auth.tsx"]:::client
            PropList["Properties.tsx"]:::client
            PropDetail["PropertyDetail.tsx"]:::client
            DashPage["Dashboard.tsx"]:::client
            Protected["ProtectedRoute.tsx"]:::client
        end
    end

    %% Application Logic
    subgraph "Application Layer"
        AuthCtx["src/contexts/AuthContext.tsx"]:::logic
        HookMobile["src/hooks/use-mobile.tsx"]:::logic
        HookToast["src/hooks/use-toast.ts"]:::logic
    end

    %% Service Layer
    subgraph "Service Layer"
        SupClient["src/integrations/supabase/client.ts"]:::logic
        SupTypes["src/integrations/supabase/types.ts"]:::logic
        PropService["src/services/propertyService.ts"]:::logic
        CompService["src/services/companyService.ts"]:::logic
        Utils["src/lib/utils.ts"]:::logic
    end

    %% Data & Backend
    subgraph "Supabase (BaaS)" 
        AuthSvc[(Supabase Auth)]:::external
        DB[(PostgreSQL DB)]:::external
        Storage[(Storage Buckets)]:::external
        Realtime[(Realtime)]:::external
    end

    %% Static Hosting
    subgraph "Static Hosting/CDN"
        CDN["Vite Build → CDN"]:::external
    end

    %% Connections
    Browser -->|GET static assets| CDN
    CDN -->|serves assets| Browser
    Browser -->|loads| Main
    Main -->|imports| Pages
    Pages -->|route protection| Protected
    Protected -->|wraps| AuthCtx
    Pages --> AuthPage
    Pages --> PropList
    Pages --> PropDetail
    Pages --> DashPage
    Browser -->|uses| AuthCtx
    Main -->|uses hooks| HookMobile
    Main -->|uses hooks| HookToast
    PropList -->|fetches data| PropService
    PropDetail -->|fetches data| PropService
    DashPage -->|fetches data| CompService
    PropService -->|calls| SupClient
    CompService -->|calls| SupClient
    SupClient -->|auth calls| AuthSvc
    SupClient -->|queries| DB
    SupClient -->|stores files| Storage
    SupClient -->|subscribes| Realtime

    %% Click Events
    click Main "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/src/main.tsx"
    click HTML "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/index.html"
    click ViteCfg "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/vite.config.ts"
    click TailwindCfg "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/tailwind.config.ts"
    click SupConfig "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/supabase/config.toml"
    click UIprims "https://github.com/sri-dinesh/nexus-flow-hackthonproject/tree/main/src/components/ui/"
    click UIcomp "https://github.com/sri-dinesh/nexus-flow-hackthonproject/tree/main/src/components/"
    click CompanyComp "https://github.com/sri-dinesh/nexus-flow-hackthonproject/tree/main/src/components/company/"
    click DashComp "https://github.com/sri-dinesh/nexus-flow-hackthonproject/tree/main/src/components/dashboard/"
    click Protected "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/src/components/ProtectedRoute.tsx"
    click Pages "https://github.com/sri-dinesh/nexus-flow-hackthonproject/tree/main/src/pages/"
    click AuthPage "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/src/pages/Auth.tsx"
    click PropList "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/src/pages/Properties.tsx"
    click PropDetail "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/src/pages/PropertyDetail.tsx"
    click DashPage "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/src/pages/Dashboard.tsx"
    click AuthCtx "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/src/contexts/AuthContext.tsx"
    click HookMobile "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/src/hooks/use-mobile.tsx"
    click HookToast "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/src/hooks/use-toast.ts"
    click SupClient "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/src/integrations/supabase/client.ts"
    click SupTypes "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/src/integrations/supabase/types.ts"
    click PropService "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/src/services/propertyService.ts"
    click CompService "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/src/services/companyService.ts"
    click Utils "https://github.com/sri-dinesh/nexus-flow-hackthonproject/blob/main/src/lib/utils.ts"

    %% Styles
    classDef client fill:#cce5ff,stroke:#0056b3,color:#0056b3;
    classDef logic fill:#d4edda,stroke:#155724,color:#155724;
    classDef external fill:#fff3cd,stroke:#856404,color:#856404;
```
