# kubra-kzlk/web-service-applicatie-lampen architecture

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

- Interactive diagram: https://gitdiagram.com/kubra-kzlk/web-service-applicatie-lampen
- Repository: https://github.com/kubra-kzlk/web-service-applicatie-lampen

## Overview

##### Main Components

a. Client Layer:
- External clients/systems that consume the API
- Swagger UI as the API documentation/testing interface

b. API Layer:
- Controllers (LampsController, ManufacturersController, StylesController)
- 15 API endpoints grouped by HTTP methods (GET, POST, PUT, DELETE)

c. Service Layer:
- Both implementations:
- In-Memory Services (InMemoryLampData)
- Database Services (LampServiceDB, ManufacturerServiceDB, StyleServiceDB)
- Interface abstractions (ILampData, IManufacturerData, IStyleData)

d. Data Layer:
- DatabaseContext
- Entity Configurations (LampConfiguration, ManufacturerConfiguration, StyleConfiguration)
- Both storage options:
- In-Memory Database
- SQL Server Database

##### Relationships to Highlight

**[External Clients] ←→ [Swagger UI]**
- ↓
**[API Layer (Controllers)]**
- ↓
**[Service Layer]**
- ↙         ↘
**[In-Memory]  [Database Services]**
- ↓
**[Data Layer (Entity Framework)]**
- ↙         ↘
**[In-Memory DB] [SQL Server]**

##### Important Details

a. Entity Relationships:
- How Lamp entities reference Manufacturer (1:N)
- How Lamp entities relate to Styles (M:N)

b. Cross-Cutting Concerns:
- Automapper for DTO transformations
- Serilog integration for logging
- Data Annotations for validation

##### Component Details

For each major component, include:
- Component name
- Key responsibilities
- Technologies used
- Dependencies

##### Architectural Patterns to Highlight

- Repository Pattern (Service layer)
- Dependency Injection
- Interface-based design
- Configuration-based database switching

##### Notes

Notes to explain:
- How to switch between database implementations
- API endpoint groupings
- Validation flow
- Error handling

Remember to emphasize the RESTful nature of the API and how it handles the three main entities (Lamps, Manufacturers, and Styles) through its various endpoints.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Clients
        EC[External Clients]:::client
        SW[Swagger UI]:::client
    end

    subgraph API_Layer
        LC["LampsController"]:::api
        MC["ManufacturersController"]:::api
        SC["StylesController"]:::api
    end

    subgraph Service_Layer
        subgraph Interfaces
            ILD["ILampData"]:::interface
            IMD["IManufacturerData"]:::interface
            ISD["IStyleData"]:::interface
        end

        subgraph Implementations
            IMLD["InMemoryLampData"]:::service
            LSD["LampServiceDB"]:::service
            MSD["ManufacturerServiceDB"]:::service
            SSD["StyleServiceDB"]:::service
        end
    end

    subgraph Data_Layer
        DC["DatabaseContext"]:::data
        subgraph Configurations
            LC_["LampConfiguration"]:::data
            MC_["ManufacturerConfiguration"]:::data
            SC_["StyleConfiguration"]:::data
            SD["SeedData"]:::data
        end
    end

    subgraph Storage
        IMDB[(In-Memory DB)]:::storage
        SQLDB[(SQL Server)]:::storage
    end

    subgraph Models
        L["Lamp"]:::model
        M["Manufacturer"]:::model
        S["Style"]:::model
    end

    %% Relationships
    EC --> SW
    SW --> LC & MC & SC
    
    LC --> ILD
    MC --> IMD
    SC --> ISD
    
    ILD --> IMLD & LSD
    IMD --> MSD
    ISD --> SSD
    
    IMLD --> IMDB
    LSD & MSD & SSD --> DC
    
    DC --> LC_ & MC_ & SC_ & SD
    DC --> SQLDB
    
    L --> M
    L --> S

    %% Click Events
    click LC "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Controllers/LampsController.cs"
    click MC "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Controllers/ManufacturersController.cs"
    click SC "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Controllers/StylesController.cs"
    click ILD "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Services/ILampData.cs"
    click IMD "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Services/IManufacturerData.cs"
    click ISD "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Services/IStyleData.cs"
    click IMLD "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Services/InMemoryLampData.cs"
    click LSD "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Services/LampServiceDB.cs"
    click MSD "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Services/ManufacturerServiceDB.cs"
    click SSD "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Services/StyleServiceDB.cs"
    click DC "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Data/DatabaseContext.cs"
    click LC_ "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Data/LampConfiguration.cs"
    click MC_ "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Data/ManufacturerConfiguration.cs"
    click SC_ "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Data/StyleConfiguration.cs"
    click SD "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Data/SeedData.cs"
    click L "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Models/Lamp.cs"
    click M "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Models/Manufacturer.cs"
    click S "https://github.com/kubra-kzlk/Web-service-applicatie-Lampen/blob/main/lampen/Models/Style.cs"

    %% Styles
    classDef client fill:#gray
    classDef api fill:#blue
    classDef interface fill:#lightgreen
    classDef service fill:#green
    classDef data fill:#orange
    classDef storage fill:#purple
    classDef model fill:#yellow

    %% Legend
    subgraph Legend
        CL[Client]:::client
        AP[API]:::api
        IN[Interface]:::interface
        SV[Service]:::service
        DT[Data]:::data
        ST[(Storage)]:::storage
        MD[Model]:::model
    end
```
