# efty34/moodscribe architecture

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

- Interactive diagram: https://gitdiagram.com/efty34/moodscribe
- Repository: https://github.com/efty34/moodscribe

## Overview

##### Project Type and Purpose
- This is a cross-platform mobile (and desktop/web) client built with Flutter.
- It’s a “Diary” application featuring user authentication, diary entries, mood tracking, to-do tasks, profile management, and external services (Firebase and a “Gemini” service).

##### File Structure
- Top-level “android”, “ios”, “linux”, “macos”, “windows”, “web” folders: Flutter host platforms.
- “lib/” is the Dart code:
- lib/main.dart – entry point
- lib/auth – authentication wrapper & service
- lib/pages – UI screens (home, login, diary, stats, settings, etc.)
- lib/components – reusable widgets (buttons, charts, drawers, etc.)
- lib/services – business-logic providers (diary, to-do, mood, user, recommendation, etc.)
- lib/firebase – Firebase initialization & wrapper
- lib/mood_buddy/services – external “gemini” AI service client
- lib/notification – local notification controller
- pubspec.yaml / firebase.json – dependencies and Firebase hosting/config.

##### README

1. Sketch four horizontal layers: Presentation, Domain, Data, Platform.
2. Under Presentation, list key pages (HomePage, DiaryEntryPage, TodoPage, ProfilePage).
3. Under Domain, list providers/services (DiaryService, TodoServiceProvider, MoodChartProvider, RecommendationService).
5. Under Platform, show “Flutter Engine” connecting to native code modules for Android, iOS, etc.
– UI → Service calls
– Service → Data (Firebase SDK via platform channel)
– Data responses → Service → UI
– NotificationController → OS notification subsystem
– GeminiService → external AI endpoint

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Entry Point"
        Main["main.dart"]:::platform
    end

    subgraph "Presentation Layer" 
        direction TB
        AuthWrapper["AuthWrapper"]:::ui
        Welcome["Welcome Screen"]:::ui
        Login["Login Screen"]:::ui
        Register["Registration Screen"]:::ui
        Home["Home Screen"]:::ui
        DiaryEntryScreen["Diary Entry Screen"]:::ui
        TodoList["To-Do List Screen"]:::ui
        AddTodo["Add To-Do Screen"]:::ui
        Profile["Profile Screen"]:::ui
        Settings["Settings Screen"]:::ui
        Stats["Statistics Screen"]:::ui
        Category["Category / Recommendation Screen"]:::ui
        Components["Reusable Widgets"]:::ui
    end

    subgraph "Domain / State Layer"
        direction TB
        AuthService["AuthService"]:::domain
        DiaryService["DiaryService"]:::domain
        TodoService["To-Do Service"]:::domain
        TodoProvider["To-Do Service Provider"]:::domain
        MoodChart["Mood Chart Provider"]:::domain
        StreakCal["Streak Calendar Provider"]:::domain
        StressChart["Stress Chart Provider"]:::domain
        Recommendation["RecommendationService"]:::domain
        Favorites["FavoritesService"]:::domain
        ProfileProv["ProfileProvider"]:::domain
        UserService["UserService"]:::domain
    end

    subgraph "Data Layer"
        direction TB
        Firebase["Firebase (Auth, Firestore, Storage)"]:::data
        Notifications["Local Notifications Controller"]:::data
        Gemini["Gemini AI Service"]:::data
    end

    subgraph "Platform Layer"
        direction TB
        FlutterEngine["Flutter Engine"]:::platform
        Host["Host Platforms"]:::platform
    end

    %% Entry to Presentation
    Main --> AuthWrapper
    AuthWrapper --> Welcome
    AuthWrapper --> Login
    AuthWrapper --> Register

    %% UI navigation
    Welcome --> Home
    Home --> DiaryEntryScreen
    Home --> TodoList
    Home --> Stats
    Home --> Category
    Home --> Profile
    Home --> Settings
    TodoList --> AddTodo

    %% UI to Domain calls
    Welcome -->|auth| AuthService
    Login -->|auth| AuthService
    Register -->|auth| AuthService
    DiaryEntryScreen -->|getEntries| DiaryService
    AddTodo -->|addTask| TodoService
    TodoList -->|fetchTasks| TodoProvider
    Stats -->|fetchMoodData| MoodChart
    Stats -->|fetchStressData| StressChart
    Category -->|recommend| Recommendation
    Profile -->|getProfile| ProfileProv
    Settings -->|updatePrefs| UserService

    %% Domain to Data
    AuthService -->|uses| Firebase
    DiaryService -->|reads/writes| Firebase
    TodoService -->|reads/writes| Firebase
    TodoProvider -->|reads| Firebase
    MoodChart -->|reads| Firebase
    StreakCal -->|reads| Firebase
    StressChart -->|reads| Firebase
    Recommendation -->|calls| Gemini
    Favorites -->|reads/writes| Firebase
    ProfileProv -->|reads/writes| Firebase
    UserService -->|reads/writes| Firebase
    Notifications -->|schedules| Host
    Notifications -->|triggers| FlutterEngine

    %% Data back to Domain/UI (async)
    Firebase -.->|streams/futures| DiaryService
    Firebase -.->|streams| AuthService
    Firebase -.->|streams| TodoProvider
    Firebase -.->|data| MoodChart
    Firebase -.->|data| StreakCal
    Firebase -.->|data| StressChart
    Firebase -.->|data| ProfileProv
    Firebase -.->|data| UserService
    Gemini -.->|response| Recommendation
    Notifications -.->|callback| FlutterEngine

    %% Platform interactions
    FlutterEngine -->|platform channels| Firebase
    FlutterEngine -->|plugins| Notifications
    FlutterEngine -->|http/gRPC| Gemini
    FlutterEngine --> Host

    %% Click events
    click Main "https://github.com/efty34/moodscribe/blob/main/lib/main.dart"
    click AuthWrapper "https://github.com/efty34/moodscribe/blob/main/lib/auth/auth_wrapper.dart"
    click AuthService "https://github.com/efty34/moodscribe/blob/main/lib/auth/auth_service.dart"
    click Welcome "https://github.com/efty34/moodscribe/blob/main/lib/pages/welcome_page.dart"
    click Login "https://github.com/efty34/moodscribe/blob/main/lib/pages/login_page.dart"
    click Register "https://github.com/efty34/moodscribe/blob/main/lib/pages/register_page.dart"
    click Home "https://github.com/efty34/moodscribe/blob/main/lib/pages/home_page.dart"
    click DiaryEntryScreen "https://github.com/efty34/moodscribe/blob/main/lib/pages/diary_entry.dart"
    click TodoList "https://github.com/efty34/moodscribe/blob/main/lib/pages/todo_page.dart"
    click AddTodo "https://github.com/efty34/moodscribe/blob/main/lib/pages/add_todo_page.dart"
    click Profile "https://github.com/efty34/moodscribe/blob/main/lib/pages/profile_page.dart"
    click Settings "https://github.com/efty34/moodscribe/blob/main/lib/pages/settings_page.dart"
    click Stats "https://github.com/efty34/moodscribe/blob/main/lib/pages/stats_page.dart"
    click Category "https://github.com/efty34/moodscribe/blob/main/lib/pages/category_page.dart"
    click Components "https://github.com/efty34/moodscribe/tree/main/lib/components/"
    click DiaryEntryCard "https://github.com/efty34/moodscribe/blob/main/lib/components/diary_entry_card.dart"
    click StreakCalendar "https://github.com/efty34/moodscribe/blob/main/lib/components/diary_streak_calendar.dart"
    click DiaryDetail "https://github.com/efty34/moodscribe/blob/main/lib/components/diary_detail_page.dart"
    click DiaryWidgets "https://github.com/efty34/moodscribe/tree/main/lib/components/mood_chart/"
    click TodoWidgets "https://github.com/efty34/moodscribe/tree/main/lib/components/todo/"
    click ProfileWidgets "https://github.com/efty34/moodscribe/tree/main/lib/components/profilepage/"
    click SettingsWidgets "https://github.com/efty34/moodscribe/tree/main/lib/components/settings/"
    click AppDrawer "https://github.com/efty34/moodscribe/tree/main/lib/components/app_drawer/"
    click CustomAppBar "https://github.com/efty34/moodscribe/blob/main/lib/components/custom_app_bar.dart"
    click DiaryService "https://github.com/efty34/moodscribe/blob/main/lib/services/diary_service.dart"
    click TodoService "https://github.com/efty34/moodscribe/blob/main/lib/services/todo_service.dart"
    click TodoProvider "https://github.com/efty34/moodscribe/blob/main/lib/services/todo_service_provider.dart"
    click MoodChart "https://github.com/efty34/moodscribe/blob/main/lib/services/mood_chart_provider.dart"
    click StreakCal "https://github.com/efty34/moodscribe/blob/main/lib/services/streak_calendar_provider.dart"
    click StressChart "https://github.com/efty34/moodscribe/blob/main/lib/services/stress_chart_provider.dart"
    click Recommendation "https://github.com/efty34/moodscribe/blob/main/lib/services/recommendation_service.dart"
    click Favorites "https://github.com/efty34/moodscribe/blob/main/lib/services/favorites_service.dart"
    click ProfileProv "https://github.com/efty34/moodscribe/blob/main/lib/services/profile_provider.dart"
    click UserService "https://github.com/efty34/moodscribe/blob/main/lib/services/user_service.dart"
    click Firebase "https://github.com/efty34/moodscribe/blob/main/lib/firebase/firebase.dart"
    click Notifications "https://github.com/efty34/moodscribe/blob/main/lib/notification/notification_controller.dart"
    click Gemini "https://github.com/efty34/moodscribe/blob/main/lib/mood_buddy/services/gemini_service.dart"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef domain fill:#DFFFD0,stroke:#228B22,color:#228B22
    classDef data fill:#FFE4B5,stroke:#FF8C00,color:#FF8C00
    classDef platform fill:#E0E0E0,stroke:#808080,color:#808080
```
