After reading the great books from Robert C. Martin and watching his talks on youtube I was challenged to implement a Clean Architecture sample. To acomplish this goal, I selected the simple domain of a Todo List app then I started to design the solution following the principles found in the the book. If you share the same interest you are on the right place.
The application is designed around the uses cases of a Todo List app. The user can do the following:
- Add a todo item.
- List the todo items.
- Update the todo item titles.
- Complete a todo item.
The solution is divided between Production Code
and Unit Tests
. For the Production Code
I created the following four layers:
- The Core project with Use Cases, Entities and Boundary Objects.
- The Infrastructure with the Data Access implementation.
- The Console App as the initial delivery mechanism.
- The Web API as the second delivery mechanism I implemented.
On the Unit Tests
you will code to ensure the use cases business.
Soon.
Soon.
Soon.
Soon.
Soon.
Soon.
Soon.
Soon.
Soon.
You can run the application uses cases from the Tests
, Console
or from the Web API
. We are continuously delivering the Todo List Swagger Demo on Google Cloud.
dotnet test tests/TodoList.UnitTests/TodoList.UnitTests.csproj
dotnet run --project "source/TodoList.ConsoleApp/TodoList.ConsoleApp.csproj"
Usage:
add [title]
finish [id]
list
update [id] [title]
exit
dotnet run --project "source/TodoList.WebApi/TodoList.WebApi.csproj"
When you change the environment to Production
then the StartupProduction
class will be instantiated which uses the SQL Server persistence.
dotnet run --project --environment="production" "source/TodoList.WebApi/TodoList.WebApi.csproj"
Then navigate to https://localhost:5001/
.
Run scripts/sql-docker-up.sh
to setup a SQL Server in a Docker container with the following Connection String:
Server=localhost;User Id=sa;Password=<YourNewStrong!Passw0rd>;
Run the EF Tool to add a migration to the TodoList.Infrastructure
project.
dotnet ef migrations add "InitialCreate" -o "EntityFrameworkDataAccess/Migrations" --project source/TodoList.Infrastructure --startup-project source/TodoList.WebApi
Generate tables and seed the database via Entity Framework Tool:
dotnet ef database update --project source/TodoList.Infrastructure --startup-project source/TodoList.WebApi
- MacOS Sierra
- VSCode ❤️
- .NET Core SDK 2.2.
- Docker 🐳
- SQL Server.
I am happy to answer issues. Give a ⭐ if you like the project.