# tonystagon/reslocate-analytics architecture

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

- Interactive diagram: https://gitdiagram.com/tonystagon/reslocate-analytics
- Repository: https://github.com/tonystagon/reslocate-analytics

## Overview

##### Project type and purpose
- This is a full-stack, data-driven dashboard application (“EduAnalytics Dashboard”) built with React + TypeScript on the frontend and Supabase (Postgres + realtime APIs) on the backend. Its purpose is to provide administrators, students, and policy makers with analytics around student success, funding, and institutional insights.

##### File structure
- Top-level files:
- index.html, src/main.tsx, vite.config.ts → Vite-powered React entry point
- src/App.tsx → Root React component with routing/layout
- src/components → Reusable UI components (Layout, Navigation, KPICard, etc.)
- src/pages → Page-level components (Overview, Universities, Funding, etc.)
- src/hooks → Custom hooks encapsulating data fetching (useSupabaseQuery), business logic (useAdvancedMatching), and domain hooks (useProfile)
- src/lib/supabase.ts → Supabase client initialization
- src/utils → Pure functions for data consistency and profile matching
- supabase/migrations → Database schema migrations
- .env.example → Environment variables for Supabase credentials
- Build & deploy config:
- tailwind.config.js, postcss.config.js → Styling
- Vercel/Netlify readiness implied by static output (Vite)
- package.json scripts: dev, build, preview

##### README for additional insights
- Tech stack confirmed: React 18 + TS, Vite, Tailwind, Lucide React, Supabase, PostgreSQL, Vercel/Netlify.
- Key features map directly to pages under src/pages.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Runtime Flow - Vertical Top to Bottom
    Browser["User Browser"]:::infra
    CDN["Vercel/Netlify CDN"]:::infra
    Browser -->|"HTTP GET index.html"| CDN
    CDN -->|"Serves JS Bundles"| FrontendEntry

    subgraph "Frontend Application" 
        direction TB
        FrontendEntry["index.html<br/>src/main.tsx<br/>vite.config.ts"]:::infra
        FrontendEntry --> AppRoot

        AppRoot["App.tsx (Root Component)"]:::ui
        AppRoot --> PagesLayer
        AppRoot --> ComponentsLayer
        AppRoot --> HooksLayer
        AppRoot --> UtilsLayer
        AppRoot --> SupabaseClient

        subgraph "Pages (UI Layer)" 
            direction TB
            Overview["Overview.tsx"]:::ui
            Universities["Universities.tsx"]:::ui
            Funding["Funding.tsx"]:::ui
            Institutions["Institutions.tsx"]:::ui
            TVET["TVET.tsx"]:::ui
            StudentMarks["StudentMarks.tsx"]:::ui
            Engagement["Engagement.tsx"]:::ui
            SessionHealth["SessionHealth.tsx"]:::ui
            FeatureAdoption["FeatureAdoption.tsx"]:::ui
            Matches["Matches.tsx"]:::ui
            MatchingProfiles["MatchingProfiles.tsx"]:::ui
            UserJourney["UserJourney.tsx"]:::ui
        end

        subgraph "Components (UI Layer)" 
            direction TB
            Layout["Layout.tsx"]:::ui
            Navigation["Navigation.tsx"]:::ui
            KPICard["KPICard.tsx"]:::ui
            SearchableTable["SearchableTable.tsx"]:::ui
            ErrorMessage["ErrorMessage.tsx"]:::ui
            LoadingSpinner["LoadingSpinner.tsx"]:::ui
        end

        subgraph "Hooks (Data & Business Logic)" 
            direction TB
            SupabaseQuery["useSupabaseQuery.ts"]:::logic
            AdvancedMatching["useAdvancedMatching.ts"]:::logic
            ProfileHook["useProfile.ts"]:::logic
        end

        subgraph "Utils (Pure Functions)" 
            direction TB
            DataConsistency["dataConsistency.ts"]:::logic
            ProfileMatching["profileMatching.ts"]:::logic
        end

        supabaseClient["supabase.ts"]:::logic
    end

    CDN --> FrontendEntry
    FrontendEntry --> AppRoot
    PagesLayer -->|renders| HooksLayer
    HooksLayer -->|calls| supabaseAPI
    UtilsLayer -->|processes| HooksLayer

    %% Backend Services
    subgraph "Backend as a Service (Supabase)" 
        direction TB
        supabaseAPI["Supabase API<br/>Auth & Realtime"]:::service
        supabaseAPI -->|SQL Queries| PostgresDB
        migrations["create_user_marks_table.sql"]:::db
    end

    subgraph "Database" 
        PostgresDB["PostgreSQL"]:::db
    end

    supabaseAPI -. "Realtime WebSocket" .-> HooksLayer
    migrations --> PostgresDB

    %% Environment & Config
    .env[".env.example"]:::infra
    tailwind["tailwind.config.js"]:::infra
    postcss["postcss.config.js"]:::infra
    .env --> supabaseClient
    tailwind --> FrontendEntry
    postcss --> FrontendEntry

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef logic fill:#E6FFEA,stroke:#28A745,color:#28A745;
    classDef service fill:#FFF4E5,stroke:#E36209,color:#E36209;
    classDef db fill:#F3E8FF,stroke:#6F42C1,color:#6F42C1;
    classDef infra fill:#F0F0F0,stroke:#666666,color:#666666;

    %% Click Events
    click FrontendEntry "https://github.com/tonystagon/reslocate-analytics/blob/main/index.html"
    click FrontendEntry "https://github.com/tonystagon/reslocate-analytics/blob/main/src/main.tsx"
    click FrontendEntry "https://github.com/tonystagon/reslocate-analytics/blob/main/vite.config.ts"
    click AppRoot "https://github.com/tonystagon/reslocate-analytics/blob/main/src/App.tsx"
    click Layout "https://github.com/tonystagon/reslocate-analytics/blob/main/src/components/Layout.tsx"
    click Navigation "https://github.com/tonystagon/reslocate-analytics/blob/main/src/components/Navigation.tsx"
    click KPICard "https://github.com/tonystagon/reslocate-analytics/blob/main/src/components/KPICard.tsx"
    click SearchableTable "https://github.com/tonystagon/reslocate-analytics/blob/main/src/components/SearchableTable.tsx"
    click ErrorMessage "https://github.com/tonystagon/reslocate-analytics/blob/main/src/components/ErrorMessage.tsx"
    click LoadingSpinner "https://github.com/tonystagon/reslocate-analytics/blob/main/src/components/LoadingSpinner.tsx"
    click Overview "https://github.com/tonystagon/reslocate-analytics/blob/main/src/pages/Overview.tsx"
    click Universities "https://github.com/tonystagon/reslocate-analytics/blob/main/src/pages/Universities.tsx"
    click Funding "https://github.com/tonystagon/reslocate-analytics/blob/main/src/pages/Funding.tsx"
    click Institutions "https://github.com/tonystagon/reslocate-analytics/blob/main/src/pages/Institutions.tsx"
    click TVET "https://github.com/tonystagon/reslocate-analytics/blob/main/src/pages/TVET.tsx"
    click StudentMarks "https://github.com/tonystagon/reslocate-analytics/blob/main/src/pages/StudentMarks.tsx"
    click Engagement "https://github.com/tonystagon/reslocate-analytics/blob/main/src/pages/Engagement.tsx"
    click SessionHealth "https://github.com/tonystagon/reslocate-analytics/blob/main/src/pages/SessionHealth.tsx"
    click FeatureAdoption "https://github.com/tonystagon/reslocate-analytics/blob/main/src/pages/FeatureAdoption.tsx"
    click Matches "https://github.com/tonystagon/reslocate-analytics/blob/main/src/pages/Matches.tsx"
    click MatchingProfiles "https://github.com/tonystagon/reslocate-analytics/blob/main/src/pages/MatchingProfiles.tsx"
    click UserJourney "https://github.com/tonystagon/reslocate-analytics/blob/main/src/pages/UserJourney.tsx"
    click SupabaseQuery "https://github.com/tonystagon/reslocate-analytics/blob/main/src/hooks/useSupabaseQuery.ts"
    click AdvancedMatching "https://github.com/tonystagon/reslocate-analytics/blob/main/src/hooks/useAdvancedMatching.ts"
    click ProfileHook "https://github.com/tonystagon/reslocate-analytics/blob/main/src/hooks/useProfile.ts"
    click DataConsistency "https://github.com/tonystagon/reslocate-analytics/blob/main/src/utils/dataConsistency.ts"
    click ProfileMatching "https://github.com/tonystagon/reslocate-analytics/blob/main/src/utils/profileMatching.ts"
    click supabaseClient "https://github.com/tonystagon/reslocate-analytics/blob/main/src/lib/supabase.ts"
    click migrations "https://github.com/tonystagon/reslocate-analytics/blob/main/supabase/migrations/create_user_marks_table.sql"
    click .env "https://github.com/tonystagon/reslocate-analytics/blob/main/.env.example"
    click tailwind "https://github.com/tonystagon/reslocate-analytics/blob/main/tailwind.config.js"
    click postcss "https://github.com/tonystagon/reslocate-analytics/blob/main/postcss.config.js"
```
