Skip to content

AlphaYu/adnc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,870 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ADNC A pragmatic .NET 8 reference architecture for modular monoliths, distributed applications, and microservice systems.

GitHub license GitHub stars GitHub forks Visitors

A pragmatic .NET 8 reference architecture for modular monoliths, distributed applications, and microservice systems.

Why ADNC · Design Principles · Architecture · Getting Started · Documentation

简体中文 · English

What Is ADNC?

ADNC is an open-source distributed application framework built on .NET 8. It brings together the infrastructure, conventions, and sample services that teams typically need when building production-grade business systems: gateway routing, service discovery, centralized configuration, authentication, inter-service communication, event-driven integration, persistence, caching, observability, resilience, and deployment support.

The repository is both a framework and a working reference implementation. It includes reusable Adnc.Infra.* packages, shared service-layer packages, an Ocelot gateway, a multi-service demo domain, database scripts, Docker Compose infrastructure assets, and English/Chinese documentation.

ADNC is intentionally not a one-size-fits-all template. It demonstrates how different service shapes can coexist in the same system: classic layered services, compact single-project services, and DDD-style services with explicit domain layers.

Why ADNC

Distributed systems fail most often at the boundaries: service ownership, data consistency, configuration drift, operational visibility, authentication, and integration contracts. ADNC focuses on those boundaries instead of only scaffolding controllers and repositories.

Use ADNC when you want:

  • A practical .NET 8 architecture baseline for business applications.
  • A reference implementation for moving from modular monoliths toward microservices.
  • Consistent infrastructure abstractions across services without forcing identical project layouts.
  • Examples of HTTP, gRPC, and event-driven service integration in one repository.
  • A realistic demo that includes gateway, identity, persistence, cache, messaging, tracing, logs, and deployment assets.
  • Source code and documentation that can be studied, customized, or selectively adopted.

ADNC is not positioned as:

  • A black-box platform that hides .NET application architecture.
  • Generated code with no architectural intent.
  • A microservice-only template that requires every bounded context to be deployed independently from day one.
  • A benchmark report. Performance notes are scenario references, not guarantees.

Design Principles

Modular first, distributed when necessary

Service boundaries should be explicit before deployment boundaries become expensive. ADNC supports modular service design and lets teams adopt distributed deployment where the operational cost is justified.

Different domains deserve different shapes

Small CRUD-oriented services do not need the same structure as domain-heavy services. The demo intentionally includes multiple project styles so teams can make informed trade-offs.

Infrastructure is shared; business behavior is owned by services

Cross-cutting concerns such as authentication, caching, repository patterns, remote calls, events, logging, and health checks are centralized in reusable packages. Business logic remains in service-specific application and domain layers.

Operational concerns are part of the architecture

Configuration, discovery, tracing, logging, gateway routing, health checks, and deployment assets are treated as first-class concerns, not afterthoughts.

Prefer replaceable integrations

The project uses established .NET ecosystem components such as Ocelot, Consul, Refit, gRPC, EF Core, Dapper, CAP, RabbitMQ, Redis, Polly, NLog, SkyAPM, and HealthChecks. ADNC organizes these tools behind consistent conventions rather than reinventing them.

Architecture at a Glance

adnc-framework

At a high level, ADNC is organized into four parts:

Layer Responsibility
Gateway Ocelot-based API gateway, routing, authentication integration, Consul provider, resilience policies
Infrastructure Reusable packages for Consul, Redis, repositories, event bus, ID generation, helpers, and core primitives
Shared Service Layer Common application, domain, repository, remote-call, and web API building blocks
Demo Services Business services that show layered, compact, and DDD-oriented service structures

Infrastructure Packages

The src/Infrastructures directory contains reusable packages under the Adnc.Infra.* namespace.

Area Projects
Core primitives Adnc.Infra.Core, Adnc.Infra.Helper
Service discovery and configuration Adnc.Infra.Consul
Event bus Adnc.Infra.EventBus
ID generation Adnc.Infra.IdGenerater
Redis Adnc.Infra.Redis, Adnc.Infra.Redis.Caching
Repository abstraction Adnc.Infra.Repository
Repository implementations Adnc.Infra.Repository.Dapper, Adnc.Infra.Repository.EfCore, Adnc.Infra.Repository.EfCore.MySql, Adnc.Infra.Repository.EfCore.SqlServer, Adnc.Infra.Repository.EfCore.MongoDB

ADNC infrastructure packages

Shared Service Packages

The src/ServiceShared directory contains reusable service-level building blocks under the Adnc.Shared.* namespace.

Area Projects
Shared constants and context Adnc.Shared
Application layer Adnc.Shared.Application, Adnc.Shared.Application.Contracts
Domain layer Adnc.Shared.Domain
Repository layer Adnc.Shared.Repository
Remote calls Adnc.Shared.Remote
Web API infrastructure Adnc.Shared.WebApi

ADNC shared service packages

Core Capabilities

Capability ADNC Direction
API gateway Ocelot gateway with routing, Consul integration, authentication, and Polly support
Service discovery Consul-based registration and discovery
Configuration Local environment settings plus Consul-backed configuration center
Service communication Refit-based HTTP clients and gRPC clients via Grpc.Net.ClientFactory
Event integration CAP, RabbitMQ, integration event contracts, and event tracking support
Persistence EF Core, Dapper, MySQL, SQL Server, and MongoDB-oriented infrastructure
Transactions Unit of Work support and eventual consistency through CAP
Caching Redis provider, distributed cache abstraction, distributed locks, and Bloom filter support
Security JWT authentication, authorization helpers, shared web API infrastructure
Observability NLog, Loki target, SkyAPM/SkyWalking, HealthChecks, Prometheus-related packages
Resilience Polly-based transient fault handling at gateway and service-call boundaries
Engineering baseline Central Package Management, shared build props, editor configuration, solution slicing

Technology Stack

Category Technologies
Runtime .NET 8
Gateway Ocelot
Registry and configuration Consul
Remote calls Refit, gRPC
Persistence EF Core, Dapper, MySQL, SQL Server, MongoDB
Messaging and consistency CAP, RabbitMQ
Cache Redis
Resilience Polly
Logging and tracing NLog, Loki, SkyAPM, SkyWalking
Metrics and health Prometheus packages, AspNetCore HealthChecks
API and validation Swashbuckle, FluentValidation
Mapping AutoMapper

Repository Structure

adnc
├── .github/                   GitHub Actions workflows
├── database/                  Database initialization script
├── deploy/                    Docker Compose assets for staging-like infrastructure
├── docs/
│   ├── architecture/          Architecture decision records
│   └── wiki/                  English and Chinese documentation source
├── src/
│   ├── Infrastructures/       ADNC infrastructure packages
│   ├── ServiceShared/         Shared service-layer building blocks
│   ├── Gateways/              Ocelot gateway
│   └── Demo/                  Demo microservices
├── test/                      Test-related projects
├── README.md
├── README_ZH.md
└── LICENSE

Important Solutions

Path Purpose
src/Adnc.sln Main solution containing the ADNC framework projects
src/Infrastructures/Adnc.Infra.sln Infrastructure-only solution
src/ServiceShared/Adnc.Shared.sln Shared service-layer solution
src/Demo/Adnc.Demo.sln Demo service solution
src/Gateways/Ocelot/Adnc.Ocelot.sln Ocelot gateway solution

Build configuration is centralized through:

  • src/Directory.Build.props: shared build settings, including net8.0, nullable reference types, implicit usings, package metadata, and documentation generation.
  • src/Directory.Packages.props: Central Package Management for NuGet versions.
  • src/.editorconfig: cross-editor code style configuration.

Getting Started

The fastest way to get started is to follow the quick start guide. The demo requires infrastructure such as Consul, Redis, RabbitMQ, MySQL, logging components, and service configuration, so the startup sequence matters.

  1. Install the .NET 8 SDK.
  2. Read the ADNC Quick Start Guide.
  3. Open src/Adnc.sln for framework packages or src/Demo/Adnc.Demo.sln for demo services.
  4. Prepare infrastructure from the quick start guide or the Docker Compose assets in docs/devops-staging.
  5. Initialize demo data from database/mysql/adnc.sql.
  6. Start the gateway and demo services in the documented order.

For Docker-oriented setup, use the Quick Docker Deployment Guide.

Demo Domain

The demo contains five business services and shared cross-service contracts. Each service uses a different structure to make the architectural trade-offs visible.

Service Business Scope Architecture Style
Admin Organization, users, roles, permissions, dictionaries, and configuration Classic layered architecture with separated application contracts
Maint Logs, audits, and operations management Classic layered architecture with contracts merged into the application layer
Cust Customer management Minimal single-project service
Ord Order management DDD-style service with a domain layer
Whse Warehouse management DDD-style service with a domain layer

Shared Contracts

src/Demo/Shared
├── Remote.Event/      Integration event contracts
├── Remote.Grpc/       gRPC client definitions
├── Remote.Http/       HTTP client definitions
├── protos/            gRPC protocol definitions
└── resources/         Shared configuration and resources

Service Layouts

Admin/
├── Api/
├── Application/
├── Application.Contracts/
└── Repository/

Maint/
├── Api/
├── Application/
└── Repository/

Cust/
└── Api/

Ord/
├── Api/
├── Application/
├── Domain/
└── Migrations/

Whse/
├── Api/
├── Application/
├── Domain/
└── Migrations/

Documentation

Index Topic
01 ADNC Project Tour: A Practical .NET 8 Implementation
02 ADNC Quick Start Guide
03 ADNC Quick Docker Deployment Guide
04 ADNC Configuration Nodes Detailed Explanation
05 ADNC Development Workflow
06 ADNC Repository Layer Development Guide
07 ADNC Service Layer Development Guide
08 ADNC API Layer Development Guide
09 ADNC Authentication and Authorization
10 ADNC Repository Usage: Basic Functionality
11 ADNC Repository Usage: Code First
12 ADNC Repository Usage: Switching Database Types
13 ADNC Repository Usage: Transactions and Unit of Work
14 ADNC Repository Usage: Executing Raw SQL
15 ADNC Repository Usage: Read/Write Splitting
16 ADNC ID Generator: Snowflake Algorithm
17 ADNC Cache: Redis, Distributed Locks, and Bloom Filters
18 ADNC Inter-service Communication: HTTP with Refit
19 ADNC Inter-service Communication: gRPC
20 ADNC Inter-service Communication: Events with CAP
21 ADNC Observability: Enabling SkyAPM and SkyWalking
22 ADNC Configuration Center: Consul
23 ADNC Service Registry: Consul

Ecosystem

Front-end

ADNC has a companion admin front-end built with Vue 3, Vite, TypeScript, and Element Plus.

ADNC exception log page

ADNC role management page

Links

Performance Notes

The project includes JMeter-oriented notes from a demo environment covering gateway routing, service discovery, configuration center access, synchronous service calls, CRUD operations, local transactions, distributed transactions, caching, Bloom filters, tracing, logging, and operation logs.

Reference environment:

  • ECS server: 4 vCPU, 8 GB RAM, 8 Mbps bandwidth.
  • Approximate remaining capacity during testing: 50 percent CPU and 50 percent memory.
  • Observed throughput around 1000 requests per second, constrained by bandwidth.
  • Simulated concurrency: 1200 concurrent threads.
  • Read/write ratio: 7:3.

These numbers are environment-specific and should be treated as scenario notes, not benchmark guarantees.

Contributing

Issues, discussions, and pull requests are welcome. For larger changes, start by opening an issue that explains the problem, proposed direction, and expected impact on existing packages, demo services, or documentation.

When contributing code, try to preserve the project intent:

  • Keep infrastructure concerns reusable and service-agnostic.
  • Keep business behavior inside the relevant demo service.
  • Prefer established .NET ecosystem components over custom infrastructure unless there is a clear reason.
  • Update documentation when behavior, configuration, or startup flow changes.

Community

If ADNC helps you evaluate, teach, or build .NET distributed systems, consider giving the repository a star.

License

ADNC is released under the MIT License.

About

A pragmatic .NET 8 reference architecture for modular monoliths, distributed applications, and microservice systems.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages