# niaefeup/uni architecture

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

- Interactive diagram: https://gitdiagram.com/niaefeup/uni
- Repository: https://github.com/niaefeup/uni

## Overview

##### Main System Components

a) Client Layer (Mobile Application)
- Flutter UI Components (under lib/view/)
- State Management (using Provider pattern, under lib/model/providers/)
- Local Storage (under lib/controller/local_storage/)

b) Network Layer
- HTTP Clients (under lib/http/)
- Authentication Controllers (under lib/session/)
- API Integration (under lib/sigarra/)

c) Backend Services
- University Systems (Sigarra)
- Authentication Services (OIDC)
- External Services (bus schedules, restaurants, etc.)

##### Component Relationships

a) Data Flow
- User Interface → Controllers → Network Layer → Backend Services
- Backend Services → Local Storage → UI Components
- Authentication Flow: Login → Session Management → Protected Resources

b) State Management
- Provider Pattern Implementation
- Lazy Loading Components
- Background Workers

##### Architectural Patterns

a) MVC-like Structure
- Models (lib/model/entities/)
- Views (lib/view/)
- Controllers (lib/controller/)

b) Feature Modules
- Academic (exams, schedule, courses)
- Services (library, restaurants, transportation)
- User Management (profile, settings)

##### Technical Implementation Details

Elements:

a) Cross-Platform Components
- Android-specific (packages/uni_app/android/)
- iOS-specific (packages/uni_app/ios/)
- Shared Flutter code (packages/uni_app/lib/)

b) Supporting Services
- Background Workers
- Notifications System
- Local Storage (Database)

**[Mobile Clients]**
- ↓
**[Flutter Application Layer]**
- ↓
**[Controllers & Services Layer]**
- ↓
**[Network & Authentication Layer]**
- ↓
**[External Systems & APIs]**

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        UI["Flutter UI Components"]
        Theme["Theme Management"]
        L10n["Multi-language Support"]
    end

    subgraph StateManagement
        Providers["State Providers"]
        LazyProviders["Lazy Providers"]
        StartupProviders["Startup Providers"]
    end

    subgraph DataLayer
        LocalDB[("Local Storage")]
        Parsers["Data Parsers"]
        Fetchers["Data Fetchers"]
    end

    subgraph NetworkLayer
        HTTPClient["HTTP Clients"]
        Auth["Authentication"]
        APIIntegration["API Integration"]
    end

    subgraph BackgroundServices
        Workers["Background Workers"]
        Notifications["Notifications System"]
    end

    subgraph ExternalSystems
        Sigarra["University Systems"]
        OIDC["Authentication Services"]
        ExtServices["External Services"]
    end

    UI --> Providers
    UI --> Theme
    UI --> L10n
    Providers --> LocalDB
    LazyProviders --> LocalDB
    StartupProviders --> LocalDB
    
    Providers --> HTTPClient
    HTTPClient --> Auth
    Auth --> APIIntegration
    APIIntegration --> ExternalSystems
    
    Fetchers --> HTTPClient
    Fetchers --> Parsers
    Parsers --> LocalDB
    
    Workers --> Notifications
    Workers --> Fetchers
    
    %% Click Events
    click UI "https://github.com/niAEFEUP/uni/tree/develop/packages/uni_app/lib/view/"
    click Theme "https://github.com/niAEFEUP/uni/blob/develop/packages/uni_app/lib/view/theme.dart"
    click L10n "https://github.com/niAEFEUP/uni/tree/develop/packages/uni_app/lib/l10n/"
    click Providers "https://github.com/niAEFEUP/uni/tree/develop/packages/uni_app/lib/model/providers/"
    click LazyProviders "https://github.com/niAEFEUP/uni/tree/develop/packages/uni_app/lib/model/providers/lazy/"
    click StartupProviders "https://github.com/niAEFEUP/uni/tree/develop/packages/uni_app/lib/model/providers/startup/"
    click LocalDB "https://github.com/niAEFEUP/uni/tree/develop/packages/uni_app/lib/controller/local_storage/"
    click Parsers "https://github.com/niAEFEUP/uni/tree/develop/packages/uni_app/lib/controller/parsers/"
    click Fetchers "https://github.com/niAEFEUP/uni/tree/develop/packages/uni_app/lib/controller/fetchers/"
    click HTTPClient "https://github.com/niAEFEUP/uni/tree/develop/packages/uni_app/lib/http/client/"
    click Auth "https://github.com/niAEFEUP/uni/tree/develop/packages/uni_app/lib/session/"
    click APIIntegration "https://github.com/niAEFEUP/uni/tree/develop/packages/uni_app/lib/sigarra/"
    click Workers "https://github.com/niAEFEUP/uni/tree/develop/packages/uni_app/lib/controller/background_workers/"
    click Notifications "https://github.com/niAEFEUP/uni/tree/develop/packages/uni_app/lib/controller/background_workers/notifications/"

    %% Styling
    classDef ui fill:#2196F3,stroke:#1565C0,color:white
    classDef state fill:#4CAF50,stroke:#388E3C,color:white
    classDef data fill:#FFC107,stroke:#FFA000,color:black
    classDef network fill:#F44336,stroke:#D32F2F,color:white
    classDef service fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef external fill:#757575,stroke:#616161,color:white

    class UI,Theme,L10n ui
    class Providers,LazyProviders,StartupProviders state
    class LocalDB,Parsers,Fetchers data
    class HTTPClient,Auth,APIIntegration network
    class Workers,Notifications service
    class Sigarra,OIDC,ExtServices external
```
