# mahmoodimtiaz93/flutter-blogapp architecture

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

- Interactive diagram: https://gitdiagram.com/mahmoodimtiaz93/flutter-blogapp
- Repository: https://github.com/mahmoodimtiaz93/flutter-blogapp

## Overview

1. **Repository shape**
   - This is a **Flutter cross-platform mobile app** called a blog/social media app.
   - The same codebase targets **Android, iOS, web, Linux, and macOS**, with platform folders containing only the standard Flutter host scaffolding.
   - The architectural center of gravity is under **`lib/`**, which is split into presentation, state management, services, constants, models, and utilities.

2. **Product/domain scope**
   - The app supports a social workflow: **sign up, sign in, create/edit posts with photos and text, like/comment on posts, search users, send/cancel friend requests, and view profile/friend feeds**.
   - The README and screen names suggest a social graph centered around users, posts, comments, and friend relationships.

3. **Presentation layer: screens**
   - UI pages live in **`lib/screen/`** and are the top-level navigation destinations.
   - Key screens include authentication (`signin_screen`, `signup_screen`), feed and home (`home_screen`, `friends_feed_sreen`, `nav_screen`), post creation (`add_post_screen`), interaction (`comment_screen`), profile management (`profile_screen`, `update_profile`), and social graph flows (`search_friend_screen`, `friendlist_screen`, `sent_request_screen`, `pendding_friendList_screen`, `friend_tabbar`).
   - `loading.dart` appears to be an app bootstrap/loading gate, likely used while auth/session state is being resolved.

4. **Reusable UI components**
   - Shared widgets are isolated in **`lib/components/`**.
   - These include custom input and action primitives such as `button.dart`, `custome_textfield.dart`, and `snackbar.dart`.
   - This indicates the app avoids duplicating form and messaging UI across auth, profile, and post/comment flows.

5. **State management boundary**
   - The **`lib/provider/`** folder holds application state controllers for major domains: `auth_provider`, `post_provider`, `comment_provider`, and `friendlist_provider`.
   - Providers act as the bridge between screens and services, holding loading/error/data state for each domain.
   - The architecture is therefore a typical Flutter client pattern: **screen → provider → service → API/model**.

6. **Service layer / backend boundary**
   - The **`lib/services/`** layer contains API-facing logic: `user_services`, `post_services`, `comment_services`, and `friends_services`.
   - This is the main boundary between the client and the external backend. The repository does not include the backend itself, so the app appears to consume a **remote API**.
   - `apiresponse.dart` suggests a shared response wrapper or result type used by those service calls.

7. **API and environment constants**
   - **`lib/constant/endpoints.dart`** centralizes remote route definitions.
   - **`lib/constant/error_handaling.dart`** likely standardizes request failures and exception translation.
   - This separation implies the app treats API URL composition and error interpretation as shared infrastructure rather than embedding them in screens.

8. **Domain/data models**
   - **`lib/model/`** contains the app’s structured data contracts: users, profiles, posts, comments, friend requests, likes received/given, search results, and related entities.
   - Examples include `post_model`, `comment_model`, `user_model`, `single_user`, `searchuser_model`, `friendlist_model`, `sentfnd_request`, `pendding_request`, `liked_given`, and `likedRecived`.
   - These models are the shared schema between backend payloads, service parsing, and UI rendering.

9. **Navigation structure**
   - Routing appears to be centralized in **`lib/utils/routes.dart`** and **`lib/utils/route_name.dart`**.
   - This indicates named-route navigation rather than ad hoc screen pushes scattered across the codebase.
   - `nav_screen.dart` likely functions as the main shell/container for switching between primary sections of the app.

10. **Utility layer**
   - **`lib/utils/`** contains app-wide helpers such as `functions.dart` and visual helpers like `colorfilter.dart`.
   - Utilities are kept separate from business logic and UI state, supporting reuse across screens and providers.

11. **Assets and branding**
   - The `assets/` and `Images/` folders hold app imagery, including screenshots used in the README and likely in-app visual assets.
   - Native launch screens and app icons are configured in each platform folder, but the app’s actual branded content appears to be lightweight and image-driven.

12. **Platform host shells**
   - Android, iOS, macOS, Linux, and web directories are standard Flutter-generated wrappers.
   - They mainly provide bootstrapping, manifests, app icons, launch screens, and platform entrypoints like `MainActivity.kt` and `AppDelegate.swift`.
   - No platform-specific business logic is evident, so the architecture is largely **shared Flutter UI with thin native shells**.

13. **End-to-end data flow**
   - A user action starts in a screen, updates provider state, triggers a service call, and receives parsed model objects back from the remote API.
   - Providers then expose results to the UI for rendering lists, feeds, comments, request statuses, and profile data.
   - The core data loop is therefore: **UI event → state provider → service/API → model parsing → provider update → UI refresh**.

14. **What to show in an architecture diagram**
   - Put **screens** at the top, **providers** as the orchestration layer, **services + endpoints** as the API boundary, and **models** underneath as the shared data contracts.
   - Show a single external dependency box for the **backend API**; the repo itself is a client application, not a full-stack monolith.
   - Include separate domain streams for **auth**, **posts/comments**, and **friend/social graph** since those are the main functional subsystems.

15. **Testing/tooling**
   - There is a minimal Flutter test scaffold in `test/widget_test.dart`, but no broad test architecture is visible from the tree.
   - `pubspec.yaml` and `analysis_options.yaml` imply standard Flutter/Dart tooling and linting, but the repository structure itself is primarily organized around runtime app concerns rather than build-time complexity.

Main entry points: [`lib/utils/routes.dart`](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/utils/routes.dart) (routes), [`lib/components/button.dart`](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/components/button.dart) (ui components), [`lib/services/user_services.dart`](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/services/user_services.dart) (user service), [`lib/services/post_services.dart`](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/services/post_services.dart) (post service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app_shell["App shell"]
  node_main["main.dart<br/>Flutter entrypoint<br/>[main.dart]"]
  node_routes["routes<br/>Route map<br/>[routes.dart]"]
  node_route_name["route names<br/>Route constants<br/>[route_name.dart]"]
end

subgraph group_presentation["Presentation"]
  node_loading["loading<br/>Bootstrap gate<br/>[loading.dart]"]
  node_nav_shell["nav shell<br/>App shell<br/>[nav_screen.dart]"]
  node_auth_screens["auth screens<br/>[signin_screen.dart]"]
  node_feed_screens["feed screens<br/>[home_screen.dart]"]
  node_post_screen["post editor<br/>Screen"]
  node_comment_screen["comments<br/>Screen"]
  node_profile_screens["profile screens"]
  node_friend_screens["friend screens"]
  node_ui_components["ui components<br/>Shared widgets<br/>[button.dart]"]
end

subgraph group_state["State"]
  node_auth_provider["auth provider<br/>State controller<br/>[auth_provider.dart]"]
  node_post_provider["post provider<br/>State controller<br/>[post_provider.dart]"]
  node_comment_provider["comment provider<br/>State controller"]
  node_friend_provider["friend provider<br/>State controller"]
end

subgraph group_data["Data"]
  node_user_services["user service<br/>API client<br/>[user_services.dart]"]
  node_post_services["post service<br/>API client<br/>[post_services.dart]"]
  node_comment_services["comment service<br/>API client"]
  node_friend_services["friend service<br/>API client"]
  node_api_response["api response<br/>Result wrapper<br/>[apiresponse.dart]"]
  node_models["models<br/>Domain schemas<br/>[post_model.dart]"]
end

subgraph group_platform["Platform"]
  node_android_shell["android<br/>Flutter host<br/>[MainActivity.kt]"]
  node_ios_shell["ios<br/>Flutter host<br/>[AppDelegate.swift]"]
  node_desktop_web_shells["desktop/web<br/>Flutter host<br/>[main.cc]"]
end

subgraph group_external["External"]
  node_backend_api[("backend API<br/>Remote dependency")]
end

node_main -->|"uses"| node_routes
node_routes -->|"references"| node_route_name
node_routes -->|"opens"| node_loading
node_routes -->|"opens"| node_nav_shell
node_routes -->|"opens"| node_auth_screens
node_routes -->|"opens"| node_feed_screens
node_routes -->|"opens"| node_post_screen
node_routes -->|"opens"| node_comment_screen
node_routes -->|"opens"| node_profile_screens
node_routes -->|"opens"| node_friend_screens
node_loading -->|"checks"| node_auth_provider
node_auth_screens -->|"updates"| node_auth_provider
node_feed_screens -->|"uses"| node_post_provider
node_post_screen -->|"updates"| node_post_provider
node_comment_screen -->|"updates"| node_comment_provider
node_friend_screens -->|"updates"| node_friend_provider
node_profile_screens -->|"uses"| node_auth_provider
node_auth_provider -->|"calls"| node_user_services
node_post_provider -->|"calls"| node_post_services
node_comment_provider -->|"calls"| node_comment_services
node_friend_provider -->|"calls"| node_friend_services
node_user_services -->|"returns"| node_api_response
node_post_services -->|"returns"| node_api_response
node_comment_services -->|"returns"| node_api_response
node_friend_services -->|"returns"| node_api_response
node_user_services -->|"parses"| node_models
node_post_services -->|"parses"| node_models
node_comment_services -->|"parses"| node_models
node_friend_services -->|"parses"| node_models
node_user_services -->|"requests"| node_backend_api
node_post_services -->|"requests"| node_backend_api
node_comment_services -->|"requests"| node_backend_api
node_friend_services -->|"requests"| node_backend_api
node_ui_components -.->|"shared by"| node_auth_screens
node_ui_components -.->|"shared by"| node_post_screen
node_ui_components -.->|"shared by"| node_comment_screen
node_ui_components -.->|"shared by"| node_profile_screens

click node_main "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/main.dart"
click node_routes "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/utils/routes.dart"
click node_route_name "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/utils/route_name.dart"
click node_loading "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/loading.dart"
click node_nav_shell "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/nav_screen.dart"
click node_auth_screens "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/signin_screen.dart"
click node_feed_screens "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/home_screen.dart"
click node_post_screen "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/add_post_screen.dart"
click node_comment_screen "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/comment_screen.dart"
click node_profile_screens "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/profile_screen.dart"
click node_friend_screens "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/search_friend_screen.dart"
click node_ui_components "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/components/button.dart"
click node_auth_provider "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/provider/auth_provider.dart"
click node_post_provider "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/provider/post_provider.dart"
click node_comment_provider "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/provider/comment_provider.dart"
click node_friend_provider "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/provider/friendlist_provider.dart"
click node_user_services "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/services/user_services.dart"
click node_post_services "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/services/post_services.dart"
click node_comment_services "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/services/comment_services.dart"
click node_friend_services "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/services/friends_services.dart"
click node_api_response "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/services/apiresponse.dart"
click node_models "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/model/post_model.dart"
click node_android_shell "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/android/app/src/main/kotlin/com/example/blogapp/MainActivity.kt"
click node_ios_shell "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/ios/Runner/AppDelegate.swift"
click node_desktop_web_shells "https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/linux/main.cc"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_routes,node_route_name toneBlue
class node_loading,node_nav_shell,node_auth_screens,node_feed_screens,node_post_screen,node_comment_screen,node_profile_screens,node_friend_screens,node_ui_components toneAmber
class node_auth_provider,node_post_provider,node_comment_provider,node_friend_provider toneMint
class node_user_services,node_post_services,node_comment_services,node_friend_services,node_api_response,node_models toneRose
class node_android_shell,node_ios_shell,node_desktop_web_shells toneIndigo
class node_backend_api toneTeal
```

## Components

### App shell

Bootstrap, routing, and navigation entrypoints

- [main.dart](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/main.dart): Flutter entrypoint · App bootstrap and top-level widget setup · `lib/main.dart`
- [routes](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/utils/routes.dart): Route map · Named route registration and screen wiring · `lib/utils/routes.dart`
- [route names](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/utils/route_name.dart): Route constants · Centralized route identifiers · `lib/utils/route_name.dart`

### Presentation

Screens and reusable UI components

- [loading](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/loading.dart): Bootstrap gate · Initial auth/session loading screen · `lib/screen/loading.dart`
- [nav shell](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/nav_screen.dart): App shell · Primary container for section switching · `lib/screen/nav_screen.dart`
- [auth screens](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/signin_screen.dart): Screens · Sign-in and sign-up flows · `lib/screen/signin_screen.dart`
- [feed screens](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/home_screen.dart): Screens · Home and friends feed views · `lib/screen/home_screen.dart`
- [post editor](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/add_post_screen.dart): Screen · Create new posts with text and photos · `lib/screen/add_post_screen.dart`
- [comments](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/comment_screen.dart): Screen · Post comment interaction view · `lib/screen/comment_screen.dart`
- [profile screens](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/profile_screen.dart): Screens · Profile view and profile update · `lib/screen/profile_screen.dart`
- [friend screens](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/screen/search_friend_screen.dart): Screens · Search, requests, lists, and friend tab UI · `lib/screen/search_friend_screen.dart`
- [ui components](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/components/button.dart): Shared widgets · Common button, text field, and snackbar widgets · `lib/components/button.dart`

### State

Provider-based domain state orchestration

- [auth provider](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/provider/auth_provider.dart): State controller · Authentication and session state · `lib/provider/auth_provider.dart`
- [post provider](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/provider/post_provider.dart): State controller · Post feed and creation state · `lib/provider/post_provider.dart`
- [comment provider](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/provider/comment_provider.dart): State controller · Comment thread state · `lib/provider/comment_provider.dart`
- [friend provider](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/provider/friendlist_provider.dart): State controller · Friend requests, lists, and social graph state · `lib/provider/friendlist_provider.dart`

### Data

API services and shared models

- [user service](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/services/user_services.dart): API client · User authentication and profile requests · `lib/services/user_services.dart`
- [post service](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/services/post_services.dart): API client · Post fetch and mutation requests · `lib/services/post_services.dart`
- [comment service](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/services/comment_services.dart): API client · Comment fetch and mutation requests · `lib/services/comment_services.dart`
- [friend service](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/services/friends_services.dart): API client · Friend search and request requests · `lib/services/friends_services.dart`
- [api response](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/services/apiresponse.dart): Result wrapper · Shared service response wrapper · `lib/services/apiresponse.dart`
- [models](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/lib/model/post_model.dart): Domain schemas · User, post, comment, and friend data contracts · `lib/model/post_model.dart`

### Platform

Flutter host shells and platform scaffolding

- [android](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/android/app/src/main/kotlin/com/example/blogapp/MainActivity.kt): Flutter host · Android native wrapper · `android/app/src/main/kotlin/com/example/blogapp/MainActivity.kt`
- [ios](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/ios/Runner/AppDelegate.swift): Flutter host · iOS native wrapper · `ios/Runner/AppDelegate.swift`
- [desktop/web](https://github.com/mahmoodimtiaz93/flutter-blogapp/blob/main/linux/main.cc): Flutter host · Linux, macOS, and web wrappers · `linux/main.cc`

### External

Remote backend dependency

- **backend API**: Remote dependency · External server consumed by the Flutter client

## Connections

- main.dart → routes: uses · Bootstrap delegates navigation setup
- routes → route names: references · Route table uses shared names
- routes → loading: opens · Initial route to loading gate
- routes → nav shell: opens · Main app container after startup
- routes → auth screens: opens · Authentication destinations
- routes → feed screens: opens · Feed destinations
- routes → post editor: opens · Post creation destination
- routes → comments: opens · Comment destination
- routes → profile screens: opens · Profile destinations
- routes → friend screens: opens · Friend/social destinations
- loading → auth provider: checks · Resolves session and auth state
- auth screens → auth provider: updates · Submits sign-in and sign-up actions
- feed screens → post provider: uses · Renders feed and post actions
- post editor → post provider: updates · Creates and edits posts
- comments → comment provider: updates · Loads and sends comments
- friend screens → friend provider: updates · Searches users and manages requests
- profile screens → auth provider: uses · Profile state and account updates
- auth provider → user service: calls · Authentication and user profile APIs
- post provider → post service: calls · Post APIs
- comment provider → comment service: calls · Comment APIs
- friend provider → friend service: calls · Friend APIs
- user service → api response: returns · Normalizes API outcomes
- post service → api response: returns · Normalizes API outcomes
- comment service → api response: returns · Normalizes API outcomes
- friend service → api response: returns · Normalizes API outcomes
- user service → models: parses · Maps user/profile payloads
- post service → models: parses · Maps post payloads
- comment service → models: parses · Maps comment payloads
- friend service → models: parses · Maps friend/search payloads
- user service → backend API: requests · Remote authentication and user endpoints
- post service → backend API: requests · Remote post endpoints
- comment service → backend API: requests · Remote comment endpoints
- friend service → backend API: requests · Remote friend endpoints
- ui components → auth screens: shared by · Form and feedback primitives
- ui components → post editor: shared by · Reusable inputs and actions
- ui components → comments: shared by · Reusable inputs and actions
- ui components → profile screens: shared by · Reusable inputs and actions
