# thatyearus/udaadaa architecture

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

- Interactive diagram: https://gitdiagram.com/thatyearus/udaadaa
- Repository: https://github.com/thatyearus/udaadaa

## Overview

##### Project type and purpose
- This is a cross-platform Flutter full-stack application (“udaadaa”) for tracking diet, weight, challenges, social feed, and chat functionality.
- The front-end is a Flutter app targeting Android, iOS, Web, macOS, Linux, and Windows.
- The back-end is powered by Supabase (PostgreSQL database + edge functions + RLS).

##### File structure
- Top-level “android”, “ios”, “linux”, “macos”, “windows”, “web” folders: platform-specific Flutter embedding.
- “lib/” folder subdivided into:
- cubit/ + state files: BLoC/Cubit state management.
- data/: network client (Dio).
- service/: notification, shared-preferences.
- models/: domain entities (Profile, Feed, Message, etc.).
- utils/: constants, analytics, theme.
- view/: UI screens organized by feature (onboarding, home, chat, feed, form, etc.).
- widgets/: reusable UI components.
- “supabase/” folder with:
- config.toml, migrations/*.sql: database schema & RLS policies.
- functions/*/index.ts: serverless edge functions for custom logic (e.g., message-push, get-room-id).
- CI workflows in “.github/workflows”: build, staging pipelines.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        UI["Flutter UI (lib/view/)"]:::client
        Widgets["Reusable Widgets (lib/widgets/)"]:::client
    end

    %% State Management Layer
    subgraph "State Management Layer"
        direction TB
        Cubits["Cubits & States (lib/cubit/)"]:::client
    end

    %% Data & Service Layer
    subgraph "Data & Service Layer"
        direction TB
        Dio["Dio HTTP Client (lib/data/dio_client.dart)"]:::client
        SharedPrefs["SharedPreferences (lib/service/shared_preferences.dart)"]:::client
        NotificationSvc["NotificationService (lib/service/notifications/notification_service.dart)"]:::client
        Analytics["Analytics Utility (lib/utils/analytics/analytics.dart)"]:::client
        ThemeUtils["Theme Utilities (lib/utils/theme/)"]:::client
        Nickname["Random Nickname Generator (lib/utils/random_nickname_generator.dart)"]:::client
    end

    %% Backend Layer
    subgraph "Supabase Backend"
        direction TB
        subgraph "Edge Functions"
            direction TB
            GetRoom["GetRoomIdFunction"]:::backend
            Hello["HelloFunction"]:::backend
            MessagePush["MessagePushFunction"]:::backend
            PostInitial["PostInitialChatDataFunction"]:::backend
            ReactionPush["ReactionPushFunction"]:::backend
            StagePost["StagePostInitialChatDataFunction"]:::backend
        end
        Migrations["Migrations & RLS Policies"]:::backend
        Database["PostgreSQL Database"]:::backend
        Storage["Storage Buckets"]:::backend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        FCM["FCM Gateway"]:::external
        AnalyticsEndpoint["Analytics Endpoint"]:::external
    end

    %% CI/CD
    subgraph "CI/CD Pipelines"
        direction TB
        MainCI["GitHub Actions Main (main.yml)"]:::ci
        StagingCI["GitHub Actions Staging (staging.yml)"]:::ci
    end

    %% Connections
    UI -->|"triggers events"| Cubits
    Widgets -->|"used by"| UI
    Cubits -->|"calls"| Dio
    Cubits -->|"reads/writes"| SharedPrefs
    Cubits -->|"requests push"| NotificationSvc
    Cubits -->|"logs to"| Analytics
    Cubits -->|"applies theme"| ThemeUtils
    Cubits -->|"generates nickname"| Nickname
    Dio -->|"calls edge functions / REST"| GetRoom
    Dio -->|"calls edge functions / REST"| Hello
    Dio -->|"calls edge functions / REST"| MessagePush
    Dio -->|"calls edge functions / REST"| PostInitial
    Dio -->|"calls edge functions / REST"| ReactionPush
    Dio -->|"calls edge functions / REST"| StagePost
    GetRoom -->|"queries"| Database
    Hello -->|"queries"| Database
    MessagePush -->|"writes"| Database
    PostInitial -->|"writes"| Database
    ReactionPush -->|"writes"| Database
    StagePost -->|"writes"| Database
    Database -->|"returns data"| Dio
    MessagePush -->|"sends notification"| FCM
    FCM -->|"delivers to"| UI
    Cubits -->|"sends analytics"| AnalyticsEndpoint

    MainCI -->|"build & deploy"| UI
    StagingCI -->|"build & deploy"| UI
    MainCI -->|"deploy functions & migrations"| GetRoom
    MainCI -->|"deploy functions & migrations"| Database
    StagingCI -->|"deploy functions & migrations"| GetRoom
    StagingCI -->|"deploy functions & migrations"| Database

    %% Click Events
    click UI "https://github.com/thatyearus/udaadaa/tree/main/lib/view/"
    click Widgets "https://github.com/thatyearus/udaadaa/tree/main/lib/widgets/"
    click Cubits "https://github.com/thatyearus/udaadaa/tree/main/lib/cubit/"
    click Dio "https://github.com/thatyearus/udaadaa/blob/main/lib/data/dio_client.dart"
    click SharedPrefs "https://github.com/thatyearus/udaadaa/blob/main/lib/service/shared_preferences.dart"
    click NotificationSvc "https://github.com/thatyearus/udaadaa/blob/main/lib/service/notifications/notification_service.dart"
    click Analytics "https://github.com/thatyearus/udaadaa/blob/main/lib/utils/analytics/analytics.dart"
    click ThemeUtils "https://github.com/thatyearus/udaadaa/tree/main/lib/utils/theme/"
    click Nickname "https://github.com/thatyearus/udaadaa/blob/main/lib/utils/random_nickname_generator.dart"
    click GetRoom "https://github.com/thatyearus/udaadaa/blob/main/supabase/functions/get-room-id-by-name/index.ts"
    click Hello "https://github.com/thatyearus/udaadaa/blob/main/supabase/functions/hello/index.ts"
    click MessagePush "https://github.com/thatyearus/udaadaa/blob/main/supabase/functions/message-push/index.ts"
    click PostInitial "https://github.com/thatyearus/udaadaa/blob/main/supabase/functions/post-initial-chat-data/index.ts"
    click ReactionPush "https://github.com/thatyearus/udaadaa/blob/main/supabase/functions/reaction-push/index.ts"
    click StagePost "https://github.com/thatyearus/udaadaa/blob/main/supabase/functions/stage-post-initial-chat-data/index.ts"
    click Migrations "https://github.com/thatyearus/udaadaa/tree/main/supabase/migrations/"
    click MainCI "https://github.com/thatyearus/udaadaa/blob/main/.github/workflows/main.yml"
    click StagingCI "https://github.com/thatyearus/udaadaa/blob/main/.github/workflows/staging.yml"

    %% Styles
    classDef client fill:#cce5ff,stroke:#004085,color:#004085
    classDef backend fill:#d4edda,stroke:#155724,color:#155724
    classDef external fill:#fff3cd,stroke:#856404,color:#856404
    classDef ci fill:#e2e3e5,stroke:#6c757d,color:#6c757d
```
