# paulossjunior/serialogexample architecture

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

- Interactive diagram: https://gitdiagram.com/paulossjunior/serialogexample
- Repository: https://github.com/paulossjunior/serialogexample

## Overview

##### Main Components

a) Application Layer Components:
- Minimal API (.NET 8)
- Configuration Management
- Service Layer
- Repository Layer
- Models
- Logging Infrastructure

b) External Components:
- Seq Server
- File System (for file-based logs)
- Console Output

**┌─ Client Layer ─────────────────────────┐**
- HTTP Clients (Browser/Curl/etc.)       │
- ┬───────────────────┘
- ↓
**┌─ API Layer ───────────────────────────┐**
- Minimal API Endpoints (.NET 8)         │
- ┬───────────────────┘
- ↓
**┌─ Service Layer ───────────────────────┐**
- UserService                           │
- ┬───────────────────┘
- ↓
**┌─ Repository Layer ────────────────────┐**
- UserRepository                        │
- ┬───────────────────┘
- ↓
**┌─ Logging Infrastructure ──────────────────────────────┐**
- ┌─────────────┐  ┌──────────┐  ┌──────────────────┐ │
- Serilog   │  │  Enrichers│  │ Log Configuration│ │
- ┬──────┘  └─────┬────┘  └────────┬─────────┘ │
- ┼──────────────┼─────────────────┼───────────┘

**┌────────▼──────┐ ┌────▼────┐    ┌──────▼─────┐**
- Seq Server   │ │ File Logs│    │  Console   │
- ┘ └─────────┘    └────────────┘

##### Important Elements to Highlight

a) Data Flow:
- HTTP requests flow from clients to API
- Log message flow through Serilog to different sinks
- Enricher injection points

b) Configuration Components:
- LoggerConfig.cs location and influence
- Environment-specific settings (Development/Production)

##### Additional Details

Specific project elements:
- Log Enrichers (Machine Name, Environment, Thread ID, Client IP)
- Multiple Sink Outputs (Console, File, Seq)
- Docker container boundaries
- API Endpoints (/users)

##### Technical Details

- .NET 8 Runtime
- Serilog Configuration
- Docker network
- File system mounts for logs
- Seq dashboard access

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        HTTP[HTTP Clients]:::client
    end

    subgraph API
        MinAPI[Minimal API]:::api
        click MinAPI "https://github.com/paulossjunior/SerialogExample/blob/main/SerialogExample/Program.cs"
        Config[Configuration Files]:::config
        click Config "https://github.com/paulossjunior/SerialogExample/blob/main/SerialogExample/appsettings.json"
        ExHandler[Exception Handler]:::error
        click ExHandler "https://github.com/paulossjunior/SerialogExample/blob/main/SerialogExample/Models/Exceptions/ValidationException.cs"
    end

    subgraph Service
        UserSvc[User Service]:::service
        click UserSvc "https://github.com/paulossjunior/SerialogExample/blob/main/SerialogExample/Services/UserService.cs"
        UserSvcInt[IUserService]:::interface
        click UserSvcInt "https://github.com/paulossjunior/SerialogExample/blob/main/SerialogExample/Services/Interfaces/IUserService.cs"
    end

    subgraph Repository
        UserRepo[User Repository]:::repo
        click UserRepo "https://github.com/paulossjunior/SerialogExample/blob/main/SerialogExample/Repositories/UserRepository.cs"
        UserRepoInt[IUserRepository]:::interface
        click UserRepoInt "https://github.com/paulossjunior/SerialogExample/blob/main/SerialogExample/Repositories/Interfaces/IUserRepository.cs"
        UserModel[User Model]:::model
        click UserModel "https://github.com/paulossjunior/SerialogExample/blob/main/SerialogExample/Models/User.cs"
    end

    subgraph LogInfra[Logging Infrastructure]
        Serilog[Serilog]:::logger
        LogConfig[Logger Configuration]:::config
        click LogConfig "https://github.com/paulossjunior/SerialogExample/blob/main/SerialogExample/Configuration/LoggerConfig.cs"
        Enrichers[Log Enrichers]:::enricher
    end

    subgraph Outputs[Log Outputs]
        SeqServer[Seq Server]:::external
        FileLogs[File Logs]:::storage
        click FileLogs "https://github.com/paulossjunior/SerialogExample/tree/main/SerialogExample/logs"
        Console[Console Output]:::output
    end

    HTTP --> MinAPI
    MinAPI --> Config
    MinAPI --> ExHandler
    MinAPI --> UserSvc
    UserSvc --> UserSvcInt
    UserSvc --> UserRepo
    UserRepo --> UserRepoInt
    UserRepo --> UserModel
    
    MinAPI --> Serilog
    Serilog --> LogConfig
    Serilog --> Enrichers
    
    Serilog --> SeqServer
    Serilog --> FileLogs
    Serilog --> Console

    classDef client fill:#gray,stroke:#333,stroke-width:2px
    classDef api fill:#3498db,stroke:#2980b9,stroke-width:2px
    classDef service fill:#2ecc71,stroke:#27ae60,stroke-width:2px
    classDef repo fill:#9b59b6,stroke:#8e44ad,stroke-width:2px
    classDef interface fill:#95a5a6,stroke:#7f8c8d,stroke-width:2px
    classDef model fill:#e74c3c,stroke:#c0392b,stroke-width:2px
    classDef logger fill:#1abc9c,stroke:#16a085,stroke-width:2px
    classDef config fill:#f1c40f,stroke:#f39c12,stroke-width:2px
    classDef enricher fill:#e67e22,stroke:#d35400,stroke-width:2px
    classDef external fill:#34495e,stroke:#2c3e50,stroke-width:2px
    classDef storage fill:#95a5a6,stroke:#7f8c8d,stroke-width:2px
    classDef output fill:#bdc3c7,stroke:#95a5a6,stroke-width:2px
    classDef error fill:#e74c3c,stroke:#c0392b,stroke-width:2px

    subgraph Legend
        Client_L[Client]:::client
        API_L[API Component]:::api
        Service_L[Service]:::service
        Repo_L[Repository]:::repo
        Interface_L[Interface]:::interface
        Model_L[Model]:::model
        Logger_L[Logger]:::logger
        Config_L[Configuration]:::config
        Enricher_L[Enricher]:::enricher
        External_L[External System]:::external
        Storage_L[Storage]:::storage
        Output_L[Output]:::output
        Error_L[Error Handler]:::error
    end
```
