# guifeh/discagram-api architecture

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

- Interactive diagram: https://gitdiagram.com/guifeh/discagram-api
- Repository: https://github.com/guifeh/discagram-api

## Overview

#### Purpose and Entry Point
This is a small .NET application centered on user authentication and password handling. The runtime starts in `Program.cs`, which is responsible for application bootstrapping, dependency registration, configuration loading, and HTTP pipeline setup.

#### Domain Model
The core business entity is the user model at `Domain/Entities/User.cs`. Domain-level password abstraction is separated through `Domain/Interfaces/IPasswordHash.cs`, allowing authentication code to depend on a contract rather than a concrete hashing implementation.

#### Authentication Service Boundary
`Services/Auth/AuthService.cs` contains the primary authentication use-case flow: accepting credentials or user data, coordinating password verification/hash generation, and interacting with persistence. It is the application-service boundary between HTTP-facing startup code and domain/infrastructure concerns.

#### Password Security
`Security/Criptography.cs` provides the concrete cryptographic/password-hashing implementation behind `IPasswordHash`. Authentication should consume the interface from `Domain/Interfaces/IPasswordHash.cs`; this isolates security algorithm choices from the service and domain layers.

#### Persistence
Entity Framework Core persistence is represented by `Infraestructure/Context/AppDbContext.cs`. This context maps `Domain/Entities/User.cs` to the configured database and is the principal infrastructure boundary for durable user/account state.

#### Runtime Configuration and Delivery
Application settings are supplied through `appsettings.json` and environment-specific overrides in `appsettings.Development.json`. Container-orchestrated deployment infrastructure is defined under `k8s/`, including database/cluster configuration in `k8s/cluster-cnpg.yaml`, ingress/proxy deployment in `k8s/nginx-deployment.yaml`, and environment Helm-style values in `k8s/values-dev.yaml` and `k8s/values-prd.yaml`.

#### Primary Flow
Startup in `Program.cs` composes the dependency graph: database context, authentication service, and password hashing implementation. Requests enter the application pipeline, invoke `Services/Auth/AuthService.cs`, validate or create `Domain/Entities/User.cs` state via the password abstraction, then read/write through `Infraestructure/Context/AppDbContext.cs`. Kubernetes manifests provide the operational boundary around the running service, reverse proxy, resource quotas, and CloudNativePG-oriented database setup.

Main entry points: [`Program.cs`](https://github.com/guifeh/discagram-api/blob/main/Program.cs) (Application bootstrap), [`Services/Auth/AuthService.cs`](https://github.com/guifeh/discagram-api/blob/main/Services/Auth/AuthService.cs) (Authentication service), [`Infraestructure/Context/AppDbContext.cs`](https://github.com/guifeh/discagram-api/blob/main/Infraestructure/Context/AppDbContext.cs) (Application DB context), [`k8s/nginx-deployment.yaml`](https://github.com/guifeh/discagram-api/blob/main/k8s/nginx-deployment.yaml) (Ingress proxy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_program["Application bootstrap<br/>ASP.NET startup<br/>[Program.cs]"]
  node_settings["Application settings<br/>configuration<br/>[appsettings.json]"]
  node_dev_settings["Development overrides<br/>configuration"]
end

subgraph group_domain["Domain &amp; authentication"]
  node_auth_service["Authentication service<br/>application service<br/>[AuthService.cs]"]
  node_user["User<br/>domain entity<br/>[User.cs]"]
  node_password_contract{{"Password hash contract<br/>domain interface<br/>[IPasswordHash.cs]"}}
end

subgraph group_infrastructure["Infrastructure"]
  node_password_crypto["Password cryptography<br/>hashing implementation<br/>[Criptography.cs]"]
  node_db_context[("Application DB context<br/>EF Core context<br/>[AppDbContext.cs]")]
end

subgraph group_delivery["Kubernetes delivery"]
  node_cluster_db[("CloudNativePG database<br/>Kubernetes database<br/>[cluster-cnpg.yaml]")]
  node_nginx["Ingress proxy<br/>Kubernetes deployment"]
  node_dev_values["Development values<br/>deployment values<br/>[values-dev.yaml]"]
  node_prod_values["Production values<br/>deployment values<br/>[values-prd.yaml]"]
end

node_settings -->|"loads"| node_program
node_dev_settings -.->|"overrides"| node_program
node_program -->|"registers and invokes"| node_auth_service
node_program -->|"registers"| node_db_context
node_program -->|"registers"| node_password_crypto
node_auth_service -->|"validates or creates"| node_user
node_auth_service -->|"hashes and verifies through"| node_password_contract
node_password_crypto -->|"implements"| node_password_contract
node_auth_service -->|"reads and writes"| node_db_context
node_db_context -->|"maps"| node_user
node_nginx -->|"routes requests to"| node_program
node_db_context -->|"connects to"| node_cluster_db
node_dev_values -.->|"configures development"| node_nginx
node_prod_values -.->|"configures production"| node_nginx
node_dev_values -.->|"configures development"| node_cluster_db
node_prod_values -.->|"configures production"| node_cluster_db

click node_program "https://github.com/guifeh/discagram-api/blob/main/Program.cs"
click node_settings "https://github.com/guifeh/discagram-api/blob/main/appsettings.json"
click node_dev_settings "https://github.com/guifeh/discagram-api/blob/main/appsettings.Development.json"
click node_auth_service "https://github.com/guifeh/discagram-api/blob/main/Services/Auth/AuthService.cs"
click node_user "https://github.com/guifeh/discagram-api/blob/main/Domain/Entities/User.cs"
click node_password_contract "https://github.com/guifeh/discagram-api/blob/main/Domain/Interfaces/IPasswordHash.cs"
click node_password_crypto "https://github.com/guifeh/discagram-api/blob/main/Security/Criptography.cs"
click node_db_context "https://github.com/guifeh/discagram-api/blob/main/Infraestructure/Context/AppDbContext.cs"
click node_cluster_db "https://github.com/guifeh/discagram-api/blob/main/k8s/cluster-cnpg.yaml"
click node_nginx "https://github.com/guifeh/discagram-api/blob/main/k8s/nginx-deployment.yaml"
click node_dev_values "https://github.com/guifeh/discagram-api/blob/main/k8s/values-dev.yaml"
click node_prod_values "https://github.com/guifeh/discagram-api/blob/main/k8s/values-prd.yaml"

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_program,node_settings,node_dev_settings toneBlue
class node_auth_service,node_user,node_password_contract toneAmber
class node_password_crypto,node_db_context toneMint
class node_cluster_db,node_nginx,node_dev_values,node_prod_values toneRose
```

## Components

### Application runtime

- [Application bootstrap](https://github.com/guifeh/discagram-api/blob/main/Program.cs): ASP.NET startup · Composes services, configuration, and HTTP pipeline. · `Program.cs`
- [Application settings](https://github.com/guifeh/discagram-api/blob/main/appsettings.json): configuration · `appsettings.json`
- [Development overrides](https://github.com/guifeh/discagram-api/blob/main/appsettings.Development.json): configuration · `appsettings.Development.json`

### Domain & authentication

- [Authentication service](https://github.com/guifeh/discagram-api/blob/main/Services/Auth/AuthService.cs): application service · Coordinates credential handling and user persistence. · `Services/Auth/AuthService.cs`
- [User](https://github.com/guifeh/discagram-api/blob/main/Domain/Entities/User.cs): domain entity · `Domain/Entities/User.cs`
- [Password hash contract](https://github.com/guifeh/discagram-api/blob/main/Domain/Interfaces/IPasswordHash.cs): domain interface · `Domain/Interfaces/IPasswordHash.cs`

### Infrastructure

- [Password cryptography](https://github.com/guifeh/discagram-api/blob/main/Security/Criptography.cs): hashing implementation · `Security/Criptography.cs`
- [Application DB context](https://github.com/guifeh/discagram-api/blob/main/Infraestructure/Context/AppDbContext.cs): EF Core context · Maps users to durable account state. · `Infraestructure/Context/AppDbContext.cs`

### Kubernetes delivery

- [CloudNativePG database](https://github.com/guifeh/discagram-api/blob/main/k8s/cluster-cnpg.yaml): Kubernetes database · `k8s/cluster-cnpg.yaml`
- [Ingress proxy](https://github.com/guifeh/discagram-api/blob/main/k8s/nginx-deployment.yaml): Kubernetes deployment · `k8s/nginx-deployment.yaml`
- [Development values](https://github.com/guifeh/discagram-api/blob/main/k8s/values-dev.yaml): deployment values · `k8s/values-dev.yaml`
- [Production values](https://github.com/guifeh/discagram-api/blob/main/k8s/values-prd.yaml): deployment values · `k8s/values-prd.yaml`

## Connections

- Application settings → Application bootstrap: loads
- Development overrides → Application bootstrap: overrides
- Application bootstrap → Authentication service: registers and invokes
- Application bootstrap → Application DB context: registers
- Application bootstrap → Password cryptography: registers
- Authentication service → User: validates or creates
- Authentication service → Password hash contract: hashes and verifies through
- Password cryptography → Password hash contract: implements
- Authentication service → Application DB context: reads and writes
- Application DB context → User: maps
- Ingress proxy → Application bootstrap: routes requests to
- Application DB context → CloudNativePG database: connects to
- Development values → Ingress proxy: configures development
- Production values → Ingress proxy: configures production
- Development values → CloudNativePG database: configures development
- Production values → CloudNativePG database: configures production
