Skip to content

raminsharifiOrg/Sample.CleanArchitechture.Microservice

Repository files navigation

📦 Sample.CleanArchitecture.Microservice

A modern microservice template with Clean Architecture principles

License: MIT .NET 8.0 Project Status: Active

📚 Introduction

Sample.CleanArchitecture.Microservice is a demonstration project that implements a microservice using the principles of Clean Architecture. This project is intended as a template or starting point for building scalable, maintainable, and testable microservices.

🧩 Microservices

Microservices is an architectural style that structures an application as a collection of small, autonomous services. Each service is self-contained, independently deployable, and communicates with others via APIs or messaging systems.

🔑 Key Characteristics:

  • Independence: Services can be developed, deployed, and scaled independently.
  • Decentralization: Each service manages its own data and operates autonomously.
  • Resilience: Services are designed to handle failures gracefully.
  • Scalability: Services can be scaled independently to meet demand.

🏗️ Clean Architecture

Clean Architecture is a design philosophy that emphasizes separation of concerns, making systems easy to understand, maintain, and test. It organizes code into distinct layers, each with a specific responsibility.

📂 Layers in Clean Architecture:

  • Entities: Core business logic and rules, independent of external frameworks.
  • Use Cases (Interactors): Application-specific business rules and actions.
  • Interface Adapters: Bridges between use cases and external systems, converting data formats as needed.
  • Frameworks & Drivers: The outermost layer, containing implementation details like UI frameworks, databases, and web APIs.

🎯 Benefits:

  • Testability: Isolated components are easier to test.
  • Maintainability: Changes in one layer do not affect others.
  • Flexibility: Easier integration of new technologies or modifications.

🗂️ Project Structure


Sample.CleanArchitecture.Microservice/
│
├── src(Each Domain Source)/
│   ├── Domain/              # Business logic, entities, and use cases
│   ├── Application/         # Application services, interfaces
│   ├── Infrastructure/      # Implementations for data access, external services
│   └── Web (Gateway)/       # Entry point, controllers, HTTP handling
│
└── README.md                # Project documentation

🚀 Getting Started

📋 Prerequisites

🏃‍♂️ Running the Application

  1. Clone the Repository:

    git clone https://github.com/raminsharifiOrg/Sample.CleanArchitechture.Microservice
    cd Sample.CleanArchitecture.Microservice
  2. Build the Solution:

    dotnet build
  3. Run the Application:

    dotnet run --project src/Api
  4. Access the API:

    The API will be available at https://localhost:5001 by default.

🐳 Running with Docker

  1. Build the Docker Image:

    docker build -t sample-cleanarchitecture-microservice .
  2. Run the Docker Container:

    docker run -p 5001:80 sample-cleanarchitecture-microservice
  3. Access the API:

    The API will be available at http://localhost:5001.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

A big thank you to the contributors of the Clean Architecture and Microservices communities for their guidance and inspiration.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published