# tomfregonese/quizapp architecture

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

- Interactive diagram: https://gitdiagram.com/tomfregonese/quizapp
- Repository: https://github.com/tomfregonese/quizapp

## Overview

##### Project type and purpose
- This is a full-stack quiz application.
- Front-end is built in Angular (TypeScript) and serves the user interface.
- Back-end is an ASP.NET Core Web API written in C#, exposing REST endpoints and handling business logic.
- The application uses JSON files in a DataSet folder as its data store (for categories, quizzes, questions, users, progress).

##### File structure
A. Top-level separation
– Back.QuizApp: the API server
– Front.QuizApp: the Angular client
B. Backend layers (Back.QuizApp)
– Controllers: HTTP entry points, DTO definitions, mapping to domain models
– Business:
· IServices (interfaces for category, question, quiz, user, user-progress services)
· Models (domain entities: Category, Question, Answer, Quiz, User, UserQuizProgress)
· Services (implementations of the business logic, e.g., QuizService, TimerService)
– DataSet: JSON files acting as a file-based datastore
– Configuration: Program.cs, appsettings.json, launchSettings.json, .http test scripts
C. Frontend layers (Front.QuizApp/src/app)
– environment & app.config.ts: API base URLs and routing
– business: DTOs, models, mappers, services (CategoryService, QuizService, etc.)
– components: reusable UI pieces (dashboard, quiz-card, loading-spinner, error-dialog, quiz-question, user-header)
– pages: screen-level components (home, login, quiz-details)
– Angular module + routing definitions in app.routes.ts

##### README
- Minimal content (“# QuizApp”).

##### Detail but keep clarity
- Layers and their interactions without overcrowding.
- Five service interfaces (ICategoryService, IQuestionService, etc.) either aggregated as “Business Services” or individually if detail is needed.
- TimerService if quiz timing is a core feature.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Front-end Layer
    subgraph "Front-end (Angular UI)"
        Browser["User Browser"]:::external
        subgraph "Angular SPA"
            AUI["SPA: Front.QuizApp/src/app"]:::frontend
            subgraph "Routing & Config"
                AppRoutes["app.routes.ts"]:::frontend
                AppConfig["app.config.ts"]:::frontend
                Env["environment.ts"]:::frontend
            end
            subgraph "Business Layer"
                DTOs["DTOs"]:::frontend
                ModelsFE["Models"]:::frontend
                MappersFE["Mappers"]:::frontend
                ServicesFE["Services"]:::frontend
            end
            subgraph "UI Components"
                Dash["DashboardComponent"]:::frontend
                Card["QuizCardComponent"]:::frontend
                QuestionUI["QuizQuestionComponent"]:::frontend
                Spinner["LoadingSpinnerComponent"]:::frontend
                ErrorUI["ErrorDialogComponent"]:::frontend
                Header["UserHeaderComponent"]:::frontend
            end
            subgraph "Pages"
                Home["HomePage"]:::frontend
                Login["LoginPage"]:::frontend
                Details["QuizDetailsPage"]:::frontend
            end
        end
    end

    %% Back-end Layer
    subgraph "Back-end (ASP.NET Core API)"
        subgraph "Controllers (API Layer)"
            CatCtrl["CategoryController"]:::api
            QuesCtrl["QuestionController"]:::api
            QuizCtrl["QuizController"]:::api
            UserCtrl["UserController"]:::api
            ProgressCtrl["UserQuizProgressController"]:::api
        end
        subgraph "Business Layer"
            Interfaces["IServices Interfaces"]:::service
            ModelsBE["Domain Models"]:::service
            ServicesBE["Service Implementations"]:::service
            Timer["TimerService"]:::service
        end
        subgraph "Data Store"
            JSONStore["JSON DataSet"]:::datastore
        end
        subgraph "Configuration & Startup"
            Program["Program.cs"]:::api
            AppSettings["appsettings.json"]:::api
            Launch["launchSettings.json"]:::api
            HttpTests["Ynov.QuizApp.http"]:::api
        end
    end

    %% Future Database
    FutureDB["Future Database"]:::external

    %% Data Flows
    Browser -->|"interacts"| AUI
    AUI -->|"reads config"| AppConfig
    AUI -->|"loads routes"| AppRoutes
    AUI -->|"uses services"| ServicesFE
    ServicesFE -->|"HTTP/JSON"| CatCtrl
    ServicesFE -->|"HTTP/JSON"| QuesCtrl
    ServicesFE -->|"HTTP/JSON"| QuizCtrl
    ServicesFE -->|"HTTP/JSON"| UserCtrl
    ServicesFE -->|"HTTP/JSON"| ProgressCtrl

    CatCtrl -->|"map DTO→Model"| Interfaces
    QuesCtrl -->|"map DTO→Model"| Interfaces
    QuizCtrl -->|"map DTO→Model"| Interfaces
    UserCtrl -->|"map DTO→Model"| Interfaces
    ProgressCtrl -->|"map DTO→Model"| Interfaces

    Interfaces -->|"invoke"| ServicesBE
    ServicesBE -->|"read/write"| JSONStore
    Timer -->|"schedule events"| ServicesBE
    JSONStore -->|"data response"| ServicesBE

    ServicesBE -->|"return model"| Interfaces
    Interfaces -->|"map Model→DTO"| CatCtrl
    Interfaces -->|"map Model→DTO"| QuesCtrl
    Interfaces -->|"map Model→DTO"| QuizCtrl
    Interfaces -->|"map Model→DTO"| UserCtrl
    Interfaces -->|"map Model→DTO"| ProgressCtrl

    CatCtrl -->|"HTTP response"| ServicesFE
    QuesCtrl -->|"HTTP response"| ServicesFE
    QuizCtrl -->|"HTTP response"| ServicesFE
    UserCtrl -->|"HTTP response"| ServicesFE
    ProgressCtrl -->|"HTTP response"| ServicesFE

    %% Optional future DB
    ServicesBE -.->|"future persistence"| FutureDB

    %% Click Events Front-end
    click AUI "https://github.com/tomfregonese/quizapp/tree/main/Front.QuizApp/src/app"
    click AppRoutes "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/app.routes.ts"
    click AppConfig "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/app.config.ts"
    click Env "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/environment/environment.ts"
    click DTOs "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/business/dtos/*.dto.ts"
    click ModelsFE "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/business/models/*.model.ts"
    click MappersFE "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/business/mappers/*.mapper.ts"
    click ServicesFE "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/business/services/*.service.ts"
    click Dash "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/components/dashboard/dashboard.component.ts"
    click Card "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/components/quiz-card/quiz-card.component.ts"
    click QuestionUI "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/components/quiz-question/quiz-question.component.ts"
    click Spinner "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/components/loading-spinner/loading-spinner.component.ts"
    click ErrorUI "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/components/error-dialog/error-dialog.component.ts"
    click Header "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/components/user-header/user-header.component.ts"
    click Home "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/pages/home/home.page.ts"
    click Login "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/pages/login/login.page.ts"
    click Details "https://github.com/tomfregonese/quizapp/blob/main/Front.QuizApp/src/app/pages/quiz-details/quiz-details.page.ts"

    %% Click Events Back-end
    click CatCtrl "https://github.com/tomfregonese/quizapp/blob/main/Back.QuizApp/Controllers/CategoryController.cs"
    click QuesCtrl "https://github.com/tomfregonese/quizapp/blob/main/Back.QuizApp/Controllers/QuestionController.cs"
    click QuizCtrl "https://github.com/tomfregonese/quizapp/blob/main/Back.QuizApp/Controllers/QuizController.cs"
    click UserCtrl "https://github.com/tomfregonese/quizapp/blob/main/Back.QuizApp/Controllers/UserController.cs"
    click ProgressCtrl "https://github.com/tomfregonese/quizapp/blob/main/Back.QuizApp/Controllers/UserQuizProgressController.cs"
    click Interfaces "https://github.com/tomfregonese/quizapp/blob/main/Back.QuizApp/Business/IServices/*.cs"
    click ModelsBE "https://github.com/tomfregonese/quizapp/blob/main/Back.QuizApp/Business/Models/*.cs"
    click ServicesBE "https://github.com/tomfregonese/quizapp/blob/main/Back.QuizApp/Business/Services/*.cs"
    click Timer "https://github.com/tomfregonese/quizapp/blob/main/Back.QuizApp/Business/Services/TimerService.cs"
    click JSONStore "https://github.com/tomfregonese/quizapp/blob/main/Back.QuizApp/DataSet/*.json"
    click Program "https://github.com/tomfregonese/quizapp/blob/main/Back.QuizApp/Program.cs"
    click AppSettings "https://github.com/tomfregonese/quizapp/blob/main/Back.QuizApp/appsettings.json"
    click Launch "https://github.com/tomfregonese/quizapp/blob/main/Back.QuizApp/Properties/launchSettings.json"
    click HttpTests "https://github.com/tomfregonese/quizapp/blob/main/Back.QuizApp/Ynov.QuizApp.http"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#3399ff;
    classDef api fill:#d4edda,stroke:#28a745;
    classDef service fill:#fff3cd,stroke:#ffcd3c;
    classDef datastore fill:#e2e3e5,stroke:#6c757d;
    classDef external fill:#f8d7da,stroke:#dc3545;
```
