# aloann/childcare architecture

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

- Interactive diagram: https://gitdiagram.com/aloann/childcare
- Repository: https://github.com/aloann/childcare

## Overview

##### Project Type and Purpose
- This is a cross‐platform Flutter application (mobile, web, desktop) that serves as a “mini Algerian Health Record Booklet.”
- No separate backend folder exists—platform‐specific folders (android/, ios/, linux/, macos/, windows/, web/) host the native embedding of the same Flutter client.
- The presence of google-services.json hints at Firebase (Auth, Firestore or Realtime DB) usage; additional hints like gemini_chat_bot.dart suggest integration with an external chat API.

##### File Structure
- Top-level:
- android/, ios/, linux/, macos/, windows/, web/ – Flutter engine entrypoints for each OS
- lib/ – Flutter code, UI screens under lib/pages, main.dart as the entrypoint
- pubspec.yaml/lock – dependencies (likely firebase, HTTP, state management)
- test/ – widget tests
- Inside lib/pages you see feature-oriented Dart files (login.dart, register.dart, home.dart, child_list_mom.dart, smart_assistant.dart, etc.).

##### README Insights
- Mini health record app
- Authentication, home screens for different roles (mother, doctor, admin)
- Chat assistant feature (“gemini_chat_bot.dart”)

##### Main Components
a. Flutter Client Layer
- UI Screens (Pages: Login, Register, Home, Child Management, Appointments, Chat Assistant, etc.)
- Business Logic (state management, input validation)
- Services (AuthService, DatabaseService, ChatService)
b. Platform Embedding
- Flutter Engine → Android (MainActivity.kt), iOS (AppDelegate.swift), Desktop runners
c. External Services
- Firebase Auth
- Firebase Firestore/RTDB
- External Chat API (Gemini/ChatGPT)
d. Data Storage
- Cloud Database (Firestore)
- Optionally local cache (SQLite/shared_preferences, if used)

##### Relationships & Interactions
- User taps a button → Flutter UI Screen
- UI delegates to Business Logic / Service
- AuthService ↔ Firebase Auth
- DatabaseService ↔ Firestore (CRUD for mother, child, appointment records)
- ChatService ↔ External Chat API over HTTPS
- Responses flow back up: API → Service → UI

##### Architectural Patterns & Principles
- Feature-oriented folder structure (pages per feature)
- Layered architecture: UI → Business Logic → Data Services → External Systems
- Single codebase for all platforms via Flutter
- External integrations kept behind service abstractions

1. A high-level Context: User(s) ↔ Flutter App ↔ Cloud Services
2. Drill down to Container View:
- Flutter App container
- Firebase container (Auth, Firestore)
- Chat API container
3. Drill down to Component View inside Flutter App:
- UI Components (LoginPage, HomePage, ChildListPage, ChatAssistantPage…)
- Service Components (AuthService, DatabaseService, ChatService)
- Data Models (MessageModel, ChildModel, AppointmentModel)
4. With platform embedding details (MainActivity.kt, AppDelegate.swift) at the Flutter engine boundary.

##### Detail without Overthinking
- Screens and services as discrete components
- Explicit flows for login, data CRUD, chat interactions
- Don’t omit the platform‐specific runners—they anchor the client to each OS

- Reflects all parts of this multi-platform Flutter app
- Shows how UI, logic, and data layers interact
- Calls out external dependencies (Firebase, Chat API)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Flutter App Container
    subgraph "Flutter App"
        direction TB
        main["main.dart"]:::client
        subgraph "UI Components"
            direction TB
            Login["LoginPage"]:::client
            Register["RegisterPage"]:::client
            Home["HomePage"]:::client
            MotherHome["MotherHome"]:::client
            DoctorHome["DoctorHome"]:::client
            AdminHome["AdminHome"]:::client
            ChildListMom["ChildListMom"]:::client
            ChildListDoc["ChildListDoc"]:::client
            AddChild["AddChild"]:::client
            EditChild["EditChild"]:::client
            ViewChild["ViewChild"]:::client
            AppointmentsMom["AppointmentsMother"]:::client
            Vaccination["VaccinationPage"]:::client
            Sizes["SizesPage"]:::client
            ResetPW["ResetPasswordPage"]:::client
            SmartAssist["SmartAssistant"]:::client
            GeminiChat["GeminiChatBot"]:::client
            ChatBubble["ChatBubbleWidget"]:::client
        end
        subgraph "Services"
            direction TB
            AuthService["AuthService"]:::client
            DBService["DatabaseService"]:::client
            ChatService["ChatService"]:::client
        end
        MessageModel["MessageModel"]:::model
    end

    %% External Systems
    subgraph "Cloud Services"
        direction TB
        FirebaseAuth["Firebase Auth"]:::external
        FirestoreDB["Firestore"]:::db
        ChatAPI["External Chat API"]:::external
    end

    %% Platform Runners
    subgraph "Platform Embedding"
        direction TB
        Android["MainActivity.kt"]:::platform
        iOS["AppDelegate.swift (iOS)"]:::platform
        macOS["AppDelegate.swift (macOS)"]:::platform
        Linux["main.cc"]:::platform
        Windows["main.cpp"]:::platform
        Web["index.html"]:::platform
    end

    %% Relationships
    main -->|"navigates to"| Login
    main -->|"navigates to"| Register
    main -->|"navigates to"| Home

    Login -->|"authenticateUser()"| AuthService
    Register -->|"registerUser()"| AuthService
    Home -->|"loadDashboard()"| DBService

    MotherHome -->|"fetchChildren()"| DBService
    DoctorHome -->|"fetchPatients()"| DBService
    AdminHome -->|"manageUsers()"| DBService

    ChildListMom -->|"getChildList()"| DBService
    ChildListDoc -->|"getChildList()"| DBService
    AddChild -->|"addChild()"| DBService
    EditChild -->|"updateChild()"| DBService
    ViewChild -->|"viewChild()"| DBService

    AppointmentsMom -->|"fetchAppointments()"| DBService
    Vaccination -->|"fetchVaccinations()"| DBService
    Sizes -->|"fetchSizes()"| DBService

    ResetPW -->|"resetPassword()"| AuthService

    SmartAssist -->|"guideUser()"| ChatService
    GeminiChat -->|"sendMessage()"| ChatService
    ChatBubble -->|"displayMessage()"| MessageModel

    AuthService -->|"REST over HTTPS"| FirebaseAuth
    DBService -->|"Firestore SDK"| FirestoreDB
    ChatService -->|"HTTPS API"| ChatAPI

    %% Platform embedding to Flutter engine
    Android --> main
    iOS --> main
    macOS --> main
    Linux --> main
    Windows --> main
    Web --> main

    %% Click Events
    click main "https://github.com/aloann/childcare/blob/master/lib/main.dart"
    click Login "https://github.com/aloann/childcare/blob/master/lib/pages/login.dart"
    click Register "https://github.com/aloann/childcare/blob/master/lib/pages/register.dart"
    click Home "https://github.com/aloann/childcare/blob/master/lib/pages/home.dart"
    click MotherHome "https://github.com/aloann/childcare/blob/master/lib/pages/mother_home.dart"
    click DoctorHome "https://github.com/aloann/childcare/blob/master/lib/pages/doctor_home.dart"
    click AdminHome "https://github.com/aloann/childcare/blob/master/lib/pages/admin_home.dart"
    click ChildListMom "https://github.com/aloann/childcare/blob/master/lib/pages/child_list_mom.dart"
    click ChildListDoc "https://github.com/aloann/childcare/blob/master/lib/pages/child_list_doc.dart"
    click AddChild "https://github.com/aloann/childcare/blob/master/lib/pages/add_child.dart"
    click EditChild "https://github.com/aloann/childcare/blob/master/lib/pages/edit_child.dart"
    click ViewChild "https://github.com/aloann/childcare/blob/master/lib/pages/view_child.dart"
    click AppointmentsMom "https://github.com/aloann/childcare/blob/master/lib/pages/appointments_mother.dart"
    click Vaccination "https://github.com/aloann/childcare/blob/master/lib/pages/vac_page.dart"
    click Sizes "https://github.com/aloann/childcare/blob/master/lib/pages/sizes_page.dart"
    click ResetPW "https://github.com/aloann/childcare/blob/master/lib/pages/reset_pw.dart"
    click SmartAssist "https://github.com/aloann/childcare/blob/master/lib/pages/smart_assistant.dart"
    click GeminiChat "https://github.com/aloann/childcare/blob/master/lib/pages/gemini_chat_bot.dart"
    click ChatBubble "https://github.com/aloann/childcare/blob/master/lib/pages/chat_bubble.dart"
    click MessageModel "https://github.com/aloann/childcare/blob/master/lib/pages/message_model.dart"
    click Android "https://github.com/aloann/childcare/blob/master/android/app/src/main/kotlin/com/example/pfe2025/MainActivity.kt"
    click iOS "https://github.com/aloann/childcare/blob/master/ios/Runner/AppDelegate.swift"
    click macOS "https://github.com/aloann/childcare/blob/master/macos/Runner/AppDelegate.swift"
    click Linux "https://github.com/aloann/childcare/blob/master/linux/runner/main.cc"
    click Windows "https://github.com/aloann/childcare/blob/master/windows/runner/main.cpp"
    click Web "https://github.com/aloann/childcare/blob/master/web/index.html"
    click FirebaseAuth "https://github.com/aloann/childcare/blob/master/android/app/google-services.json"
    click pubspec "https://github.com/aloann/childcare/blob/master/pubspec.yaml"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef model fill:#E0F7FA,stroke:#00838F,color:#006064
    classDef db fill:#E8F5E9,stroke:#2E7D32,color:#1B5E20
    classDef external fill:#FFF3E0,stroke:#FB8C00,color:#E65100
    classDef platform fill:#F3E5F5,stroke:#8E24AA,color:#6A1B9A
```
