# mohamedhamdysoftwareengineer/novaed architecture

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

- Interactive diagram: https://gitdiagram.com/mohamedhamdysoftwareengineer/novaed
- Repository: https://github.com/mohamedhamdysoftwareengineer/novaed

## Overview

##### Project Type & Purpose
- A multi‐platform Flutter front-end (Android, iOS, Web, Windows, macOS, Linux) implementing an interactive quiz & learning management system.
- Follows MVVM (Model-View-ViewModel) with Cubit (BLoC) for state management.
- Integrates with an external .NET backend (RESTful API) for data persistence and business logic.

##### High-Level File Structure Analysis
- Top-level directories for each target platform (android/, ios/, web/, windows/, macos/, linux/)—all running the same Flutter code.
- lib/ contains the app code:
- core/: shared services (api_service.dart, auth_http_client.dart), utilities (routing, constants, responsive helpers) and common widgets.
- features/: each feature (“LogIn”, “User Profile”, “Choice Screen”, “Quiz Screen”, “Home”, “Splash”) split into:
– data/models: JSON models for API payloads
– presentation/manager: Cubits (ViewModels) + states
– presentation/views: Flutter UI (Views + Widgets)
- main.dart: application entry, sets up routing, theming, and initial Cubit providers.
- pubspec.yaml: dependencies (flutter, bloc, http, etc.) and asset declarations.

##### Key Components
a. Presentation Layer (Views)
– Widgets under lib/features/.../views & views/widgets
– SplashView, LoginView, HomeView, ChoiceScreen, QuizScreen, UserProfileView
– Core widgets: BaseScaffold, CustomAppBar, BottomBar, ErrorScreen

b. ViewModel Layer (Cubits)
– auth_cubit (LogIn), profile_cubit (User Profile), submission_cubit (Choice), question_cubit (Quiz)
– Manage UI state and user interactions

c. Model Layer
– Data classes (user_model.dart, quiz_models.dart) mapping JSON ↔ Dart objects

d. Services Layer
– ApiService: general HTTP client wrapper
– AuthHttpClient: authenticated HTTP calls
– AuthService: login/logout token management
– (Future) other domain services: QuizService, ProfileService

e. External Backend & Persistence
– .NET REST API Server (Authentication, Quiz, Profile, Choice endpoints)
– Database (e.g., SQL Server) behind the .NET layer

f. Infrastructure & Assets
– Flutter Engine & Platform Channels (managed by generated files in android/, ios/, etc.)
– Local assets: fonts (assets/fonts), images (assets/images)

##### Relationships & Data Flow
- User taps a View → triggers Cubit event → Cubit calls appropriate Service → Service issues HTTP request → .NET API → Database → response JSON → mapped to Model → Cubit emits new state → View updates UI.
- Navigation: handled by AppRouter (core/utils/app_router.dart), pushes/pops Views based on Cubit states or user actions.

##### Architectural Patterns & Principles
- MVVM:
- View only renders UI and listens to Cubit state
- ViewModel (Cubit) contains business logic and orchestrates Services
- Model handles data structures and JSON serialization
- Separation of Concerns: UI, state management, network access, and data models are decoupled.
- Reactive Programming: Cubit streams drive UI updates.
- Scalability & Testability: each layer can be unit tested independently (see test/widget_test.dart).

- Clear component labels (e.g., “QuizScreenView”, “QuestionCubit”, “QuizService”, “QuizModel”).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        SplashView["SplashView"]:::ui
        LoginView["LoginView"]:::ui
        HomeView["HomeView"]:::ui
        ChoiceScreen["ChoiceScreen"]:::ui
        QuizScreen["QuizScreen"]:::ui
        UserProfileView["UserProfileView"]:::ui
        BaseScaffold["BaseScaffold"]:::ui
        CustomAppBar["CustomAppBar"]:::ui
        CustomBottomBar["CustomBottomBar"]:::ui
        ErrorScreen["ErrorScreen"]:::ui
    end

    %% ViewModel Layer
    subgraph "ViewModel Layer (Cubits)"
        direction TB
        AuthCubit["AuthCubit"]:::vm
        ProfileCubit["ProfileCubit"]:::vm
        SubmissionCubit["SubmissionCubit"]:::vm
        QuestionCubit["QuestionCubit"]:::vm
    end

    %% Data Model Layer
    subgraph "Data Model Layer"
        direction TB
        UserModel["UserModel"]:::model
        QuizModels["QuizModels"]:::model
    end

    %% Services Layer
    subgraph "Services Layer"
        direction TB
        ApiService["ApiService"]:::service
        AuthHttpClient["AuthHttpClient"]:::service
        AuthService["AuthService"]:::service
    end

    %% Infrastructure
    subgraph "Infrastructure & Routing"
        direction TB
        AppRouter["AppRouter"]:::infra
        MainEntry["main.dart"]:::infra
        Assets["Assets (fonts/images)"]:::infra
        Pubspec["pubspec.yaml"]:::infra
    end

    %% External Systems
    subgraph "External Backend"
        direction TB
        DotNetAPI[".NET Core Web API"]:::external
        Database["SQL Database"]:::external
    end

    %% Navigation Flow
    AppRouter -->|"routes to"| SplashView
    AppRouter -->|"routes to"| LoginView
    AppRouter -->|"routes to"| HomeView
    AppRouter -->|"routes to"| ChoiceScreen
    AppRouter -->|"routes to"| QuizScreen
    AppRouter -->|"routes to"| UserProfileView

    MainEntry -->|"initializes"| AppRouter
    MainEntry -->|"provides Cubits"| AuthCubit
    MainEntry -->|"provides Cubits"| ProfileCubit
    MainEntry -->|"provides Cubits"| SubmissionCubit
    MainEntry -->|"provides Cubits"| QuestionCubit

    %% Interaction & Data Flow
    SplashView -->|"trigger auth check"| AuthCubit
    LoginView -->|"login intent"| AuthCubit
    HomeView -->|"load profile"| ProfileCubit
    ChoiceScreen -->|"submit choice"| SubmissionCubit
    QuizScreen -->|"load questions"| QuestionCubit
    UserProfileView -->|"edit profile"| ProfileCubit

    AuthCubit -->|"calls"| AuthService
    ProfileCubit -->|"calls"| ApiService
    SubmissionCubit -->|"calls"| ApiService
    QuestionCubit -->|"calls"| ApiService

    AuthService -->|"uses"| AuthHttpClient
    ApiService -->|"uses"| AuthHttpClient

    AuthHttpClient -->|"HTTP/REST"| DotNetAPI
    DotNetAPI -->|"query/update"| Database
    Database -->|"response JSON"| DotNetAPI
    DotNetAPI -->|"response JSON"| AuthHttpClient

    AuthHttpClient -->|"resp data"| ApiService
    ApiService -->|"maps to"| UserModel
    ApiService -->|"maps to"| QuizModels

    UserModel -->|"state update"| AuthCubit
    QuizModels -->|"state update"| QuestionCubit

    AuthCubit -->|"state change"| SplashView
    AuthCubit -->|"state change"| LoginView
    ProfileCubit -->|"state change"| HomeView
    SubmissionCubit -->|"state change"| ChoiceScreen
    QuestionCubit -->|"state change"| QuizScreen

    %% Click Events
    click SplashView "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/features/splash/presentation/views/splash_view.dart"
    click LoginView "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/features/LogIn/presentation/views/login.dart"
    click HomeView "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/features/home/presentation/views/home_view.dart"
    click ChoiceScreen "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/features/choice_screen/presentation/views/choice_screen.dart"
    click QuizScreen "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/features/quiz_screen/presentation/views/quiz_screen.dart"
    click UserProfileView "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/features/User Profile/Presentation/views/user_profile.dart"
    click BaseScaffold "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/core/widgets/base_scaffold.dart"
    click CustomAppBar "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/core/widgets/custom_app_bar.dart"
    click CustomBottomBar "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/core/widgets/custom_bottom_bar.dart"
    click ErrorScreen "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/core/widgets/error_screen.dart"
    click AuthCubit "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/features/LogIn/presentation/manager/auth_cubit.dart"
    click ProfileCubit "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/features/User Profile/Presentation/manager/profile_cubit.dart"
    click SubmissionCubit "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/features/choice_screen/presentation/manager/submission_cubit.dart"
    click QuestionCubit "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/features/quiz_screen/presentation/manager/question_cubit.dart"
    click UserModel "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/features/LogIn/data/models/user_model.dart"
    click QuizModels "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/features/quiz_screen/data/models/quiz_models.dart"
    click ApiService "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/core/services/api_service.dart"
    click AuthHttpClient "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/core/services/auth_http_client.dart"
    click AuthService "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/core/services/auth_service.dart"
    click AppRouter "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/core/utils/app_router.dart"
    click MainEntry "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/lib/main.dart"
    click Assets "https://github.com/mohamedhamdysoftwareengineer/novaed/tree/main/assets/fonts/"
    click Assets "https://github.com/mohamedhamdysoftwareengineer/novaed/tree/main/assets/images/"
    click Pubspec "https://github.com/mohamedhamdysoftwareengineer/novaed/blob/main/pubspec.yaml"

    %% Styling
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#03396c;
    classDef vm fill:#DFF7D8,stroke:#2f8f17,color:#196F3D;
    classDef service fill:#FFF5C3,stroke:#D4A017,color:#7D6608;
    classDef model fill:#FFE3C1,stroke:#D98880,color:#943126;
    classDef infra fill:#E8E8E8,stroke:#A6A6A6,color:#333333;
    classDef external fill:#FFD6D6,stroke:#D62020,color:#8B0000;
```
