# mycalls/applimode architecture

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

- Interactive diagram: https://gitdiagram.com/mycalls/applimode
- Repository: https://github.com/mycalls/applimode

## Overview

##### Project type and purpose
- This is a full-stack, cross-platform mobile/web application (“Applimode”) built with Flutter for its UI layer and Google Firebase for its backend services.
- Purpose: Allow non-developers to quickly spin up a blog or community service that runs on Android, iOS, Web (PWA), and optionally desktop platforms, leveraging Firebase Authentication, Firestore Database, Storage, Cloud Functions, and optional Cloudflare services.

##### File structure
- Top-level “android”, “ios”, “web”, “linux”, “macos”, “windows”: Flutter platform folders containing native scaffolding.
- “lib/src”: Main Dart code, organized via feature modules (authentication, posts, comments, profile, admin_settings, etc.) following a layered approach (presentation → application → domain → data).
- “functions”: Node.js Cloud Functions for server-side logic or triggers.
- “applimode-tool”: CLI tool (Node.js) for bootstrapping/configuring the Firebase environment.
- Configuration/deployment files: firebase.json, firestore.rules, storage.rules, presettings (Cloudflare D1/R2/Cors/Workers), flutterfire CLI integration.

##### README for additional insights
- Confirms Firebase services in use: Authentication, Firestore, Storage, optional R2/D1/CDN.
- Mentions Riverpod for state management in Flutter.
- Cloud Functions invoked for back-end rules and indexing.
- Optional integration with external AI (Google Gemini via FCM functions).

##### Elements
- Clear component labels (e.g., “Android/iOS/Web Clients”, “Firestore Database”, “Cloud Functions”)
- Blue rectangles for client components
- Grey clouds for external services (Cloudflare, AI)

##### Final recommendations
- Be as detailed as possible within each layer: annotate that features (posts, comments, profile) map to data collections in Firestore.
- Security rules and indexes (presettings) are shown as part of the backend configuration.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph "Mobile & Web Clients" 
        direction TB
        Android["Android Client App"]:::frontend
        iOS["iOS Client App"]:::frontend
        WebPWA["Web Client App (PWA)"]:::frontend
        Linux["Linux Client App"]:::frontend
        macOS["macOS Client App"]:::frontend
        Windows["Windows Client App"]:::frontend
    end

    %% Flutter UI & Riverpod Layer
    subgraph "Flutter UI & Riverpod" 
        direction TB
        AppShell["App Shell"]:::frontend
        Routing["Routing & Startup"]:::frontend
        subgraph Features
            direction TB
            AuthFeature["Authentication Feature"]:::frontend
            PostsFeature["Posts Listing Feature"]:::frontend
            PostFeature["Single Post Feature"]:::frontend
            CommentsFeature["Comments Feature"]:::frontend
            ProfileFeature["Profile Management Feature"]:::frontend
            AdminSettingsFeature["Admin Settings Feature"]:::frontend
            EditorFeature["Editor Feature"]:::frontend
            PromptsFeature["AI Prompts & Assistant"]:::frontend
            StorageRepo["Firebase Storage Abstraction"]:::frontend
            R2StorageRepo["Cloudflare R2 Storage Proxy"]:::frontend
            SearchRepo["Full-text Search (D1)"]:::frontend
            VideoPlayer["Video Player Components"]:::frontend
            CommonWidgets["Common Widgets & Utilities"]:::frontend
        end
    end

    %% Backend Services
    subgraph "Backend Services"
        direction TB
        CLI["CLI Initialization Tool"]:::compute
        subgraph Firebase
            direction TB
            AuthSvc["Firebase Authentication"]:::db
            Firestore["Firestore Database"]:::db
            StorageSvc["Firebase Storage"]:::db
            CloudFunctions["Cloud Functions"]:::compute
        end
        Config["Firebase Config & Security Rules"]:::compute
    end

    %% External Integrations (Optional)
    subgraph "External Integrations (Optional)"
        direction TB
        CF_R2["Cloudflare R2"]:::external
        CF_D1["Cloudflare D1"]:::external
        CF_Workers["Cloudflare Workers"]:::external
        AI_Assist["AI Assistant (Gemini)"]:::external
    end

    %% Relationships
    Android -->|uses| AppShell
    iOS -->|uses| AppShell
    WebPWA -->|uses| AppShell
    Linux -->|uses| AppShell
    macOS -->|uses| AppShell
    Windows -->|uses| AppShell

    AppShell -->|initializes| Routing
    Routing -->|provides| AuthFeature
    Routing -->|provides| PostsFeature
    Routing -->|provides| PostFeature
    Routing -->|provides| CommentsFeature
    Routing -->|provides| ProfileFeature
    Routing -->|provides| AdminSettingsFeature
    Routing -->|provides| EditorFeature
    Routing -->|provides| PromptsFeature

    AuthFeature -->|calls| AuthSvc
    PostsFeature -->|reads/writes| Firestore
    PostFeature -->|reads/writes| Firestore
    CommentsFeature -->|reads/writes| Firestore
    ProfileFeature -->|reads/writes| Firestore
    AdminSettingsFeature -->|reads/writes| Firestore
    EditorFeature -->|writes| Firestore
    PromptsFeature -->|calls| AI_Assist

    StorageRepo -->|uploads/downloads| StorageSvc
    R2StorageRepo -->|uploads/downloads| CF_R2
    SearchRepo -->|queries| CF_D1
    VideoPlayer -->|renders| CF_Workers

    AuthFeature -->|triggers| CloudFunctions
    PostsFeature -->|triggers| CloudFunctions
    Firestore -->|onWrite triggers| CloudFunctions

    CLI -->|configures| Config
    CLI -->|deploys| AuthSvc
    CLI -->|deploys| Firestore
    CLI -->|deploys| StorageSvc
    CLI -->|deploys| CloudFunctions

    %% Click Events
    click Android "https://github.com/mycalls/applimode/tree/main/android/"
    click iOS "https://github.com/mycalls/applimode/tree/main/ios/"
    click WebPWA "https://github.com/mycalls/applimode/tree/main/web/"
    click Linux "https://github.com/mycalls/applimode/tree/main/linux/"
    click macOS "https://github.com/mycalls/applimode/tree/main/macos/"
    click Windows "https://github.com/mycalls/applimode/tree/main/windows/"
    click AppShell "https://github.com/mycalls/applimode/blob/main/lib/main.dart"
    click AppShell "https://github.com/mycalls/applimode/blob/main/lib/src/app.dart"
    click Routing "https://github.com/mycalls/applimode/blob/main/lib/src/routing/app_router.dart"
    click Routing "https://github.com/mycalls/applimode/blob/main/lib/src/routing/app_startup.dart"
    click Routing "https://github.com/mycalls/applimode/blob/main/lib/src/routing/app_startup_widget.dart"
    click AuthFeature "https://github.com/mycalls/applimode/tree/main/lib/src/features/authentication/"
    click PostsFeature "https://github.com/mycalls/applimode/tree/main/lib/src/features/posts/"
    click PostFeature "https://github.com/mycalls/applimode/tree/main/lib/src/features/post/"
    click CommentsFeature "https://github.com/mycalls/applimode/tree/main/lib/src/features/comments/"
    click ProfileFeature "https://github.com/mycalls/applimode/tree/main/lib/src/features/profile/"
    click AdminSettingsFeature "https://github.com/mycalls/applimode/tree/main/lib/src/features/admin_settings/"
    click EditorFeature "https://github.com/mycalls/applimode/tree/main/lib/src/features/editor/"
    click PromptsFeature "https://github.com/mycalls/applimode/tree/main/lib/src/features/prompts/"
    click StorageRepo "https://github.com/mycalls/applimode/blob/main/lib/src/features/firebase_storage/firebase_storage_repository.dart"
    click R2StorageRepo "https://github.com/mycalls/applimode/blob/main/lib/src/features/r_two_storage/r_two_storage_repository.dart"
    click SearchRepo "https://github.com/mycalls/applimode/blob/main/lib/src/features/search/data/d_one_repository.dart"
    click VideoPlayer "https://github.com/mycalls/applimode/tree/main/lib/src/features/video_player/"
    click CommonWidgets "https://github.com/mycalls/applimode/tree/main/lib/src/common_widgets/"
    click CommonWidgets "https://github.com/mycalls/applimode/tree/main/lib/src/utils/"
    click CLI "https://github.com/mycalls/applimode/blob/main/applimode-tool/index.js"
    click CloudFunctions "https://github.com/mycalls/applimode/blob/main/functions/index.js"
    click Config "https://github.com/mycalls/applimode/blob/main/firebase.json"
    click Config "https://github.com/mycalls/applimode/blob/main/firestore.rules"
    click Config "https://github.com/mycalls/applimode/blob/main/storage.rules"
    click Config "https://github.com/mycalls/applimode/blob/main/firestore.indexes.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,stroke-width:1px;
    classDef compute fill:#FFE4B5,stroke:#D2691E,stroke-width:1px;
    classDef db fill:#D5F5E3,stroke:#27AE60,stroke-width:1px;
    classDef external fill:#F0F0F0,stroke:#7F8C8D,stroke-width:1px;
```
