# rushyendra28/kidlink architecture

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

- Interactive diagram: https://gitdiagram.com/rushyendra28/kidlink
- Repository: https://github.com/rushyendra28/kidlink

## Overview

##### Project type and purpose
- Cross-platform Flutter application (“kidlink”) for parental monitoring of children’s device usage.
- Runs on Android, iOS, Web, Linux, macOS, Windows.
- Uses local JSON storage for usage data, Firebase Cloud Messaging (FCM) for push notifications, and likely Firebase Auth for user sign-in.

##### File-structure analysis
a. Top levels:
– android, ios, linux, macos, windows, web: platform runners and build configs
– lib: core Dart code
– test: widget tests
b. Under lib:
– models/: data objects (e.g., UserModel)
– screens/: Flutter UI pages (child/parent login, dashboards, profile)
– services/: abstraction layer for Authentication, Monitoring (screen-time tracking & JSON storage), Notification (FCM integration)
– theme/: shared theme provider
c. No server code: client-only, integrates with external services (FCM, Firebase Auth, local file system).

##### README insights
- Monitors screen time & app usage, stores data as JSON, sends real-time alerts via FCM.
- No proprietary backend–cloud components beyond FCM/Auth.

a. Presentation Layer (Flutter UI)
– Screens (child_login, child_dashboard, parent_dashboard, parent_profile)
b. Domain/Model Layer
– UserModel, other data objects
c. Services/Infrastructure Layer
– AuthService ↔ Firebase Auth
– MonitoringService ↔ Local JSON file storage & device usage APIs
– NotificationService ↔ FCM
d. Platform Runners
– AndroidEmbedder, iOS runner, Web runner, Linux/macOS/Windows runner
e. External Services
– Firebase Authentication (sign-in)
– Firebase Cloud Messaging (push notifications)

##### Interactions and data flows
1. User opens App → Presentation Layer
2. Login screen calls AuthService → Firebase Auth → returns token/user profile
3. After auth, MonitoringService polls device APIs for screen-time/app usage → writes JSON locally
4. ParentDashboard requests usage data → MonitoringService reads JSON → UI renders charts/stats
5. NotificationService registers with FCM → receives push alerts (e.g., excessive use) → UI notifier/pop-up
6. Services layer exposed to UI via Provider (theme_provider.dart implies use of Provider state management).

##### Architectural patterns and design principles
- Layered/Clean Architecture: UI → Domain models → Services → External
- Separation of concerns: services encapsulate all logic for auth, monitoring, notifications.
- Platform abstraction: same Dart code, platform runners handle native integration.
- State management: Provider pattern via theme_provider (could extend to auth & data providers).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        ChildLogin["Child Login Screen"]:::ui
        ChildDashboard["Child Dashboard Screen"]:::ui
        ParentDashboard["Parent Dashboard Screen"]:::ui
        ParentProfile["Parent Profile Screen"]:::ui
    end

    %% Domain Layer
    subgraph "Domain/Model Layer"
        direction TB
        UserModel["UserModel"]:::domain
    end

    %% Services Layer
    subgraph "Services/Infrastructure Layer"
        direction TB
        AuthService["AuthService"]:::service
        MonitoringService["MonitoringService"]:::service
        NotificationService["NotificationService"]:::service
        ThemeProvider["Theme Provider"]:::service
    end

    %% External Services
    subgraph "External Services"
        direction TB
        FirebaseAuth["Firebase Authentication"]:::external
        FCM["Firebase Cloud Messaging"]:::external
        LocalStorage["Local JSON File Storage"]:::storage
    end

    %% Platform Runners
    subgraph "Platform Runners"
        direction TB
        AndroidEmbedder["Android Embedder"]:::platform
        iOSRunner["iOS Runner"]:::platform
        WebRunner["Web Runner"]:::platform
        LinuxRunner["Linux Runner"]:::platform
        macOSRunner["macOS Runner"]:::platform
        WindowsRunner["Windows Runner"]:::platform
    end

    %% Interactions
    ChildLogin -->|"loginRequest"| AuthService
    ParentDashboard -->|"fetchUsageData"| MonitoringService
    ChildDashboard -->|"fetchUsageData"| MonitoringService
    ParentProfile -->|"updateProfile"| AuthService
    AuthService -->|"HTTPS"| FirebaseAuth
    MonitoringService -->|"read/write JSON"| LocalStorage
    MonitoringService -->|pollDeviceAPIs| LocalStorage
    NotificationService -->|"register"| FCM
    FCM -->|"pushNotification"| NotificationService
    NotificationService -->|"notifyUI"| ChildDashboard
    ThemeProvider -->|"stateProvision"| ChildLogin
    ThemeProvider -->|"stateProvision"| ChildDashboard
    ThemeProvider -->|"stateProvision"| ParentDashboard
    ThemeProvider -->|"stateProvision"| ParentProfile

    %% Platform to Engine
    AndroidEmbedder -->|"native integration"| ChildLogin
    iOSRunner -->|"native integration"| ChildLogin
    WebRunner -->|"web integration"| ChildLogin
    LinuxRunner -->|"native integration"| ChildLogin
    macOSRunner -->|"native integration"| ChildLogin
    WindowsRunner -->|"native integration"| ChildLogin

    %% Model Usage
    AuthService -->|"mapUser"| UserModel
    MonitoringService -->|"mapUsageData"| UserModel

    %% Click Events
    click ChildLogin "https://github.com/rushyendra28/kidlink/blob/main/lib/screens/child_login_screen.dart"
    click ChildDashboard "https://github.com/rushyendra28/kidlink/blob/main/lib/screens/child_dashboard.dart"
    click ParentDashboard "https://github.com/rushyendra28/kidlink/blob/main/lib/screens/parent_dashboard.dart"
    click ParentProfile "https://github.com/rushyendra28/kidlink/blob/main/lib/screens/parent_profile_screen.dart"
    click UserModel "https://github.com/rushyendra28/kidlink/blob/main/lib/models/user_model.dart"
    click AuthService "https://github.com/rushyendra28/kidlink/blob/main/lib/services/auth_service.dart"
    click MonitoringService "https://github.com/rushyendra28/kidlink/blob/main/lib/services/monitoring_service.dart"
    click NotificationService "https://github.com/rushyendra28/kidlink/blob/main/lib/services/notification_service.dart"
    click ThemeProvider "https://github.com/rushyendra28/kidlink/blob/main/lib/theme/theme_provider.dart"
    click AndroidEmbedder "https://github.com/rushyendra28/kidlink/blob/main/android/app/src/main/kotlin/com/example/kidlink/MainActivity.kt"
    click iOSRunner "https://github.com/rushyendra28/kidlink/blob/main/ios/Runner/AppDelegate.swift"
    click WebRunner "https://github.com/rushyendra28/kidlink/blob/main/web/index.html"
    click LinuxRunner "https://github.com/rushyendra28/kidlink/blob/main/linux/runner/main.cc"
    click macOSRunner "https://github.com/rushyendra28/kidlink/blob/main/macos/Runner/AppDelegate.swift"
    click WindowsRunner "https://github.com/rushyendra28/kidlink/blob/main/windows/runner/main.cpp"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#0366d6,stroke-width:1px;
    classDef domain fill:#E8D0FF,stroke:#6f42c1,stroke-width:1px;
    classDef service fill:#D0FFD6,stroke:#22863a,stroke-width:1px,stroke-dasharray: 5 5;
    classDef external fill:#FFF5B1,stroke:#d73a49,stroke-width:1px,stroke-dasharray: 2 2;
    classDef storage fill:#FFEFE0,stroke:#e36209,stroke-width:1px;
    classDef platform fill:#F0F0F0,stroke:#444444,stroke-width:1px;
```
