# rajvardhant/infoniche architecture

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

- Interactive diagram: https://gitdiagram.com/rajvardhant/infoniche
- Repository: https://github.com/rajvardhant/infoniche

## Overview

##### Project Type and Purpose
- This is a cross-platform Flutter news application (Android, iOS, Web, Windows, Linux, macOS).
- Purpose: fetch and display real-time news, current affairs, quizzes, user profiles, bookmarks and support offline storage, voice search, sharing, theming.

##### File Structure
- Top-level “android/”, “ios/”, “web/”, “linux/”, “macos/”, “windows/” directories: platform-specific embedding and native code.
- “lib/” directory: core app code, organized by MVC:
- lib/view/ – UI screens (Widgets)
- lib/controller/ – GetX controllers (business logic & routing)
- lib/model/ – Data models (from JSON/API)
- lib/repositry/ – Data access layer (API, local cache)
- lib/utils/ – Helpers (string utilities, date formatting)
- lib/view_model/ – (If used) view-specific state transformations
- “assets/” for images, “pubspec.yaml” for dependencies, test/ for widget tests.

##### README Insights
- Uses GetX for state management & routing, MVC pattern.
- Dependencies: http (REST API), get_storage/shared_preferences (local persistence), cached_network_image, speech_to_text, image_picker, permission_handler, shimmer, flutter_rating_bar, google_nav_bar.

##### Main Components
a. Presentation Layer (Flutter UI)
- View Widgets: HomeScreen, NewsDetailScreen, QuizScreen, ProfileScreen, etc.
- Theme management (light/dark)
- Native plugins: image_picker, speech_to_text, permission_handler
b. State Management Layer
- GetX Controllers: NewsController, BookmarkController, ThemeController, LanguageController, etc.
- Routing via GetX
c. Data Layer
- Repositories/Services:
- NewsRepository: HTTP calls to external News API
- CurrentAffairsRepository
- LocalStorageService: get_storage/shared_preferences wrapper
- HTTP Client: “http” library
- Caching: get_storage and cached_network_image
d. Domain Models
- Article, User, Source, Category, CurrentAffairs, Quiz, etc.
e. External & Platform Services
- External News API (REST endpoint)
- Native OS (speech recognition, image selection, share sheet)
- Device local storage (file system, shared preferences)
f. Cross-cutting Utilities
- Logging, string_utils, error handling

##### Relationships & Data Flows
- User taps UI → View sends event to Controller.
- Controller checks cache via LocalStorageService; if stale or offline, calls Repository.
- Repository issues HTTP request to News API.
- API returns JSON → Repository parses into Model objects.
- Controller updates Observables → View reacts and rebuilds UI.
- Bookmark actions write to local DB or shared_preferences.
- Voice search invokes speech_to_text plugin → Controller processes transcription → triggers search.

##### Architectural Patterns & Principles
- MVC with clear separation of concerns.
- Unidirectional data flow: View → Controller → Repository → API/Local → Model → Controller → View.
- Dependency inversion: Controllers depend on abstract repository interfaces.
- Caching and offline-first strategy.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Flutter Engine wrapper
    subgraph "Flutter Engine"
        %% Presentation Layer
        subgraph "Presentation Layer" 
            HomeScreen["HomeScreen"]:::presentation
            NewsDetailScreen["NewsDetailScreen"]:::presentation
            QuizScreen["QuizScreen"]:::presentation
            ProfileScreen["ProfileScreen"]:::presentation
            BookmarkScreen["BookmarkScreen"]:::presentation
            CategoriesScreen["CategoriesScreen"]:::presentation
            CurrentAffairsScreen["CurrentAffairsScreen"]:::presentation
            HistoricalNewsScreen["HistoricalNewsScreen"]:::presentation
            InterestScreen["InterestSelectionScreen"]:::presentation
            LanguageScreen["LanguageSelectionScreen"]:::presentation
            SearchScreen["SearchScreen"]:::presentation
            SplashScreen["SplashScreen"]:::presentation
        end

        %% State Management Layer
        subgraph "State Management Layer" 
            BookmarkController["BookmarkController"]:::state
            CurrentAffairsController["CurrentAffairsController"]:::state
            HistoricalNewsController["HistoricalNewsController"]:::state
            InterestController["InterestController"]:::state
            LanguageController["LanguageController"]:::state
            ThemeController["ThemeController"]:::state
            UserProfileController["UserProfileController"]:::state
        end

        %% Data Layer
        subgraph "Data Layer" 
            NewsRepository["NewsRepository"]:::data
            CurrentAffairsRepository["CurrentAffairsRepository"]:::data
            LocalStorageService["LocalStorageService"]:::storage
            CachedNetworkImage["CachedNetworkImage"]:::storage
        end

        %% Domain Models
        subgraph "Domain Models" 
            CategoriesModel["CategoriesModel"]:::domain
            CurrentAffairsModel["CurrentAffairsModel"]:::domain
            HistoricalNewsModel["HistoricalNewsModel"]:::domain
            ChannelHeadlinesModel["NewsChannelHeadlinesModel"]:::domain
            SearchNewsModel["SearchNewsModel"]:::domain
        end

        %% Utilities
        subgraph "Utilities" 
            StringUtils["StringUtils"]:::utils
        end
    end

    %% External & Plugins
    subgraph "External & Platform Services"
        NewsAPI["External News API"]:::external
        SpeechToText["speech_to_text"]:::plugin
        ImagePicker["image_picker"]:::plugin
        PermissionHandler["permission_handler"]:::plugin
    end

    %% Storage
    DeviceStorage["Device Local Storage"]:::storage

    %% Data Flows
    SplashScreen -->|"initRoute"| LanguageController -->|"setLanguage() "| HomeScreen
    HomeScreen -->|"tap article"| NewsDetailScreen
    HomeScreen -->|"tap quiz"| QuizScreen
    HomeScreen -->|"tap profile"| ProfileScreen
    HomeScreen -->|"tap bookmarks"| BookmarkScreen
    HomeScreen -->|"tap categories"| CategoriesScreen
    HomeScreen -->|"tap current affairs"| CurrentAffairsScreen
    HomeScreen -->|"tap history"| HistoricalNewsScreen
    HomeScreen -->|"tap interests"| InterestScreen
    HomeScreen -->|"tap search"| SearchScreen

    %% Presentation to State
    HomeScreen -->|"fetchNews() "| NewsController((NewsController)):::state
    NewsDetailScreen -->|"loadDetail() "| NewsController
    QuizScreen -->|"loadQuiz() "| InterestController
    ProfileScreen -->|"loadProfile() "| UserProfileController
    BookmarkScreen -->|"manageBookmarks() "| BookmarkController
    CategoriesScreen -->|"selectCategory() "| LanguageController
    CurrentAffairsScreen -->|"fetchAffairs() "| CurrentAffairsController
    HistoricalNewsScreen -->|"fetchHistory() "| HistoricalNewsController
    InterestScreen -->|"selectInterest() "| InterestController
    LanguageScreen -->|"changeLanguage() "| LanguageController
    SearchScreen -->|"voiceSearch() "| SpeechToText

    %% State to Data
    NewsController -->|"fetchNews() "| NewsRepository
    CurrentAffairsController -->|"getAffairs() "| CurrentAffairsRepository
    HistoricalNewsController -->|"getHistory() "| NewsRepository
    BookmarkController -->|"saveBookmark() "| LocalStorageService
    InterestController -->|"saveInterest() "| LocalStorageService
    UserProfileController -->|"saveProfile() "| LocalStorageService
    LanguageController -->|"saveLanguage() "| LocalStorageService
    ThemeController -->|"saveTheme() "| LocalStorageService

    %% Data to External/API
    NewsRepository -->|"GET /news"| NewsAPI
    CurrentAffairsRepository -->|"GET /affairs"| NewsAPI

    %% Caching and Storage
    NewsRepository -->|"cacheImage() "| CachedNetworkImage
    NewsRepository -->|"cacheData() "| LocalStorageService
    BookmarkController -->|"read/write"| DeviceStorage

    %% Models Flow
    NewsRepository -->|"map to model"| CategoriesModel
    NewsRepository -->|"map to model"| ChannelHeadlinesModel
    CurrentAffairsRepository -->|"map to model"| CurrentAffairsModel
    HistoricalNewsController -->|"map to model"| HistoricalNewsModel
    SearchScreen -->|"map to model"| SearchNewsModel

    %% Utilities usage
    any -->|"format() "| StringUtils

    %% Click Events
    click HomeScreen "https://github.com/rajvardhant/infoniche/blob/main/lib/view/home_screen.dart"
    click NewsDetailScreen "https://github.com/rajvardhant/infoniche/blob/main/lib/view/news_detail_screen.dart"
    click QuizScreen "https://github.com/rajvardhant/infoniche/blob/main/lib/view/quiz_screen.dart"
    click ProfileScreen "https://github.com/rajvardhant/infoniche/blob/main/lib/view/profile_screen.dart"
    click BookmarkScreen "https://github.com/rajvardhant/infoniche/blob/main/lib/view/bookmark_screen.dart"
    click CategoriesScreen "https://github.com/rajvardhant/infoniche/blob/main/lib/view/categories_screen.dart"
    click CurrentAffairsScreen "https://github.com/rajvardhant/infoniche/blob/main/lib/view/current_affairs_screen.dart"
    click HistoricalNewsScreen "https://github.com/rajvardhant/infoniche/blob/main/lib/view/historical_news_screen.dart"
    click InterestScreen "https://github.com/rajvardhant/infoniche/blob/main/lib/view/interest_screen.dart"
    click LanguageScreen "https://github.com/rajvardhant/infoniche/blob/main/lib/view/language_screen.dart"
    click SearchScreen "https://github.com/rajvardhant/infoniche/blob/main/lib/view/search_screen.dart"
    click SplashScreen "https://github.com/rajvardhant/infoniche/blob/main/lib/view/splash_screen.dart"

    click BookmarkController "https://github.com/rajvardhant/infoniche/blob/main/lib/controller/bookmark_controller.dart"
    click CurrentAffairsController "https://github.com/rajvardhant/infoniche/blob/main/lib/controller/current_affairs_controller.dart"
    click HistoricalNewsController "https://github.com/rajvardhant/infoniche/blob/main/lib/controller/historical_news_controller.dart"
    click InterestController "https://github.com/rajvardhant/infoniche/blob/main/lib/controller/interest_controller.dart"
    click LanguageController "https://github.com/rajvardhant/infoniche/blob/main/lib/controller/language_controller.dart"
    click ThemeController "https://github.com/rajvardhant/infoniche/blob/main/lib/controller/theme_controller.dart"
    click UserProfileController "https://github.com/rajvardhant/infoniche/blob/main/lib/controller/user_profile_controller.dart"

    click NewsRepository "https://github.com/rajvardhant/infoniche/blob/main/lib/repositry/news_repository.dart"
    click CurrentAffairsRepository "https://github.com/rajvardhant/infoniche/blob/main/lib/repositry/current_affairs_repository.dart"

    click CategoriesModel "https://github.com/rajvardhant/infoniche/blob/main/lib/model/categories_new_model.dart"
    click CurrentAffairsModel "https://github.com/rajvardhant/infoniche/blob/main/lib/model/current_affairs_model.dart"
    click HistoricalNewsModel "https://github.com/rajvardhant/infoniche/blob/main/lib/model/historical_news_model.dart"
    click ChannelHeadlinesModel "https://github.com/rajvardhant/infoniche/blob/main/lib/model/news_channel_headlines_modle.dart"
    click SearchNewsModel "https://github.com/rajvardhant/infoniche/blob/main/lib/model/search_news_model.dart"

    click StringUtils "https://github.com/rajvardhant/infoniche/blob/main/lib/utils/string_utils.dart"
    click Main "https://github.com/rajvardhant/infoniche/blob/main/lib/main.dart"

    %% Styles
    classDef presentation fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef state fill:#DFFFE0,stroke:#28A745,color:#28A745;
    classDef data fill:#FFE8D0,stroke:#D97706,color:#D97706;
    classDef domain fill:#F0E0FF,stroke:#6F42C1,color:#6F42C1;
    classDef utils fill:#F0F0F0,stroke:#6A737D,color:#6A737D;
    classDef storage fill:#FFF5D0,stroke:#D69E2E,color:#D69E2E;
    classDef external fill:#E0E0E0,stroke:#586069,color:#586069;
    classDef plugin fill:#FFF0D0,stroke:#D08770,color:#D08770;
```
