# markharrison/colorsapi architecture

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

- Interactive diagram: https://gitdiagram.com/markharrison/colorsapi
- Repository: https://github.com/markharrison/colorsapi

## Overview

ColorsAPI is an ASP.NET Core HTTP API for listing, looking up, creating or updating, deleting, and resetting colors. Clients enter through the hosted application and color routes; the controller validates requests and delegates color operations to a service, which maintains an in-memory collection of ColorsItem records initialized from configuration. The API also exposes random-color and name lookup routes, Swagger UI, and a configuration-information endpoint. The excerpts show controller-to-service calls and service state handling; they do not show a persistent datastore or external service integration.

Main entry points: [`Services/ColorsService.cs`](https://github.com/markharrison/colorsapi/blob/main/Services/ColorsService.cs) (Color Operations), [`Program.cs`](https://github.com/markharrison/colorsapi/blob/main/Program.cs) (Application Host), [`Controllers/ColorsController.cs`](https://github.com/markharrison/colorsapi/blob/main/Controllers/ColorsController.cs) (Color Routes), [`Models/ColorsItem.cs`](https://github.com/markharrison/colorsapi/blob/main/Models/ColorsItem.cs) (Color Record)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_hosting["HTTP Hosting"]
  node_host["Application Host<br/>[Program.cs]"]
  node_swagger["Swagger UI<br/>[Program.cs]"]
end

subgraph group_colors["Color API"]
  node_controller["Color Routes"]
  node_configinfo["Config Info<br/>[Program.cs]"]
  node_service["Color Operations<br/>[ColorsService.cs]"]
end

subgraph group_runtime["Runtime State"]
  node_model["Color Record<br/>[ColorsItem.cs]"]
  node_state[("In-memory Colors<br/>[ColorsService.cs]")]
end

node_client(("API Client"))
node_configuration["Application Config"]

node_client -->|"sends requests"| node_host
node_host -->|"maps routes"| node_controller
node_host -->|"serves UI"| node_swagger
node_client -->|"requests info"| node_configinfo
node_controller -->|"delegates operations"| node_service
node_service -->|"reads and updates"| node_state
node_service -->|"uses records"| node_model
node_host -->|"registers singleton"| node_service
node_service -->|"loads defaults"| node_configuration
node_configinfo -->|"formats diagnostics"| node_service

click node_host "https://github.com/markharrison/colorsapi/blob/main/Program.cs"
click node_swagger "https://github.com/markharrison/colorsapi/blob/main/Program.cs"
click node_controller "https://github.com/markharrison/colorsapi/blob/main/Controllers/ColorsController.cs"
click node_configinfo "https://github.com/markharrison/colorsapi/blob/main/Program.cs"
click node_service "https://github.com/markharrison/colorsapi/blob/main/Services/ColorsService.cs"
click node_model "https://github.com/markharrison/colorsapi/blob/main/Models/ColorsItem.cs"
click node_state "https://github.com/markharrison/colorsapi/blob/main/Services/ColorsService.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_host,node_swagger,node_client toneBlue
class node_controller,node_configinfo,node_service toneAmber
class node_model,node_state toneMint
class node_configuration toneIndigo
```

## Components

### HTTP Hosting

- [Application Host](https://github.com/markharrison/colorsapi/blob/main/Program.cs): `Program.cs`
- [Swagger UI](https://github.com/markharrison/colorsapi/blob/main/Program.cs): `Program.cs`

### Color API

- [Color Routes](https://github.com/markharrison/colorsapi/blob/main/Controllers/ColorsController.cs): `Controllers/ColorsController.cs`
- [Config Info](https://github.com/markharrison/colorsapi/blob/main/Program.cs): `Program.cs`
- [Color Operations](https://github.com/markharrison/colorsapi/blob/main/Services/ColorsService.cs): `Services/ColorsService.cs`

### Runtime State

- [Color Record](https://github.com/markharrison/colorsapi/blob/main/Models/ColorsItem.cs): `Models/ColorsItem.cs`
- [In-memory Colors](https://github.com/markharrison/colorsapi/blob/main/Services/ColorsService.cs): `Services/ColorsService.cs`

### Other components

- **API Client**
- **Application Config**

## Connections

- API Client → Application Host: sends requests (evidence: `Program.cs`)
- Application Host → Color Routes: maps routes (evidence: `Program.cs`)
- Application Host → Swagger UI: serves UI (evidence: `Program.cs`)
- API Client → Config Info: requests info (evidence: `Program.cs`)
- Color Routes → Color Operations: delegates operations (evidence: `Controllers/ColorsController.cs`)
- Color Operations → In-memory Colors: reads and updates (evidence: `Services/ColorsService.cs`)
- Color Operations → Color Record: uses records (evidence: `Services/ColorsService.cs`)
- Application Host → Color Operations: registers singleton (evidence: `Program.cs`)
- Color Operations → Application Config: loads defaults (evidence: `Services/ColorsService.cs`)
- Config Info → Color Operations: formats diagnostics (evidence: `Program.cs`)
