This repository demonstrates the implementation of the REPR (Request-Endpoint-Response) pattern as an alternative to Minimal APIs and MVC, utilizing FastEndpoints in .NET 8. For More, please visit my Medium blog post: Elevate Your .NET APIs with the REPR Pattern and FastEndpoints.
- Overview
- Features
- Prerequisites
- Installation
- Usage
- Architecture
- Contributing
- License
- Acknowledgements
The REPR (Request-Endpoint-Response) pattern is a design approach that structures web API endpoints into three core components:
- Request: Defines the structure of the incoming request.
- Endpoint: Handles the request, processes the necessary logic, and interacts with services or databases.
- Response: Defines the structure of the outgoing response.
This pattern streamlines development, improves code maintainability, and simplifies testing by structuring code around core API operations. For a detailed explanation, refer to the blog post: Elevate Your .NET APIs with the REPR Pattern and FastEndpoints.
- Implementation of the REPR pattern.
- Utilization of FastEndpoints for streamlined endpoint creation.
- Swagger documentation for easy API exploration.
- Example CRUD operations.
- .NET SDK 8.0 or later.
- An IDE such as Visual Studio 2022 or Visual Studio Code.
-
Clone the Repository:
git clone https://github.com/biswajitpanday/REPR-Pattern.git cd '.\REPR Pattern\REPR Pattern\'
-
Restore the dependencies:
dotnet restore
-
Build the project:
dotnet build
-
Run the Application:
dotnet run
-
Access the Application: Open your browser and navigate to
http://localhost:<port>
- Open your browser and navigate to http://localhost:{port}/swagger to explore the API using Swagger UI.
- Test the API endpoints as described in the blog post.
The project follows the REPR pattern, structuring each endpoint into three components:
- Request: Defines the data contract for the incoming request.
- Endpoint: Contains the logic to process the request and interact with the necessary services or repositories.
- Response: Defines the data contract for the outgoing response.
This approach promotes a clear separation of concerns, making the codebase more maintainable and testable.
Contributions are welcome! If you have suggestions for improvements or new features, please open an issue or submit a pull request. Ensure that your contributions align with the project's coding standards and include appropriate tests.
This project is licensed under the MIT License. See the LICENSE file for details.
Special thanks to Anderson Hansen for developing the project. Additionally, gratitude to the contributors of the FastEndpoints library and the authors of various articles on the REPR pattern for their valuable insights.