# zkbkb/dashucl_archive architecture

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

- Interactive diagram: https://gitdiagram.com/zkbkb/dashucl_archive
- Repository: https://github.com/zkbkb/dashucl_archive

## Overview

##### Project type and purpose
- This is a full-stack mobile application (“DashUCL”), written in SwiftUI for iOS, that presents University-related data (buildings, timetables, spaces, etc.).
- It follows an MVVM (Model-View-ViewModel) front-end structure and uses Supabase serverless functions for authentication and proxying to UCL APIs, backed by a PostgreSQL database.

##### File structure
- Top-level “DashUCL” directory holds:
- App: App entry point and configuration (AppDelegate, DashUCLApp.swift).
- Core: cross-cutting modules—Data, Network, Storage, UI Components, Utilities, Navigation.
- Features: feature-specific folders (Home, Login, Organisation, Search, Settings, Space, Timetable), each containing Views, ViewModels, Models, and Services.
- UI: shared UI components not bound to a specific feature.
- Testing: mocks, test data, test launch utilities and views.
- Resources: images, asset catalogs, LaunchScreen.
- The “supabase” directory contains:
- config.toml and environment example.
- Serverless functions (TypeScript) for “ucl-auth” and “ucl-proxy,” plus shared CORS support.

##### README
- (No content provided.) Inference: The app uses Supabase as BaaS, leverages SwiftUI MVVM, and provides offline caching/persistence.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile App Layer
    subgraph "Mobile App" 
        direction TB
        subgraph "UI Layer" 
            direction TB
            HomeView["HomeView"]:::frontend
            LoginView["LoginView"]:::frontend
            OrganisationView["DepartmentExploreView"]:::frontend
            SearchView["SearchView"]:::frontend
            SettingsView["SettingView"]:::frontend
            SpaceView["SpaceView"]:::frontend
            TimetableView["TimetableView"]:::frontend
            SharedUI["Shared UI Components"]:::frontend
        end
        subgraph "ViewModels"
            direction TB
            HomeVM["HomeViewModel"]:::frontend
            LoginVM["LoginViewModel"]:::frontend
            SearchVM["SearchViewModel"]:::frontend
            SpaceVM["SpaceViewModel"]:::frontend
            TimetableVM["TimetableViewModel"]:::frontend
        end
        subgraph "Core Services"
            direction TB
            NetworkService["NetworkService"]:::frontend
            UCLDataManager["UCLDataManager"]:::frontend
            StaticDataManager["StaticDataManager"]:::frontend
            CacheManager["CacheManager"]:::frontend
            PersistentStorage["PersistentStorage"]:::frontend
            NavigationManager["NavigationManager"]:::frontend
        end
        subgraph "Local Storage"
            direction TB
            DeviceCache["On-device Cache"]:::frontend
            UserDefaults["UserDefaults"]:::frontend
            FileStorage["File Storage"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Supabase Backend"
        direction TB
        subgraph "Functions" 
            direction TB
            AuthFunc["Supabase Function: ucl-auth"]:::backend
            ProxyFunc["Supabase Function: ucl-proxy"]:::backend
            CORS["Shared CORS Module"]:::backend
        end
        DB[(PostgreSQL Database)]:::db
    end

    %% External API
    ExternalAPI["UCL Open Data API"]:::external

    %% Connections
    HomeView -->|"action"| HomeVM
    LoginView -->|"action"| LoginVM
    SearchView -->|"action"| SearchVM
    SpaceView -->|"action"| SpaceVM
    TimetableView -->|"action"| TimetableVM
    OrganisationView -->|"action"| HomeVM

    HomeVM -->|"calls NetworkService (HTTP/JSON)"| NetworkService
    LoginVM -->|"calls NetworkService (HTTP/JSON)"| NetworkService
    SearchVM -->|"calls NetworkService (HTTP/JSON)"| NetworkService
    SpaceVM -->|"calls NetworkService (HTTP/JSON)"| NetworkService
    TimetableVM -->|"calls NetworkService (HTTP/JSON)"| NetworkService

    NetworkService -->|"HTTP/JSON"| AuthFunc
    NetworkService -->|"HTTP/JSON"| ProxyFunc

    AuthFunc -->|"issues JWT token"| ProxyFunc
    ProxyFunc -->|"fetch/write (HTTP/JSON)"| ExternalAPI
    ProxyFunc -->|"read/write (SQL)"| DB

    CacheManager -.->|"cache read/write"| DeviceCache
    CacheManager -.->|"-"| UserDefaults
    PersistentStorage -.->|"persist data"| FileStorage

    %% Click Events
    click HomeView "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Features/Home/HomeView.swift"
    click LoginView "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Features/Login/LoginView.swift"
    click OrganisationView "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Features/Organisation/DepartmentExploreView.swift"
    click SearchView "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Features/Search/SearchView.swift"
    click SettingsView "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Features/Settings/SettingView.swift"
    click SpaceView "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Features/Space/SpaceView.swift"
    click TimetableView "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Features/Timetable/TimetableView.swift"
    click SharedUI "https://github.com/zkbkb/dashucl_archive/tree/main/DashUCL/UI/Components/"
    click HomeVM "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Features/Home/HomeViewModel.swift"
    click LoginVM "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Features/Login/LoginViewModel.swift"
    click SearchVM "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Features/Search/SearchViewModel.swift"
    click SpaceVM "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Features/Space/SpaceViewModel.swift"
    click TimetableVM "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Features/Timetable/TimetableViewModel.swift"
    click NetworkService "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Core/Network/NetworkService.swift"
    click UCLDataManager "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Core/Services/UCLDataManager.swift"
    click StaticDataManager "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Core/Storage/StaticDataManager.swift"
    click CacheManager "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Core/Storage/CacheManager.swift"
    click PersistentStorage "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Core/Storage/PersistentStorage.swift"
    click NavigationManager "https://github.com/zkbkb/dashucl_archive/blob/main/DashUCL/Core/Navigation/NavigationManager.swift"
    click AuthFunc "https://github.com/zkbkb/dashucl_archive/blob/main/supabase/functions/ucl-auth/index.ts"
    click ProxyFunc "https://github.com/zkbkb/dashucl_archive/blob/main/supabase/functions/ucl-proxy/index.ts"
    click CORS "https://github.com/zkbkb/dashucl_archive/blob/main/supabase/functions/_shared/cors.ts"
    click DB "https://github.com/zkbkb/dashucl_archive/blob/main/supabase/config.toml"
    
    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#004D40
    classDef backend fill:#E8F5E9,stroke:#1B5E20,color:#2E7D32
    classDef db fill:#FFF3E0,stroke:#E65100,color:#EF6C00
    classDef external fill:#ECEFF1,stroke:#455A64,color:#607D8B
```
