# transinh085/examify architecture

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

- Interactive diagram: https://gitdiagram.com/transinh085/examify
- Repository: https://github.com/transinh085/examify

## Overview

##### High-Level Architecture Components

- Client Layer
- API Gateway Layer
- Microservices Layer
- Infrastructure Layer

##### Detailed Component Breakdown

a) Client Layer:
- React-based WebClient (Examify.WebClient)
- Frontend features (Authentication, Quiz Management, Real-time Updates)
- To Gateway using HTTP/REST

b) API Gateway Layer (Examify.Gateway):
- YARP reverse proxy
- Routing paths to different microservices
- Authentication/authorization middleware

- Identity Service (Examify.Identity)
- User management
- Authentication
- Authorization

- Catalog Service (Examify.Catalog)
- Grade management
- Subject management
- Language management

- Quiz Service (Examify.Quiz)
- Quiz creation/management
- Question management
- Quiz execution

- Result Service (Examify.Result)
- Quiz results processing
- Performance analytics
- Score management

- Notification Service (Examify.Notification)
- Email notifications
- Real-time notifications via SignalR
- Event handling

- Upload Service (Examify.UploadFile)
- File management
- Image processing

d) Infrastructure Layer:
- Databases (PostgreSQL)
- Cache (Redis)
- Message Broker (RabbitMQ)
- Storage (Cloudinary)

##### Cross-Cutting Concerns

As vertical layers:
- OpenTelemetry (monitoring)
- Logging
- Authentication/Authorization
- Caching

##### Additional Elements

Include:
- Service boundaries
- Data flow directions
- Security boundaries

##### Key Relationships to Highlight

- How the Gateway routes requests to appropriate services
- Event-driven communication between services
- Demonstrate how the notification service integrates with others
- Authentication flow through the Identity service

##### Implementation Details

Architectural patterns:
- CQRS (Command Query Responsibility Segregation) in services
- Mediator pattern using MediatR
- Repository pattern for data access
- Event-driven architecture using MassTransit

- Layered architecture representation
- Clear labeling and annotations
- Export to high-resolution formats

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef gateway fill:#e74c3c,stroke:#c0392b,color:white
    classDef service fill:#2ecc71,stroke:#27ae60,color:white
    classDef infrastructure fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef database fill:#34495e,stroke:#2c3e50,color:white
    classDef messaging fill:#e67e22,stroke:#d35400,color:white
    classDef storage fill:#9b59b6,stroke:#8e44ad,color:white

    %% Client Layer
    subgraph ClientLayer
        WebClient["React WebClient"]:::frontend
    end
    click WebClient "https://github.com/transinh085/Examify/tree/main/Examify.WebClient/src/"

    %% API Gateway Layer
    subgraph GatewayLayer
        Gateway["API Gateway (YARP)"]:::gateway
        Auth["Auth Middleware"]:::gateway
    end
    click Gateway "https://github.com/transinh085/Examify/tree/main/Examify.Gateway/"
    click Auth "https://github.com/transinh085/Examify/blob/main/Examify.Gateway/Program.cs"

    %% Microservices Layer
    subgraph MicroservicesLayer
        %% Identity Service
        subgraph IdentityService
            Identity["Identity Service"]:::service
            UserMgmt["User Management"]:::service
            AuthN["Authentication"]:::service
        end
        click Identity "https://github.com/transinh085/Examify/tree/main/Examify.Identity/"
        click UserMgmt "https://github.com/transinh085/Examify/tree/main/Examify.Identity/Features/Command/CreateUser/"
        click AuthN "https://github.com/transinh085/Examify/tree/main/Examify.Identity/Features/Command/Login/"

        %% Catalog Service
        subgraph CatalogService
            Catalog["Catalog Service"]:::service
            Grades["Grade Management"]:::service
            Subjects["Subject Management"]:::service
            Languages["Language Management"]:::service
        end
        click Catalog "https://github.com/transinh085/Examify/tree/main/Examify.Catalog/"
        click Grades "https://github.com/transinh085/Examify/tree/main/Examify.Catalog/Features/Grades/"
        click Subjects "https://github.com/transinh085/Examify/tree/main/Examify.Catalog/Features/Subject/"
        click Languages "https://github.com/transinh085/Examify/tree/main/Examify.Catalog/Features/Languages/"

        %% Quiz Service
        subgraph QuizService
            Quiz["Quiz Service"]:::service
            QuizMgmt["Quiz Management"]:::service
            Questions["Question Management"]:::service
        end
        click Quiz "https://github.com/transinh085/Examify/tree/main/Examify.Quiz/"
        click QuizMgmt "https://github.com/transinh085/Examify/tree/main/Examify.Quiz/Features/Quiz/"
        click Questions "https://github.com/transinh085/Examify/tree/main/Examify.Quiz/Features/Questions/"

        %% Result Service
        subgraph ResultService
            Result["Result Service"]:::service
            ResultProc["Result Processing"]:::service
            Analytics["Analytics"]:::service
        end
        click Result "https://github.com/transinh085/Examify/tree/main/Examify.Result/"
        click ResultProc "https://github.com/transinh085/Examify/tree/main/Examify.Result/Features/"
        click Analytics "https://github.com/transinh085/Examify/tree/main/Examify.Result/Features/Query/"

        %% Notification Service
        subgraph NotificationService
            Notification["Notification Service"]:::service
            Email["Email Notifications"]:::service
            RealTime["Real-time Notifications"]:::service
        end
        click Notification "https://github.com/transinh085/Examify/tree/main/Examify.Notification/"
        click Email "https://github.com/transinh085/Examify/tree/main/Examify.Notification/Infrastructure/Mail/"
        click RealTime "https://github.com/transinh085/Examify/blob/main/Examify.Notification/Hubs/NotificationHub.cs"

        %% Upload Service
        subgraph UploadService
            Upload["Upload Service"]:::service
            FileMgmt["File Management"]:::service
        end
        click Upload "https://github.com/transinh085/Examify/tree/main/Examify.UploadFile/"
        click FileMgmt "https://github.com/transinh085/Examify/tree/main/Examify.UploadFile/Features/UploadImage/"
    end

    %% Infrastructure Layer
    subgraph InfrastructureLayer
        PostgreSQL[(PostgreSQL)]:::database
        Redis[(Redis Cache)]:::database
        RabbitMQ{{"RabbitMQ"}}:::messaging
        Cloudinary[("Cloudinary Storage")]:::storage
        CrossCutting["Cross-cutting Concerns"]:::infrastructure
    end
    click CrossCutting "https://github.com/transinh085/Examify/tree/main/Examify.Infrastructure/"

    %% Connections
    WebClient --> Gateway
    Gateway --> Auth
    Auth --> Identity
    Gateway --> |HTTP/gRPC| Catalog
    Gateway --> |HTTP/gRPC| Quiz
    Gateway --> |HTTP/gRPC| Result
    Gateway --> |HTTP/gRPC| Upload
    Gateway --> |WebSocket| Notification

    %% Service Interconnections
    Quiz -.-> RabbitMQ
    Result -.-> RabbitMQ
    RabbitMQ -.-> Notification
    
    %% Infrastructure Connections
    Identity --- PostgreSQL
    Catalog --- PostgreSQL
    Quiz --- PostgreSQL
    Result --- PostgreSQL
    Notification --- PostgreSQL
    Upload --- Cloudinary
    
    %% Cache Connections
    Quiz --- Redis
    Result --- Redis

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        GatewayComp["Gateway Component"]:::gateway
        ServiceComp["Microservice"]:::service
        InfraComp["Infrastructure"]:::infrastructure
        DBComp[(Database)]:::database
        MsgComp{{"Message Broker"}}:::messaging
        StorageComp[("Storage")]:::storage
    end
```
