# learnsmartcoding/smartcertify-api-clean-architecture-dotnet9 architecture

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

- Interactive diagram: https://gitdiagram.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9
- Repository: https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9

## Overview

##### Project Type & Purpose
- This is a Clean-Architecture .NET 9 Web API for an online course certification platform (“SmartCertify”).
- It follows a layered architecture (API, Application, Domain, Infrastructure) to enforce separation of concerns, maintainability, and testability.

##### File Structure Analysis
- Top-Level:
- LSC.SmartCertify.API – the ASP.NET Core Web API project (controllers, filters, middlewares, hosting/config).
- LSC.SmartCertify.Application – application services, DTOs, validators, interfaces.
- LSC.SmartCertify.Domain – core entities and domain models.
- LSC.SmartCertify.Infrastructure – EF Core DbContext, repository implementations, background services, storage service, database scripts.
- Configuration & Scripts:
- appsettings.json (Dev & Prod)
- launchSettings.json
- SQL script for schema
- NSwag/Swagger HTTP client definitions
- Patterns:
- Controllers → inject I*Service interfaces from Application layer.
- Application Services → inject I*Repository from Infrastructure.
- Domain Entities → POCO classes.
- Dependency inversion: Application and API depend on abstractions; Infrastructure implements them.
- BackgroundService classes for scheduled notifications, onboarding.

##### Key Architecture Insights from README
- Clean Architecture principles: API layer depends on Application, which depends on Domain, with Infrastructure at the outermost layer.
- Uses EF Core (DbContext in Infrastructure) for data access.
- Swagger / NSwag for API documentation.
- Integrations: Azure AD B2C, Microsoft Graph API, Azure Blob Storage (via StorageService), Azure Functions for serverless tasks.
- Monitoring with Azure Application Insights, Logging Middleware.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    UI["Angular 19 Client"]:::external

    %% API Layer
    subgraph "API Layer"
        direction TB
        Controllers["Controllers"]:::api
        Filters["Filters & Exception Filters"]:::api
        Middlewares["Logging & Validation Middlewares"]:::api
        Config["Program & AppSettings"]:::api
        Swagger["NSwag/Swagger HTTP Definitions"]:::api
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Services["Application Services"]:::app
        DTOs["DTOs & Validators"]:::app
        Interfaces["Service & Repository Interfaces"]:::app
    end

    %% Domain Layer
    subgraph "Domain Layer"
        Entities["Domain Entities"]:::domain
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        direction TB
        DbContext["SmartCertifyContext (EF Core)"]:::infra
        Repos["Repository Implementations"]:::infra
        BgServices["Background Services"]:::infra
        StorageSvc["Azure Blob Storage Service"]:::infra
        DbScripts["Database Scripts"]:::infra
    end

    %% External Services & Database
    subgraph "External Services"
        direction TB
        ADB2C["Azure AD B2C"]:::external
        GraphAPI["Microsoft Graph API"]:::external
        BlobStore["Azure Blob Storage"]:::external
        Func["Azure Functions"]:::external
        Insights["Application Insights"]:::external
    end

    SQLDB["SQL Server / Azure SQL"]:::db

    %% Flows & Dependencies
    UI -->|"HTTP/HTTPS"| Controllers
    Controllers -->|"pipeline"| Filters
    Controllers -->|"pipeline"| Middlewares
    Controllers -->|"invokes"| Services
    Services -->|"uses interfaces"| Interfaces
    Services -->|"accesses"| Repos
    Repos -->|"EF Core via"| DbContext
    DbContext -->|"reads/writes"| SQLDB
    BgServices -->|"scheduled tasks"| DbContext
    BgServices -->|"triggers"| Func
    StorageSvc -->|"SDK calls"| BlobStore
    Services -->|"auth flows"| ADB2C
    Services -->|"user data"| GraphAPI
    Controllers -->|"telemetry"| Insights
    Middlewares -->|"logs"| Insights
    BgServices -->|"telemetry"| Insights

    %% Click Events
    click Controllers "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.API/Controllers/*.cs"
    click Filters "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.API/Filters/*.cs"
    click Middlewares "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.API/Middlewares/*.cs"
    click Config "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.API/Program.cs"
    click Config "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.API/Properties/launchSettings.json"
    click Config "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.API/appsettings.json"
    click Swagger "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.API/LSC.SmartCertify.API.http"
    click Services "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/tree/main/LSC.SmartCertify.Application/Services"
    click DTOs "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.Application/DTOs/*.cs"
    click DTOs "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.Application/DTOValidations/*.cs"
    click Interfaces "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/tree/main/LSC.SmartCertify.Application/Interfaces"
    click Entities "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.Domain/Entities/*.cs"
    click DbContext "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.Infrastructure/SmartCertifyContext.cs"
    click Repos "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.Infrastructure/ChoiceRepository.cs"
    click Repos "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.Infrastructure/CourseRepository.cs"
    click Repos "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.Infrastructure/ExamRepository.cs"
    click Repos "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.Infrastructure/QuestionRepository.cs"
    click Repos "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.Infrastructure/UserProfileRepository.cs"
    click BgServices "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.Infrastructure/BackgroundServices/*.cs"
    click StorageSvc "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.Infrastructure/Storage/StorageService.cs"
    click DbScripts "https://github.com/learnsmartcoding/smartcertify-api-clean-architecture-dotnet9/blob/main/LSC.SmartCertify.Infrastructure/Database_Scripts/SmartCertify.sql"

    %% Styles
    classDef external fill:#cccccc,stroke:#333,stroke-width:1px
    classDef api fill:#a0c4ff,stroke:#0366d6,stroke-width:1px
    classDef app fill:#caffbf,stroke:#2d6a4f,stroke-width:1px
    classDef domain fill:#fdffb6,stroke:#b59f3b,stroke-width:1px
    classDef infra fill:#ffadad,stroke:#d00000,stroke-width:1px
    classDef db fill:#ffddb3,stroke:#b35100,stroke-width:1px
```
