DEV Community

Spyros Ponaris
Spyros Ponaris

Posted on

# Exploring a Practical Billing API Built with Modern .NET Patterns

The Billing repository (https://github.com/stevsharp/Billing) is a practical example of how several common .NET architectural patterns can be combined within a billing-focused application.

Built with ASP.NET Core (https://learn.microsoft.com/aspnet/core/) and Entity Framework Core (https://learn.microsoft.com/ef/core/), the project demonstrates approaches that many teams use when building modern backend services.

A Clear Project Structure

The repository follows the principles of Clean Architecture, an approach that encourages clear separation between business logic, infrastructure, and application concerns.

Learn more about Clean Architecture:
https://github.com/jasontaylordev/CleanArchitecture

This separation helps keep responsibilities organized and makes it easier to understand where different pieces of functionality belong.

Focus on Business Rules

The project incorporates concepts from Domain-Driven Design (DDD), placing important business rules within the domain layer rather than spreading them across controllers and infrastructure code.

Learn more about Domain-Driven Design:
https://martinfowler.com/bliki/DomainDrivenDesign.html

This approach helps make business behavior more explicit and encourages a design where domain concepts remain central to the application.

Using CQRS in a Simple Way

The repository demonstrates Command Query Responsibility Segregation (CQRS), separating commands (operations that modify data) from queries (operations that retrieve data).

Learn more about CQRS:
https://martinfowler.com/bliki/CQRS.html

For developers interested in learning CQRS, the project provides a straightforward implementation that is relatively easy to follow.

Reliable Event Handling

The implementation includes the Outbox Pattern, a common technique used to improve reliability when publishing events from business operations.

Learn more about the Transactional Outbox Pattern:
https://microservices.io/patterns/data/transactional-outbox.html

This pattern helps address scenarios where database changes and event publication need to remain consistent.

Multi-Tenant Considerations

Many SaaS applications need to support multiple customers while keeping their data isolated. The project includes tenant-aware functionality using authentication claims and data filtering, providing a useful reference for developers exploring multi-tenant architectures.

Learn more about multitenancy:
https://learn.microsoft.com/azure/architecture/guide/multitenant/overview

Working with Entity Framework Core

The application uses Entity Framework Core for data access and persistence. Developers looking for practical examples of EF Core usage alongside architectural patterns may find the implementation useful to study.

Learn more about EF Core:
https://learn.microsoft.com/ef/core/

Building on ASP.NET Core

The API layer is built with ASP.NET Core, Microsoft's framework for building web APIs and cloud-native applications.

Learn more about ASP.NET Core:
https://learn.microsoft.com/aspnet/core/

Good Learning Resource

One of the strengths of the repository is that it brings together several widely used concepts and patterns:

  • Clean Architecture
  • Domain-Driven Design (DDD)
  • CQRS
  • Transactional Outbox Pattern
  • Multi-Tenant Design
  • JWT Authentication
  • Automated Testing

Rather than presenting these ideas in isolation, the project shows how they can work together in a cohesive application.

Conclusion

The Billing repository is a helpful reference for developers who want to explore modern .NET application design. It demonstrates several architectural patterns in a practical context while remaining approachable enough to study and adapt for other projects.

Repository:
https://github.com/stevsharp/Billing

Whether you're learning these concepts for the first time or looking for implementation examples, the project offers a useful starting point for further exploration.

Top comments (2)

Collapse
 
__b63657 profile image
nikosst

Clear and useful article for anyone how need to remember these. Thank you Spyros.

Collapse
 
stevsharp profile image
Spyros Ponaris

Great Thanks Niko.