# rithish08/fyke-connect-india architecture

> Architecture diagram of the GitHub repository rithish08/fyke-connect-india, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rithish08/fyke-connect-india
- Repository: https://github.com/rithish08/fyke-connect-india

## Overview

##### Project type and purpose
- This is a full-stack, single-page application (SPA) built with Vite, React (TypeScript), Tailwind CSS, and shadcn-ui.
- The front end lives entirely in the `src/` folder (components, pages, hooks, contexts, services).
- The “back end” consists of Supabase: a hosted Postgres database + edge functions under `supabase/functions/*`.
- Capacitor and custom services enable mobile/native capabilities (geolocation, notifications).

##### File structure
- Top-level:
- `src/pages/`: route→page mapping
- `src/components/`: reusable UI broken out by feature (common, modals, filters, messaging, etc.)
- `src/contexts/`: React Context providers for auth, jobs, communication, localization
- `src/hooks/`: custom hooks encapsulating state, offline, translation, toast logic
- `src/services/`: wrappers around Capacitor, geolocation, notifications
- `src/integrations/supabase/`: Supabase client initialization + types
- `supabase/functions/`: serverless functions (analytics, moderate-content, send-notification)
- Config/build: `vite.config.ts`, `tailwind.config.ts`, TypeScript configs.

##### README insights
- Confirms Vite/React/TypeScript with shadcn-ui & Tailwind on the front end.
- Deploys via Lovable (automatically builds & publishes).
- Supabase is not explicitly in the README but is clear in the file tree.

##### Detail
- Break the front end into at least three tiers: UI (components/pages), state (contexts/hooks), and services (Supabase client, Capacitor).
- On the back end, separate core database from serverless functions.
- Critical flows: sign-up/auth, job search, messaging, notifications, content moderation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Boundary
    subgraph "Client"
        direction TB
        Browser["Browser / Mobile WebView"]:::external
        App["React SPA\n(src/main.tsx & src/App.tsx)"]:::ui
    end

    Browser -->|"loads"| App

    %% SPA Layers
    subgraph "SPA"
        direction TB

        subgraph "UI Layer"
            direction TB
            Pages["Pages\n(src/pages/)"]:::ui
            Components["UI Components\n(src/components/)"]:::ui
        end

        subgraph "State Management"
            direction TB
            AuthContext["AuthContext"]:::state
            CommunicationContext["CommunicationContext"]:::state
            JobContext["JobContext"]:::state
            LocalizationContext["LocalizationContext"]:::state
            Hooks["Custom Hooks\n(src/hooks/)"]:::state
        end

        subgraph "Services Layer"
            direction TB
            SupabaseClient["Supabase Client\n(src/integrations/supabase/client.ts)"]:::integration
            SupabaseTypes["Supabase Types\n(src/integrations/supabase/types.ts)"]:::integration
            CapacitorService["CapacitorService\n(src/services/capacitorService.ts)"]:::integration
            GeolocationService["GeolocationService\n(src/services/geolocationService.ts)"]:::integration
            NotificationService["NotificationService\n(src/services/notificationService.ts)"]:::integration
        end
    end

    %% Backend Boundary
    subgraph "Back end (Supabase)"
        direction TB
        AuthAPI["Supabase Auth API"]:::backend
        Database[(Postgres Database)]:::backend
        Storage[(Storage Bucket\npublic/lovable-uploads/)]:::backend

        subgraph "Edge Functions"
            direction TB
            AnalyticsFunc["analytics\n(supabase/functions/analytics/index.ts)"]:::backend
            ModerateFunc["moderate-content\n(supabase/functions/moderate-content/index.ts)"]:::backend
            NotifyFunc["send-notification\n(supabase/functions/send-notification/index.ts)"]:::backend
        end
    end

    %% External Services
    GeolocationAPI["Geolocation API"]:::external
    PushAPI["Push Notifications API"]:::external

    %% Flows within SPA
    App --> Pages
    App --> Components

    Pages -->|uses| AuthContext
    Pages -->|uses| JobContext
    Pages -->|uses| CommunicationContext
    Pages -->|uses| LocalizationContext
    Pages -->|uses| Hooks

    Components -->|dispatch| Hooks
    Components -->|reads/writes| AuthContext
    Components -->|reads/writes| JobContext

    AuthContext -->|calls| SupabaseClient
    JobContext -->|calls| SupabaseClient
    CommunicationContext -->|calls| SupabaseClient
    LocalizationContext -->|calls| SupabaseClient
    Hooks -->|invoke| CapacitorService
    Hooks -->|invoke| GeolocationService
    Hooks -->|invoke| NotificationService

    CapacitorService -->|native| GeolocationAPI
    GeolocationService -->|native| GeolocationAPI
    NotificationService -->|native| PushAPI

    SupabaseClient -->|CRUD/Auth| AuthAPI
    SupabaseClient -->|CRUD| Database
    SupabaseClient -->|storage ops| Storage

    %% SPA to Edge Functions
    SupabaseClient -->|HTTP| AnalyticsFunc
    SupabaseClient -->|HTTP| ModerateFunc
    SupabaseClient -->|HTTP| NotifyFunc

    %% Edge Functions to DB or External
    AnalyticsFunc -->|writes events| Database
    ModerateFunc -->|queries| Database
    ModerateFunc -->|calls| SupabaseClient
    NotifyFunc -->|writes| Database
    NotifyFunc -->|triggers| PushAPI

    %% Click Events
    click Pages "https://github.com/rithish08/fyke-connect-india/tree/main/src/pages/"
    click Components "https://github.com/rithish08/fyke-connect-india/tree/main/src/components/"
    click AuthContext "https://github.com/rithish08/fyke-connect-india/blob/main/src/contexts/AuthContext.tsx"
    click CommunicationContext "https://github.com/rithish08/fyke-connect-india/blob/main/src/contexts/CommunicationContext.tsx"
    click JobContext "https://github.com/rithish08/fyke-connect-india/blob/main/src/contexts/JobContext.tsx"
    click LocalizationContext "https://github.com/rithish08/fyke-connect-india/blob/main/src/contexts/LocalizationContext.tsx"
    click Hooks "https://github.com/rithish08/fyke-connect-india/tree/main/src/hooks/"
    click SupabaseClient "https://github.com/rithish08/fyke-connect-india/blob/main/src/integrations/supabase/client.ts"
    click SupabaseTypes "https://github.com/rithish08/fyke-connect-india/blob/main/src/integrations/supabase/types.ts"
    click CapacitorService "https://github.com/rithish08/fyke-connect-india/blob/main/src/services/capacitorService.ts"
    click GeolocationService "https://github.com/rithish08/fyke-connect-india/blob/main/src/services/geolocationService.ts"
    click NotificationService "https://github.com/rithish08/fyke-connect-india/blob/main/src/services/notificationService.ts"
    click AnalyticsFunc "https://github.com/rithish08/fyke-connect-india/blob/main/supabase/functions/analytics/index.ts"
    click ModerateFunc "https://github.com/rithish08/fyke-connect-india/blob/main/supabase/functions/moderate-content/index.ts"
    click NotifyFunc "https://github.com/rithish08/fyke-connect-india/blob/main/supabase/functions/send-notification/index.ts"

    %% Styles
    classDef ui fill:#D7E9F7,stroke:#1E3A8A
    classDef state fill:#DEF7E8,stroke:#047857
    classDef integration fill:#FEF3C7,stroke:#B45309
    classDef backend fill:#F3E8FF,stroke:#6B21A8
    classDef external fill:#E0E7FF,stroke:#4338CA,stroke-dasharray: 5 5
```
