# discipulusapp/discipulus architecture

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

- Interactive diagram: https://gitdiagram.com/discipulusapp/discipulus
- Repository: https://github.com/discipulusapp/discipulus

## Overview

##### Main Components
- Flutter UI / Presentation Layer:
– This includes all the screens and widgets in the lib/screens and lib/widgets directories. Subsections such as screens/activities, screens/calendar, screens/grades, screens/messages, etc., clearly show the separation of concerns in the UI.
– The design should show how these UIs present data to the user using Material 3 design guidelines.
- Business Logic and Core Services:
– The lib/core directory houses services for background tasks, notifications, offline storage (via isar), routing, and handoff (device syncing).
– Core functionalities like background processing, calendar management, and spotlight search integration should be represented.
- API Integration and Data Model Layer:
– The lib/api directory contains code for interacting with the Magister API (via both real and dummy implementations), along with detailed model definitions in lib/api/models.
– Show how the API services provide data to the UI and how the models and routes are structured to support operations like authentication, message retrieval, and grade analytics.
- Local Data & Utilities:
– The lib/models and lib/utils directories handle local data representation, settings management, account handling, and extension methods.
– Local storage (offline usage) is a key aspect, so include a component for the isar-based local storage.
- Platform-specific Integration:
– Each platform directory (android, ios, darwin for macOS, linux, windows) provides the glue between the Flutter app and native code. Represent these as individual blocks that “plug into” the main Flutter module.
– For instance, Android has Kotlin code for widgets and native implementations (e.g., AutoDNDManagerPlugin.kt), while iOS and macOS include specific asset configurations, storyboard files, and Swift components (like NavigatorWidget).
- Third-party Package:
– The packages folder containing the flutter_advanced_drawer repository should be shown as an external reusable module integrated into the Flutter UI.

##### Relationships and Interactions
- The UI layer (screens and widgets) communicates with the business logic layer to retrieve or submit data.
- The API layer provides asynchronous data retrieval from external sources (Magister) and integrates with local services and models.
- Core services (background tasks, notifications) run in parallel, ensuring that offline and background functionalities (e.g., push notification simulation via background processing) are maintained.
- Platform-specific modules serve as bridges between the Flutter core (written in Dart) and the native operating system functionalities like notifications, widget display, and file management.
- Data flows upward from the API and local storage components to the presentation layer, while user interactions propagate downward through controllers and routes defined in lib/core and lib/api/routes.

##### Architectural Patterns and Design Principles
- The project follows a layered architecture with a clear separation between the UI, business logic, and data layers.
- There is evidence of separation of concerns where platform-specific code is isolated from the shared Flutter codebase.
- The use of modular packages (e.g., flutter_advanced_drawer) and a strong emphasis on extensibility and offline capabilities exemplifies principles like modularity and reusability.

##### Relevant Technologies & Frameworks
- Flutter (and Dart) as the primary framework.
- Platform-native languages/environments (Kotlin for Android and Swift for iOS/macOS, C++/CMake for Linux/Windows).
- Material 3 design guidelines for UI consistency.
- Isar for local database storage.
- Integration with external APIs (Magister) and background processing (for notifications and tasks).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Screens["UI Screens"]:::flutter
        Widgets["UI Widgets"]:::flutter
    end

    %% Business Logic & Core Services
    subgraph "Business Logic & Core Services"
        Core["Core Services"]:::core
    end

    %% Data Layer
    subgraph "Data Layer"
        APIService["API Integration (Services)"]:::api
        APIModels["API Models"]:::api
        LocalModels["Local Data (Models)"]:::data
        Utils["Utilities"]:::data
    end

    %% Platform-specific Integration
    subgraph "Platform-specific Integration"
        Android["Android"]:::platform
        iOS["iOS"]:::platform
        macOS["macOS"]:::platform
        Linux["Linux"]:::platform
        Windows["Windows"]:::platform
    end

    %% Third-party Package
    Package["Flutter Advanced Drawer"]:::thirdParty

    %% Connections between layers
    Screens -->|"calls"| Core
    Widgets -->|"calls"| Core

    Core -->|"fetches"| APIService
    Core -->|"fetches"| APIModels
    Core -->|"reads/writes"| LocalModels
    Core -->|"reads/writes"| Utils

    APIService -->|"uses"| APIModels

    Core -->|"nativeCalls"| Android
    Core -->|"nativeCalls"| iOS
    Core -->|"nativeCalls"| macOS
    Core -->|"nativeCalls"| Linux
    Core -->|"nativeCalls"| Windows

    Package -->|"integratedWith"| Screens
    Package -->|"integratedWith"| Widgets

    %% Click Events
    click Screens "https://github.com/discipulusapp/discipulus/tree/main/lib/screens"
    click Widgets "https://github.com/discipulusapp/discipulus/tree/main/lib/widgets"
    click Core "https://github.com/discipulusapp/discipulus/tree/main/lib/core"
    click APIService "https://github.com/discipulusapp/discipulus/tree/main/lib/api"
    click APIModels "https://github.com/discipulusapp/discipulus/tree/main/lib/api/models"
    click LocalModels "https://github.com/discipulusapp/discipulus/tree/main/lib/models"
    click Utils "https://github.com/discipulusapp/discipulus/tree/main/lib/utils"
    click Android "https://github.com/discipulusapp/discipulus/tree/main/android"
    click iOS "https://github.com/discipulusapp/discipulus/tree/main/ios"
    click macOS "https://github.com/discipulusapp/discipulus/tree/main/darwin"
    click Linux "https://github.com/discipulusapp/discipulus/tree/main/linux"
    click Windows "https://github.com/discipulusapp/discipulus/tree/main/windows"
    click Package "https://github.com/discipulusapp/discipulus/tree/main/packages/flutter_advanced_drawer"

    %% Styles
    classDef flutter fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef core fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef api fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef data fill:#F0F4C3,stroke:#827717,stroke-width:2px;
    classDef platform fill:#D1C4E9,stroke:#512DA8,stroke-width:2px;
    classDef thirdParty fill:#FFE0B2,stroke:#E65100,stroke-width:2px;
```
