# alphayu/adnc architecture

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

- Interactive diagram: https://gitdiagram.com/alphayu/adnc
- Repository: https://github.com/alphayu/adnc

## Overview

ADNC is a .NET framework and reference implementation for modular business systems that can evolve into microservices. Its principal flow is an external request entering the Ocelot gateway, passing authentication and routing, and reaching a service API whose application/domain layers use shared persistence or integrations before returning a result. The graph preserves the documented infrastructure capabilities and shared service building blocks. Relationships beyond the sampled code are cited to the README; unsampled demo-service implementations are not represented as inspected components.

Main entry points: [`src/ServiceShared/Application/Services/AbstractAppService.cs`](https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/Application/Services/AbstractAppService.cs) (Business application), [`src/Infrastructures/Repository/Interface/IAdoQuerierRepository.cs`](https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Repository/Interface/IAdoQuerierRepository.cs) (Repository contracts), [`src/Gateways/Ocelot/Program.cs`](https://github.com/alphayu/adnc/blob/develop/src/Gateways/Ocelot/Program.cs) (Ocelot gateway), [`src/Gateways/Ocelot/ServiceRouter.cs`](https://github.com/alphayu/adnc/blob/develop/src/Gateways/Ocelot/ServiceRouter.cs) (Service routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["Gateway"]
  node_gateway_app["Ocelot gateway<br/>[Program.cs]"]
  node_gateway_route["Service routing<br/>[ServiceRouter.cs]"]
  node_gateway_identity["JWT validation"]
end

subgraph group_infra["Infrastructure"]
  node_consul["Discovery/configuration"]
  node_eventbus["Event bus"]
  node_redis[("Redis provider")]
  node_caching["Redis caching"]
  node_repositories[("Repository implementations<br/>[EfRepository.cs]")]
  node_dapper[("Dapper repository")]
  node_mongo[("Mongo repository")]
  node_idgen["ID generation<br/>[IdGenerater.cs]"]
  node_core["Core primitives<br/>[SystemTextJson.cs]"]
end

subgraph group_shared["Shared service layers"]
  node_api["Web API/auth"]
  node_contracts["API contracts<br/>[ProblemDetails.cs]"]
  node_application["Application services"]
  node_remote["Remote clients/tokens<br/>[TokenFactory.cs]"]
  node_domain["Domain model<br/>[AggregateRoot.cs]"]
  node_repo_contracts["Repository contracts"]
end

subgraph group_service["Service workflow"]
  node_service_api["Business service API"]
  node_service_app["Business application"]
  node_service_domain["Business domain<br/>[AggregateRoot.cs]"]
end

node_client(("API client"))

node_client -->|"sends request"| node_gateway_app
node_gateway_app -->|"validates JWT"| node_gateway_identity
node_gateway_app -->|"routes request"| node_gateway_route
node_gateway_route -->|"discovers services"| node_consul
node_gateway_route -->|"forwards request"| node_service_api
node_service_api -.->|"invokes service"| node_service_app
node_service_app -.->|"uses domain"| node_service_domain
node_service_api -->|"returns result"| node_contracts
node_service_app -->|"uses repositories"| node_repo_contracts
node_repo_contracts -->|"implemented by"| node_repositories
node_repo_contracts -->|"implemented by"| node_dapper
node_repo_contracts -->|"implemented by"| node_mongo
node_service_app -->|"publishes events"| node_eventbus
node_service_app -->|"uses caching"| node_caching
node_caching -->|"uses provider"| node_redis
node_service_app -->|"calls services"| node_remote
node_remote -->|"resolves endpoints"| node_consul
node_service_app -->|"generates identifiers"| node_idgen
node_service_app -->|"uses primitives"| node_core

click node_gateway_app "https://github.com/alphayu/adnc/blob/develop/src/Gateways/Ocelot/Program.cs"
click node_gateway_route "https://github.com/alphayu/adnc/blob/develop/src/Gateways/Ocelot/ServiceRouter.cs"
click node_gateway_identity "https://github.com/alphayu/adnc/blob/develop/src/Gateways/Ocelot/Identity/JwtSecurityTokenHandlerExtension.cs"
click node_consul "https://github.com/alphayu/adnc/tree/develop/src/Infrastructures/Consul"
click node_eventbus "https://github.com/alphayu/adnc/tree/develop/src/Infrastructures/EventBus"
click node_redis "https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Redis/Providers/StackExchange/DefaultRedisProvider.cs"
click node_caching "https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Redis.Caching/Provider/DefaultCachingProvider.cs"
click node_repositories "https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Repository.EfCore/Repositories/EfRepository.cs"
click node_dapper "https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Repository.Dapper/DapperRepository.cs"
click node_mongo "https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Repository.EfCore.MongoDB/Repositories/MongoDbRepository.cs"
click node_idgen "https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/IdGenerater/Yitter/IdGenerater.cs"
click node_core "https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Core/Json/SystemTextJson.cs"
click node_api "https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/WebApi/Authentication/Bearer/BearerAuthenticationHandler.cs"
click node_contracts "https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/Application.Contracts/ResultModels/ProblemDetails.cs"
click node_application "https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/Application/Services/AbstractAppService.cs"
click node_remote "https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/Remote/Handlers/Token/TokenFactory.cs"
click node_domain "https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/Domain/Entities/AggregateRoot.cs"
click node_repo_contracts "https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Repository/Interface/IAdoQuerierRepository.cs"
click node_service_api "https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/WebApi/Controller/AdncControllerBase.cs"
click node_service_app "https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/Application/Services/AbstractAppService.cs"
click node_service_domain "https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/Domain/Entities/AggregateRoot.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_gateway_app,node_gateway_route,node_gateway_identity,node_client toneBlue
class node_consul,node_eventbus,node_redis,node_caching,node_repositories,node_dapper,node_mongo,node_idgen,node_core toneAmber
class node_api,node_contracts,node_application,node_remote,node_domain,node_repo_contracts toneMint
class node_service_api,node_service_app,node_service_domain toneRose
```

## Components

### Gateway

- [Ocelot gateway](https://github.com/alphayu/adnc/blob/develop/src/Gateways/Ocelot/Program.cs): `src/Gateways/Ocelot/Program.cs`
- [Service routing](https://github.com/alphayu/adnc/blob/develop/src/Gateways/Ocelot/ServiceRouter.cs): `src/Gateways/Ocelot/ServiceRouter.cs`
- [JWT validation](https://github.com/alphayu/adnc/blob/develop/src/Gateways/Ocelot/Identity/JwtSecurityTokenHandlerExtension.cs): `src/Gateways/Ocelot/Identity/JwtSecurityTokenHandlerExtension.cs`

### Infrastructure

- [Discovery/configuration](https://github.com/alphayu/adnc/tree/develop/src/Infrastructures/Consul): `src/Infrastructures/Consul`
- [Event bus](https://github.com/alphayu/adnc/tree/develop/src/Infrastructures/EventBus): `src/Infrastructures/EventBus`
- [Redis provider](https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Redis/Providers/StackExchange/DefaultRedisProvider.cs): `src/Infrastructures/Redis/Providers/StackExchange/DefaultRedisProvider.cs`
- [Redis caching](https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Redis.Caching/Provider/DefaultCachingProvider.cs): `src/Infrastructures/Redis.Caching/Provider/DefaultCachingProvider.cs`
- [Repository implementations](https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Repository.EfCore/Repositories/EfRepository.cs): `src/Infrastructures/Repository.EfCore/Repositories/EfRepository.cs`
- [Dapper repository](https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Repository.Dapper/DapperRepository.cs): `src/Infrastructures/Repository.Dapper/DapperRepository.cs`
- [Mongo repository](https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Repository.EfCore.MongoDB/Repositories/MongoDbRepository.cs): `src/Infrastructures/Repository.EfCore.MongoDB/Repositories/MongoDbRepository.cs`
- [ID generation](https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/IdGenerater/Yitter/IdGenerater.cs): `src/Infrastructures/IdGenerater/Yitter/IdGenerater.cs`
- [Core primitives](https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Core/Json/SystemTextJson.cs): `src/Infrastructures/Core/Json/SystemTextJson.cs`

### Shared service layers

- [Web API/auth](https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/WebApi/Authentication/Bearer/BearerAuthenticationHandler.cs): `src/ServiceShared/WebApi/Authentication/Bearer/BearerAuthenticationHandler.cs`
- [API contracts](https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/Application.Contracts/ResultModels/ProblemDetails.cs): `src/ServiceShared/Application.Contracts/ResultModels/ProblemDetails.cs`
- [Application services](https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/Application/Services/AbstractAppService.cs): `src/ServiceShared/Application/Services/AbstractAppService.cs`
- [Remote clients/tokens](https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/Remote/Handlers/Token/TokenFactory.cs): `src/ServiceShared/Remote/Handlers/Token/TokenFactory.cs`
- [Domain model](https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/Domain/Entities/AggregateRoot.cs): `src/ServiceShared/Domain/Entities/AggregateRoot.cs`
- [Repository contracts](https://github.com/alphayu/adnc/blob/develop/src/Infrastructures/Repository/Interface/IAdoQuerierRepository.cs): `src/Infrastructures/Repository/Interface/IAdoQuerierRepository.cs`

### Service workflow

- [Business service API](https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/WebApi/Controller/AdncControllerBase.cs): `src/ServiceShared/WebApi/Controller/AdncControllerBase.cs`
- [Business application](https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/Application/Services/AbstractAppService.cs): `src/ServiceShared/Application/Services/AbstractAppService.cs`
- [Business domain](https://github.com/alphayu/adnc/blob/develop/src/ServiceShared/Domain/Entities/AggregateRoot.cs): `src/ServiceShared/Domain/Entities/AggregateRoot.cs`

### Other components

- **API client**

## Connections

- API client → Ocelot gateway: sends request (evidence: `README.md`)
- Ocelot gateway → JWT validation: validates JWT (evidence: `README.md`)
- Ocelot gateway → Service routing: routes request (evidence: `README.md`)
- Service routing → Discovery/configuration: discovers services (evidence: `README.md`)
- Service routing → Business service API: forwards request (evidence: `README.md`)
- Business service API → Business application: invokes service
- Business application → Business domain: uses domain
- Business service API → API contracts: returns result (evidence: `src/ServiceShared/WebApi/Controller/AdncControllerBase.cs`)
- Business application → Repository contracts: uses repositories (evidence: `README.md`)
- Repository contracts → Repository implementations: implemented by (evidence: `README.md`)
- Repository contracts → Dapper repository: implemented by (evidence: `README.md`)
- Repository contracts → Mongo repository: implemented by (evidence: `README.md`)
- Business application → Event bus: publishes events (evidence: `README.md`)
- Business application → Redis caching: uses caching (evidence: `README.md`)
- Redis caching → Redis provider: uses provider
- Business application → Remote clients/tokens: calls services (evidence: `README.md`)
- Remote clients/tokens → Discovery/configuration: resolves endpoints (evidence: `src/ServiceShared/Application/Registrar/AbstractApplicationDependencyRegistrar.RpcClient.cs`)
- Business application → ID generation: generates identifiers (evidence: `README.md`)
- Business application → Core primitives: uses primitives (evidence: `README.md`)
