# alokjha2/fluttergame architecture

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

- Interactive diagram: https://gitdiagram.com/alokjha2/fluttergame
- Repository: https://github.com/alokjha2/fluttergame

## Overview

##### Project Type and Purpose
- This is a cross-platform mobile/desktop/web Flutter application (“Memory Game”), extended to include multiple mini-games (quiz, scavenger hunt, snap hunt, binod game) and multiplayer features.
- It ships to Android, iOS, Linux, Windows, macOS and web via the Flutter engine.
- It uses Firebase for authentication, real-time room services, and push notifications, plus a custom Node.js server for certain multiplayer or blog-fetching APIs, and a few Python scripts for offline data scraping.

##### File-Structure Analysis
- Top-level platform folders: android/, ios/, linux/, macos/, windows/, web/ – these contain the platform hosts and native scaffolding.
- lib/ directory:
- presentation/ (screens, router, widgets) – the UI layer
- controller/ & providers/ – state-management layer (GetX or Provider patterns)
- firebase/ – services for auth and real-time updates
- repository/ – interfaces for data and error handling
- api.py / server.js – external API clients and server
- model/ – data classes
- utils/ – constants and helpers
- server/ folder: Node.js backend (server.js) for real-time rooms.
- assets/: static assets (json, images, animations, sounds) used by the UI.
- Python scripts in lib/ for offline data scraping – not part of runtime but supporting asset generation.

##### Key Architecture Characteristics
- Layered pattern: Presentation → State management/controllers → Domain (services & repositories) → Data sources (Firebase, Node server, local JSON, assets).
- Cross-platform host with a single Dart codebase compiled by Flutter engine to multiple targets.
- Real-time multiplayer via WebSocket/HTTP in server.js & room_service.dart.
- Firebase Auth and cloud messaging integration.

##### Main Components & Interactions (
A. Presentation Layer (Flutter UI)
- Screens (homepage, game screens, quiz, profile, rooms)
- Widgets (cards, progress bars, buttons)
B. State & Navigation Layer
- Controllers (cardController, countDownController, gameTimerController)
- Providers (auth_provider, quiz_provider, binod_provider, etc.)
- Router (app_router.dart → routes.dart)
C. Domain/Service Layer
- Firebase Services (auth_checker.dart, room_service.dart, notify_handler.dart)
- Repositories (article_repository.dart, app_exception.dart)
- API Clients (lib/api.py calls, lib/fetchblog.py)
D. Data Sources
- Firebase Realtime/Firestore/Messaging
- Custom Node.js Server (server/server.js)
- Local JSON in assets/json/data.json
- Local assets (images, sounds, animations)
E. Platform Hosts
- Android, iOS, Linux, Windows, macOS, Web – Flutter engine bridges Dart code to native.

##### Final Checklist
- Annotations for cross-platform Flutter engine and host environments.
- A boundary showing locally-packaged assets vs. cloud/external services.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        MAIN["lib/main.dart"]:::ui
        SCREEN_HOME["Homepage Screen"]:::ui
        SCREEN_PROFILE["Profile Screen"]:::ui
        SCREEN_ROOMS["Room Screen"]:::ui
        SCREEN_FRIENDS["Friends Screen"]:::ui
        SCREEN_QUIZ["Quiz Screen"]:::ui
        SCREEN_BINOD["Binod Game Screen"]:::ui
        SCREEN_SCAV["Scavenger Hunt Screen"]:::ui
        SCREEN_SNAP["Snap Hunt Screen"]:::ui
        WIDGET_CARD["Card Widget"]:::ui
        WIDGET_COUNT["CountDown Overlay"]:::ui
        WIDGET_HOME_BTN["Homepage Button"]:::ui
        WIDGET_INVITE["Invitation Card"]:::ui
        WIDGET_PROGRESS["Progress Bar"]:::ui
        WIDGET_FANCY["Fancy Button"]:::ui
        WIDGET_PLAY["Play Button"]:::ui
    end

    %% State & Navigation Layer
    subgraph "State & Navigation" 
        direction TB
        CONT_CARD["cardController"]:::state
        CONT_COUNT["countDownController"]:::state
        CONT_TIMER["gameTimerController"]:::state
        CONT_WAIT["waitingScreenController"]:::state
        PROVIDER_AUTH["auth_provider"]:::state
        PROVIDER_ARTICLE["article_providers"]:::state
        PROVIDER_MEMORY["memory_game_provider"]:::state
        PROVIDER_QUIZ["quiz_provider"]:::state
        PROVIDER_BINOD["binod_provider"]:::state
        ROUTER_APP["app_router.dart"]:::state
        ROUTES["routes.dart"]:::state
    end

    %% Domain & Service Layer
    subgraph "Domain & Services"
        direction TB
        SERVICE_AUTH["auth_checker"]:::service
        SERVICE_ROOM["room_service"]:::service
        SERVICE_NOTIFY["notify_handler"]:::service
        REPO_EXCEPTION["app_exception"]:::service
        REPO_ARTICLE["article_repository"]:::service
        API_PY["api.py"]:::service
        FETCH_BLOG["fetchblog.py"]:::service
        FETCH_LINK["fetch_blog_link.py"]:::service
    end

    %% Data Sources & External Systems
    subgraph "Data Sources & External"
        direction TB
        DS_FIREBASE["Firebase (Auth/Firestore/Messaging)"]:::datasource
        DS_NODE["Node.js Server"]:::datasource
        DS_JSON["Local JSON data.json"]:::datasource
        DS_ASSETS["Images/Sounds/Animations"]:::datasource
    end

    %% Auxiliary Scripts
    subgraph "Auxiliary Scripts"
        direction TB
        SCRIPT_IMAGE["scrape_image.py"]:::aux
        SCRIPT_SCRIPT["script.py"]:::aux
        SCRIPT_MAIN["main.py"]:::aux
    end

    %% Platform Hosts
    subgraph "Platform Hosts"
        direction TB
        HOST_ANDROID["Android"]:::host
        HOST_IOS["iOS"]:::host
        HOST_LINUX["Linux"]:::host
        HOST_WINDOWS["Windows"]:::host
        HOST_MACOS["macOS"]:::host
        HOST_WEB["Web"]:::host
    end

    %% Connections
    MAIN -->|launches| SCREEN_HOME
    SCREEN_HOME -->|click actions| CONT_CARD
    SCREEN_HOME --> CONT_COUNT
    SCREEN_HOME --> CONT_TIMER
    SCREEN_ROOMS --> CONT_WAIT
    SCREEN_QUIZ --> PROVIDER_QUIZ
    SCREEN_BINOD --> PROVIDER_BINOD
    SCREEN_SCAV --> PROVIDER_MEMORY
    SCREEN_SNAP --> PROVIDER_MEMORY
    WIDGET_CARD --> CONT_CARD
    WIDGET_COUNT --> CONT_COUNT
    WIDGET_PLAY --> CONT_TIMER

    CONT_CARD --> SERVICE_ROOM
    CONT_WAIT --> SERVICE_ROOM
    PROVIDER_AUTH --> SERVICE_AUTH
    PROVIDER_ARTICLE --> REPO_ARTICLE
    PROVIDER_QUIZ --> REPO_ARTICLE
    PROVIDER_BINOD --> REPO_ARTICLE

    SERVICE_AUTH --> DS_FIREBASE
    SERVICE_ROOM -->|WebSocket/HTTP| DS_NODE
    SERVICE_NOTIFY --> DS_FIREBASE
    REPO_ARTICLE --> DS_JSON
    API_PY --> DS_NODE
    FETCH_BLOG --> DS_NODE
    FETCH_LINK --> DS_NODE

    DS_NODE -->|sync| DS_FIREBASE

    %% Flutter Engine to Hosts
    MAIN -->|"Flutter Engine"| HOST_ANDROID
    MAIN -->|"Flutter Engine"| HOST_IOS
    MAIN -->|"Flutter Engine"| HOST_LINUX
    MAIN -->|"Flutter Engine"| HOST_WINDOWS
    MAIN -->|"Flutter Engine"| HOST_MACOS
    MAIN -->|"Flutter Engine"| HOST_WEB

    %% Click Events
    click MAIN "https://github.com/alokjha2/fluttergame/blob/main/lib/main.dart"
    click SCREEN_HOME "https://github.com/alokjha2/fluttergame/blob/main/lib/presentation/screens/homepage.dart"
    click SCREEN_PROFILE "https://github.com/alokjha2/fluttergame/blob/main/lib/presentation/screens/profile/profile.dart"
    click SCREEN_ROOMS "https://github.com/alokjha2/fluttergame/blob/main/lib/presentation/screens/rooms/room.dart"
    click SCREEN_FRIENDS "https://github.com/alokjha2/fluttergame/blob/main/lib/presentation/screens/friends/friends.dart"
    click SCREEN_QUIZ "https://github.com/alokjha2/fluttergame/blob/main/lib/presentation/games/quiz/quizScreen.dart"
    click SCREEN_BINOD "https://github.com/alokjha2/fluttergame/blob/main/lib/presentation/games/binod/binod.dart"
    click SCREEN_SCAV "https://github.com/alokjha2/fluttergame/blob/main/lib/presentation/games/scavengerHunt/scavengerhunt.dart"
    click SCREEN_SNAP "https://github.com/alokjha2/fluttergame/blob/main/lib/presentation/games/snapHunt/snaphunt.dart"
    click WIDGET_CARD "https://github.com/alokjha2/fluttergame/blob/main/lib/components/card.dart"
    click WIDGET_COUNT "https://github.com/alokjha2/fluttergame/blob/main/lib/components/countDownOverlay.dart"
    click WIDGET_HOME_BTN "https://github.com/alokjha2/fluttergame/blob/main/lib/components/homepage_btn.dart"
    click WIDGET_INVITE "https://github.com/alokjha2/fluttergame/blob/main/lib/components/invitationCard.dart"
    click WIDGET_PROGRESS "https://github.com/alokjha2/fluttergame/blob/main/lib/presentation/games/quiz/widgets/progress_bar.dart"
    click WIDGET_FANCY "https://github.com/alokjha2/fluttergame/blob/main/lib/widgets/fancyButton.dart"
    click WIDGET_PLAY "https://github.com/alokjha2/fluttergame/blob/main/lib/widgets/playBtn.dart"
    click CONT_CARD "https://github.com/alokjha2/fluttergame/blob/main/lib/controller/cardController.dart"
    click CONT_COUNT "https://github.com/alokjha2/fluttergame/blob/main/lib/controller/countDownController.dart"
    click CONT_TIMER "https://github.com/alokjha2/fluttergame/blob/main/lib/controller/gameTimerController.dart"
    click CONT_WAIT "https://github.com/alokjha2/fluttergame/blob/main/lib/controller/waitingScreen.dart"
    click PROVIDER_AUTH "https://github.com/alokjha2/fluttergame/blob/main/lib/providers/auth_provider.dart"
    click PROVIDER_ARTICLE "https://github.com/alokjha2/fluttergame/blob/main/lib/providers/article_providers.dart"
    click PROVIDER_MEMORY "https://github.com/alokjha2/fluttergame/blob/main/lib/providers/games/memory_game_provider.dart"
    click PROVIDER_QUIZ "https://github.com/alokjha2/fluttergame/blob/main/lib/providers/games/quiz_provider.dart"
    click PROVIDER_BINOD "https://github.com/alokjha2/fluttergame/blob/main/lib/providers/games/binod_provider.dart"
    click ROUTER_APP "https://github.com/alokjha2/fluttergame/blob/main/lib/presentation/router/app_router.dart"
    click ROUTES "https://github.com/alokjha2/fluttergame/blob/main/lib/presentation/router/routes.dart"
    click SERVICE_AUTH "https://github.com/alokjha2/fluttergame/blob/main/lib/firebase/auth_checker.dart"
    click SERVICE_ROOM "https://github.com/alokjha2/fluttergame/blob/main/lib/firebase/room_service.dart"
    click SERVICE_NOTIFY "https://github.com/alokjha2/fluttergame/blob/main/lib/firebase/notify_handler.dart"
    click REPO_EXCEPTION "https://github.com/alokjha2/fluttergame/blob/main/lib/repository/app_exception.dart"
    click REPO_ARTICLE "https://github.com/alokjha2/fluttergame/blob/main/lib/repository/article_repository.dart"
    click API_PY "https://github.com/alokjha2/fluttergame/blob/main/lib/api.py"
    click FETCH_BLOG "https://github.com/alokjha2/fluttergame/blob/main/lib/fetchblog.py"
    click FETCH_LINK "https://github.com/alokjha2/fluttergame/blob/main/lib/fetch_blog_link.py"
    click DS_JSON "https://github.com/alokjha2/fluttergame/blob/main/assets/json/data/data.json"
    click DS_ASSETS "https://github.com/alokjha2/fluttergame/tree/main/assets/images/"
    click DS_ASSETS "https://github.com/alokjha2/fluttergame/tree/main/assets/sounds/"
    click DS_ASSETS "https://github.com/alokjha2/fluttergame/blob/main/assets/brain_animation.json"
    click DS_NODE "https://github.com/alokjha2/fluttergame/blob/main/server/server.js"
    click SCRIPT_IMAGE "https://github.com/alokjha2/fluttergame/blob/main/lib/scrape_image.py"
    click SCRIPT_SCRIPT "https://github.com/alokjha2/fluttergame/blob/main/lib/script.py"
    click SCRIPT_MAIN "https://github.com/alokjha2/fluttergame/blob/main/lib/main.py"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333
    classDef state fill:#90EE90,stroke:#333
    classDef service fill:#FFA500,stroke:#333
    classDef datasource fill:#D8BFD8,stroke:#333
    classDef host fill:#D3D3D3,stroke:#333
    classDef aux fill:#F0E68C,stroke:#333
```
