# mantasdaskev/mediafon_tech_task architecture

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

- Interactive diagram: https://gitdiagram.com/mantasdaskev/mediafon_tech_task
- Repository: https://github.com/mantasdaskev/mediafon_tech_task

## Overview

##### Main Components

A. Frontend Layer (Angular):
- Login Component
- Submissions Component
- New Submission Component
- Services (API Service & State Hub Service)
- Models (Submission, Login, etc.)

B. Backend Layer (.NET Core):
- API Controllers (LoginController, SubmissionsController)
- SignalR Hub (SubmissionsStateHub)
- Business Logic Layer
- Data Access Layer
- Background Services

C. Database Layer:
- Main entities: Users and Submissions

##### Component Relationships and Interactions

A. Frontend-Backend Communication:

B. Backend Internal Flow:
- Layered architecture:
- Controllers → Business Logic → Data Access → Database
- Background Services → Business Logic
- SignalR Hub → Business Logic

##### Special Architectural Elements to Highlight

A. Real-time Updates System:
- Flow from SubmissionStateUpdater through SignalR to the client
- Queue-based update mechanism

B. Repository Pattern:
- Separation between business logic and data access
- Interface-based dependencies

C. Service Layer:
- Separation between controllers and business logic
- How services coordinate between different components

##### Additional Notes

- A title: "Mediafon Tech Task - System Architecture"
- Version/date information
- Notes about the authentication flow
- Real-time submission state update mechanism
- Separation of concerns between Core and Web projects

##### Technical Details

- Angular version
- .NET Core version
- SignalR for real-time communications
- Entity Framework Core for data access
- JWT authentication (if used)
- Database provider

## Diagram (Mermaid)

```mermaid
graph TB
    %% Title
    title[Mediafon Tech Task - System Architecture]:::title

    %% Frontend Layer
    subgraph Frontend
        LC["Login Component"]:::frontend
        SC["Submissions Component"]:::frontend
        NSC["New Submission Component"]:::frontend
        AS["API Service"]:::frontend
        SHS["State Hub Service"]:::frontend
        FM["Frontend Models"]:::frontend

        LC --> AS
        SC --> AS
        NSC --> AS
        SC --> SHS
        AS --> FM
        SHS --> FM
    end

    %% Backend API Layer
    subgraph API
        LoginC["Login Controller"]:::api
        SubC["Submissions Controller"]:::api
        SRH["SignalR Hub"]:::realtime
        SUS["State Updater Service"]:::realtime
        SUQ["Update Queue Provider"]:::realtime

        SUS --> SRH
        SUS --> SUQ
    end

    %% Business Logic Layer
    subgraph Business
        SS["Submissions Service"]:::business
        US["User Service"]:::business
        SI["Service Interfaces"]:::business

        SS --> SI
        US --> SI
    end

    %% Data Access Layer
    subgraph Data
        DC["DbContext"]:::data
        SR["Submissions Repository"]:::data
        UR["Users Repository"]:::data
        DM["Domain Models"]:::data

        SR --> DC
        UR --> DC
        SR --> DM
        UR --> DM
    end

    %% Database Layer
    DB[(Database)]:::database

    %% Cross-Layer Relationships
    AS --"HTTP"--> LoginC
    AS --"HTTP"--> SubC
    SHS --"WebSocket"--> SRH
    LoginC --> US
    SubC --> SS
    SS --> SR
    US --> UR
    DC --> DB

    %% Component Click Events
    click LC "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src-node/mediafon-tech-task/src/app/login/login.component.ts"
    click SC "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src-node/mediafon-tech-task/src/app/submissions/submissions.component.ts"
    click NSC "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src-node/mediafon-tech-task/src/app/new-submission/new-submission.component.ts"
    click AS "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src-node/mediafon-tech-task/src/app/services/submissions.api.service.ts"
    click SHS "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src-node/mediafon-tech-task/src/app/services/submissions.state.hub.service.ts"
    click FM "https://github.com/mantasdaskev/mediafon_tech_task/tree/main/src-node/mediafon-tech-task/src/app/models"
    click LoginC "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src/MediafonTechTask/Controllers/LoginController.cs"
    click SubC "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src/MediafonTechTask/Controllers/SubmissionsController.cs"
    click SRH "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src/MediafonTechTask/Hubs/SubmissionsStateHub.cs"
    click SUS "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src/MediafonTechTask/Services/SubmissionStateUpdater.cs"
    click SUQ "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src/MediafonTechTask/Services/SubmissionUpdateQueueProvider.cs"
    click SS "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src/MediafonTechTask.Core/BusinessLogic/Services/SubmissionsService.cs"
    click US "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src/MediafonTechTask.Core/BusinessLogic/Services/UserService.cs"
    click SI "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src/MediafonTechTask.Core/BusinessLogic/Services/ISubmissionsService.cs"
    click DC "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src/MediafonTechTask.Core/Data/SubmissionsDbContext.cs"
    click SR "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src/MediafonTechTask.Core/Data/Repositories/SubmissionsRepository.cs"
    click UR "https://github.com/mantasdaskev/mediafon_tech_task/blob/main/src/MediafonTechTask.Core/Data/Repositories/UsersRepository.cs"
    click DM "https://github.com/mantasdaskev/mediafon_tech_task/tree/main/src/MediafonTechTask.Core/Models"

    %% Styling
    classDef title fill:#f9f,stroke:#333,stroke-width:4px
    classDef frontend fill:#a8d1f0,stroke:#333
    classDef api fill:#90EE90,stroke:#333
    classDef realtime fill:#ff9999,stroke:#333
    classDef business fill:#ffeb99,stroke:#333
    classDef data fill:#ffb366,stroke:#333
    classDef database fill:#d9b3ff,stroke:#333

    %% Legend
    subgraph Legend
        L1[Frontend Components]:::frontend
        L2[API Layer]:::api
        L3[Real-time Components]:::realtime
        L4[Business Logic]:::business
        L5[Data Access]:::data
        L6[(Database)]:::database
    end
```
