# rafapradana/deltamind architecture

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

- Interactive diagram: https://gitdiagram.com/rafapradana/deltamind
- Repository: https://github.com/rafapradana/deltamind

## Overview

##### Project type and purpose
- DeltaMind is a cross-platform (iOS, Android, Web, Windows, macOS, Linux) Flutter application that serves as an AI-powered personalized study tool.
- It follows a full-stack, feature-first architecture: a single Dart/Flutter codebase (client) invoking external services (backend-as-a-service & AI APIs).

##### File structure
- Top-level platform folders (android/, ios/, web/, macos/, windows/, linux/) house native build/config files.
- lib/ is the heart of the app:
- core/: app-wide utilities, constants, routing, theming
- features/: independent feature modules (auth, quiz, analytics, notes, gamification, etc.)
- models/: Dart data classes
- services/: clients for Supabase, Google Gemini, analytics, spaced repetition, etc.
- main.dart: application entry point
- Configuration: pubspec.yaml lists dependencies; .env for SUPABASE_URL, GEMINI_API_KEY.

##### Insights from README
- Uses Riverpod for dependency injection & state management.
- Feature-first modules encapsulate UI, controllers, any per-feature services.
- External systems:
- Supabase (Auth, Storage, Postgres)
- Google Gemini AI API
- Syncfusion PDF processing

a. Main components
- Client (Flutter App)
- Presentation/UI Layer (Widgets & Pages)
- State Management & Controllers (Riverpod providers, feature controllers)
- Domain Layer (Models & Business Logic in services)
- External Backend Services
- Supabase (Postgres DB, Auth, Storage, Realtime)
- Google Gemini AI API
- Third-party Libraries
- Syncfusion PDF
- HTTP client for API calls
b. Relationships & interactions
- User taps UI → Flutter Widgets invoke Feature Controllers → Controllers call Services → Services perform HTTP/RPC to Supabase or Gemini → Responses flow back up to update state → UI re-renders.
- -taking and quiz data persist to Supabase; AI quiz generation & feedback via Gemini.
c. Architectural patterns & principles
- Layered Architecture: Presentation → Application (controllers/providers) → Domain (services/models) → Infrastructure (external APIs)
- Feature-first modularization for scalability and maintainability
- Dependency Injection via Riverpod
d. Key technologies & frameworks
- Flutter & Dart
- Riverpod (State/DI)
- Supabase Dart SDK
- HTTP/Dio for REST calls
- Google Gemini API
- Syncfusion Flutter PDF

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Flutter Client"
        direction TB
        EntryPoint["main.dart"]:::client
        subgraph "Core"
            direction TB
            SupabaseConfig["SupabaseConfig"]:::client
            GeminiConfig["GeminiConfig"]:::client
            AppRouter["AppRouter"]:::client
            AuthMiddleware["AuthMiddleware"]:::client
            AppColors["AppColors"]:::client
            AppTheme["AppTheme"]:::client
            AppConstants["Constants"]:::client
        end
        subgraph "Models"
            direction TB
            Models["Domain Models"]:::logic
        end
        subgraph "Services"
            direction TB
            SupabaseService["SupabaseService"]:::logic
            GeminiService["GeminiService"]:::logic
            AnalyticsService["AnalyticsService"]:::logic
            QuizService["QuizService"]:::logic
            ReviewService["ReviewService"]:::logic
            NotesService["NotesService"]:::logic
            RecommendationService["RecommendationService"]:::logic
            SpacedRepetitionService["SpacedRepetitionService"]:::logic
            StreakService["StreakService"]:::logic
        end
        subgraph "Controllers (Riverpod)"
            direction TB
            AuthController["AuthController"]:::logic
            QuizController["QuizController"]:::logic
            QuizAttemptController["QuizAttemptController"]:::logic
            AnalyticsController["AnalyticsController"]:::logic
            NotesController["NotesController"]:::logic
            GamificationController["GamificationController"]:::logic
        end
        subgraph "UI Layer"
            direction TB
            AuthUI["Auth Pages"]:::client
            QuizUI["Quiz Pages"]:::client
            AnalyticsUI["Analytics Page"]:::client
            NotesUI["Notes Pages"]:::client
            GamificationUI["Gamification Pages"]:::client
            DashboardUI["Dashboard Page"]:::client
            HistoryUI["History Page"]:::client
            NavigationUI["Scaffold with Nav Bar"]:::client
            ProfileUI["Profile Page"]:::client
            ReviewsUI["Reviews Pages"]:::client
            OnboardingUI["Onboarding Page"]:::client
            SplashUI["Splash Screen"]:::client
            SharedWidgets["Shared Widgets"]:::client
        end
    end

    Supabase["Supabase (Auth, DB, Storage)"]:::external
    Gemini["Google Gemini AI API"]:::external
    Syncfusion["Syncfusion PDF Processor"]:::external

    AuthUI -->|"invoke"| AuthController
    QuizUI -->|"invoke"| QuizController
    AnalyticsUI -->|"invoke"| AnalyticsController
    NotesUI -->|"invoke"| NotesController
    GamificationUI -->|"invoke"| GamificationController
    UIComponents((UI Layer)) -.->|uses| SharedWidgets

    AuthController -->|"calls"| SupabaseService
    QuizController -->|"calls"| QuizService
    QuizAttemptController -->|"calls"| ReviewService
    AnalyticsController -->|"calls"| AnalyticsService
    NotesController -->|"calls"| NotesService
    GamificationController -->|"calls"| StreakService

    SupabaseService -->|"uses"| Models
    GeminiService -->|"uses"| Models
    AnalyticsService -->|"uses"| Models
    QuizService -->|"uses"| Models
    ReviewService -->|"uses"| Models
    NotesService -->|"uses"| Models
    RecommendationService -->|"uses"| Models
    SpacedRepetitionService -->|"uses"| Models
    StreakService -->|"uses"| Models

    SupabaseService -->|HTTP| Supabase
    GeminiService -->|HTTP| Gemini
    NotesService -.->|optional PDF upload| Syncfusion

    classDef client fill:#cce5ff,stroke:#004085,color:#004085
    classDef logic fill:#d4edda,stroke:#155724,color:#155724
    classDef external fill:#ffe5b4,stroke:#e69500,color:#e69500

    click EntryPoint "https://github.com/rafapradana/deltamind/blob/main/lib/main.dart"
    click SupabaseConfig "https://github.com/rafapradana/deltamind/blob/main/lib/core/config/supabase_config.dart"
    click GeminiConfig "https://github.com/rafapradana/deltamind/blob/main/lib/core/config/gemini_config.dart"
    click AppRouter "https://github.com/rafapradana/deltamind/blob/main/lib/core/routing/app_router.dart"
    click AuthMiddleware "https://github.com/rafapradana/deltamind/blob/main/lib/core/routing/auth_middleware.dart"
    click AppColors "https://github.com/rafapradana/deltamind/blob/main/lib/core/theme/app_colors.dart"
    click AppTheme "https://github.com/rafapradana/deltamind/blob/main/lib/core/theme/app_theme.dart"
    click AppConstants "https://github.com/rafapradana/deltamind/blob/main/lib/core/constants/app_constants.dart"
    click Models "https://github.com/rafapradana/deltamind/tree/main/lib/models/"
    click SupabaseService "https://github.com/rafapradana/deltamind/blob/main/lib/services/supabase_service.dart"
    click GeminiService "https://github.com/rafapradana/deltamind/blob/main/lib/services/gemini_service.dart"
    click AnalyticsService "https://github.com/rafapradana/deltamind/blob/main/lib/services/analytics_service.dart"
    click QuizService "https://github.com/rafapradana/deltamind/blob/main/lib/services/quiz_service.dart"
    click ReviewService "https://github.com/rafapradana/deltamind/blob/main/lib/features/quiz/quiz_review_service.dart"
    click NotesService "https://github.com/rafapradana/deltamind/blob/main/lib/services/notes_service.dart"
    click RecommendationService "https://github.com/rafapradana/deltamind/blob/main/lib/services/recommendation_service.dart"
    click SpacedRepetitionService "https://github.com/rafapradana/deltamind/blob/main/lib/services/spaced_repetition_service.dart"
    click StreakService "https://github.com/rafapradana/deltamind/blob/main/lib/services/streak_service.dart"
    click AuthController "https://github.com/rafapradana/deltamind/blob/main/lib/features/auth/auth_controller.dart"
    click QuizController "https://github.com/rafapradana/deltamind/blob/main/lib/features/quiz/quiz_controller.dart"
    click QuizAttemptController "https://github.com/rafapradana/deltamind/blob/main/lib/features/quiz/quiz_attempt_controller.dart"
    click AnalyticsController "https://github.com/rafapradana/deltamind/blob/main/lib/features/analytics/analytics_controller.dart"
    click NotesController "https://github.com/rafapradana/deltamind/blob/main/lib/features/notes/notes_controller.dart"
    click GamificationController "https://github.com/rafapradana/deltamind/blob/main/lib/features/gamification/gamification_controller.dart"
    click AuthUI "https://github.com/rafapradana/deltamind/blob/main/lib/features/auth/login_page.dart"
    click QuizUI "https://github.com/rafapradana/deltamind/tree/main/lib/features/quiz/"
    click AnalyticsUI "https://github.com/rafapradana/deltamind/blob/main/lib/features/analytics/analytics_page.dart"
    click NotesUI "https://github.com/rafapradana/deltamind/blob/main/lib/features/notes/notes_list_page.dart"
    click GamificationUI "https://github.com/rafapradana/deltamind/blob/main/lib/features/gamification/achievements_page.dart"
    click DashboardUI "https://github.com/rafapradana/deltamind/blob/main/lib/features/dashboard/dashboard_page.dart"
    click HistoryUI "https://github.com/rafapradana/deltamind/blob/main/lib/features/history/history_page.dart"
    click NavigationUI "https://github.com/rafapradana/deltamind/blob/main/lib/features/navigation/scaffold_with_nav_bar.dart"
    click ProfileUI "https://github.com/rafapradana/deltamind/blob/main/lib/features/profile/profile_page.dart"
    click ReviewsUI "https://github.com/rafapradana/deltamind/blob/main/lib/features/reviews/reviews_page.dart"
    click OnboardingUI "https://github.com/rafapradana/deltamind/blob/main/lib/features/onboarding/onboarding_page.dart"
    click SplashUI "https://github.com/rafapradana/deltamind/blob/main/lib/features/splash/splash_screen.dart"
    click SharedWidgets "https://github.com/rafapradana/deltamind/tree/main/lib/widgets/"
```
