# preritpandey/nepnews architecture

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

- Interactive diagram: https://gitdiagram.com/preritpandey/nepnews
- Repository: https://github.com/preritpandey/nepnews

## Overview

##### Main Components
- Flutter Application Core: This is the heart of the project with code in the lib folder. Inside lib, you have:
- Pages (UI screens like Home, Browse, Profile, Auth, Bookmark)
- Controllers (managing business logic such as ads, authentication, news posts, forex, theme)
- Widgets (reusable UI components like ad cards, breaking news widgets, custom text fields, etc.)
- Models (data models for ads, forex, etc.)
- Services (data service for fetching or managing data)
- Core utilities (e.g., screen size configuration and theming)

- Native Platform Layers: Directories for Android, iOS, macos, linux, windows indicate that platform-specific projects exist. These handle native configurations, manifests, and integration layers (e.g., MainActivity.kt for Android, AppDelegate.swift for iOS).

##### Relationships and Interactions
- UI Layer ➔ Pages & Widgets:
- Pages gather the user interactions and display data.
- Widgets are used within pages to structure the front-end.

- Controllers as an Intermediary:
- Each page typically invokes a corresponding controller (like news_post_controller or auth_controller) to perform business logic.
- Controllers interact with the services layer to fetch data and update the models.

- Data Flow:
- Data flow begins at the UI (user input) which is then passed to controllers.
- Controllers call services that may fetch data from external APIs or local sources.
- Response data is parsed into models and then rendered on UI components (pages/widgets).

- Platform-Specific Integration:
- The project uses Flutter’s cross-platform abstractions. However, native directories (android, ios, etc.) should be represented to show the integration points that allow the Flutter app to run on respective platforms.

##### Architectural Patterns and Technologies
- Pattern:
- The structure is similar to an MVC or MVVM pattern: with a clear separation of UI (pages/views and widgets), business logic (controllers), and data (models and services).
- Emphasis on modularity is noted by separating concerns into distinct directories.

- Technologies:
- Flutter & Dart (lib/ for core application code)
- Platform-specific languages (Kotlin for Android, Swift/Objective-C for iOS/macOS, C++/CMakeLists for Linux/Windows)
- CI/CD integration is lightly visible (in the .github/workflows directory)
- Resource management through Flutter’s assets

- At the top, the User interacts with the Flutter UI (pages/widgets).
- Below that, illustrate how controllers manage the business logic and bridge UI with the services.
- Further down, show the data flow through models and services.
- On the side or bottom, include platform-specific wrappers showing the native Android/iOS/macOS/desktop integrations.
- Finally, note external resources like online APIs or libraries if applicable (even though not detailed in README, it’s implied by features like ads and forex data).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::user
    Core["Flutter Application Core"]:::flutter
    Assets["Assets & Resources"]:::assets

    User -->|"interacts"| Pages["Pages (UI Screens)"]:::presentation
    Core -->|"hosts"| Pages
    Assets -->|"supplies"| Pages

    subgraph "Presentation Layer"
        Pages["Pages (UI Screens)"]:::presentation
        Widgets["Widgets (Reusable UI Components)"]:::presentation
        Pages -->|"uses"| Widgets
    end

    subgraph "Business Logic Layer"
        Controllers["Controllers (Business Logic)"]:::logic
        Services["Services (Data Service)"]:::logic
        Pages -->|"triggers"| Controllers
        Controllers -->|"calls"| Services
    end

    subgraph "Data Layer"
        Models["Models (Data Models)"]:::data
        Services -->|"updates"| Models
        Models -->|"renders"| Pages
    end

    subgraph "Core Utilities"
        Utilities["Core Utilities (Screen Config & Theming)"]:::utilities
        Utilities -->|"supports"| Pages
    end

    subgraph "Native Platform Integration"
        Android["Android Native Layer"]:::native
        iOS["iOS Native Layer"]:::native
        macOS["macOS Native Layer"]:::native
        Linux["Linux Native Layer"]:::native
        Windows["Windows Native Layer"]:::native
        Core -->|"runs on"| Android
        Core -->|"runs on"| iOS
        Core -->|"runs on"| macOS
        Core -->|"runs on"| Linux
        Core -->|"runs on"| Windows
    end

    Web["Web Platform"]:::native
    Core -->|"hasWebSupport"| Web

    %% Click Events
    click Core "https://github.com/preritpandey/nepnews/tree/main/lib"
    click Pages "https://github.com/preritpandey/nepnews/tree/main/lib/pages"
    click Controllers "https://github.com/preritpandey/nepnews/tree/main/lib/controllers"
    click Widgets "https://github.com/preritpandey/nepnews/tree/main/lib/widgets"
    click Models "https://github.com/preritpandey/nepnews/tree/main/lib/models"
    click Services "https://github.com/preritpandey/nepnews/blob/main/lib/services/data_service.dart"
    click Utilities "https://github.com/preritpandey/nepnews/tree/main/lib/core"
    click Android "https://github.com/preritpandey/nepnews/tree/main/android"
    click iOS "https://github.com/preritpandey/nepnews/tree/main/ios"
    click macOS "https://github.com/preritpandey/nepnews/tree/main/macos"
    click Linux "https://github.com/preritpandey/nepnews/tree/main/linux"
    click Windows "https://github.com/preritpandey/nepnews/tree/main/windows"
    click Web "https://github.com/preritpandey/nepnews/tree/main/web"
    click Assets "https://github.com/preritpandey/nepnews/tree/main/assets"

    %% Styles
    classDef presentation fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef logic fill:#A9DFBF,stroke:#1D8348,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef utilities fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef native fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef assets fill:#D5DBDB,stroke:#7B7D7D,stroke-width:2px;
    classDef user fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef flutter fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;
```
