{"id":26154378,"url":"https://github.com/rcdmk/testepraticoddd","last_synced_at":"2025-04-14T07:11:20.154Z","repository":{"id":34219827,"uuid":"38079761","full_name":"rcdmk/TestePraticoDDD","owner":"rcdmk","description":"Toy Project using DDD (Domain Driven Design) inspired structure","archived":false,"fork":false,"pushed_at":"2025-01-03T21:07:56.000Z","size":1700,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T20:51:15.549Z","etag":null,"topics":["asp-net","asp-net-core","asp-net-mvc","ddd-architecture","ddd-validation","entity-framework-core","grpc"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rcdmk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-25T23:27:46.000Z","updated_at":"2025-01-03T21:07:56.000Z","dependencies_parsed_at":"2025-03-11T08:30:59.310Z","dependency_job_id":"554a4afd-a125-4397-b5cc-64713904a80e","html_url":"https://github.com/rcdmk/TestePraticoDDD","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcdmk%2FTestePraticoDDD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcdmk%2FTestePraticoDDD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcdmk%2FTestePraticoDDD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcdmk%2FTestePraticoDDD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rcdmk","download_url":"https://codeload.github.com/rcdmk/TestePraticoDDD/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837287,"owners_count":21169374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net","asp-net-core","asp-net-mvc","ddd-architecture","ddd-validation","entity-framework-core","grpc"],"created_at":"2025-03-11T08:29:25.469Z","updated_at":"2025-04-14T07:11:20.130Z","avatar_url":"https://github.com/rcdmk.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DDD structure project\n\n[![Build status](https://ci.appveyor.com/api/projects/status/799cc3qwne3d6el0?svg=true)](https://ci.appveyor.com/project/rcdmk/testepraticoddd)\n\nThis project uses many development patterns as learning model:\n\n* DDD - Domain Driven Design inspired structure\n* SelfValidation - Entities have auto-validation and are responsible for their own business rules validity state.\n* Repository - The data layer communication is done through repositories\n* Application Services - Data access is done through application services that can be reused by different applications (eg. Web and gRPC Services)\n* AutoMapper - Mapping from entities to and from view models and DTOs is handled by AutoMapper\n* IoC - Dependency injection is handled by .Net Core DI framework\n* Makefile - Easier to remember commands to execute common tasks\n* ... (more to come)\n\n## History\n\nThis was originally built on .Net Framework 4.5, for Windows only, in 2015 and now ported to .Net Core 6.0 in 2022.\n\nThe major changes from the original project, appart from the obvious upgrades related to .Net Core, are:\n\n1. **Ninject was removed** in favor of the existing .Net Core DI framework, as the use case is simple enough to be handled with that\n2. **Added some tests** with xUnit to cover main domain logic\n3. **Services layer was changed to gRPC** services instead of the previous WPF services\n4. **Added Makefile** to streameline most common project tasks\n5. **Added docker-compose.yml** for running additional services, like the MySQL 8 database server\n\n## Prerequisites\n\n* [dotnet 6.0+ command-line tool](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)\n* [Doker](https://www.docker.com/)\n\n## Make a friend\n\nThe command-line tool `make` is your friend here. Make sure to explore the available targets.\n\nThe most common ones will be listed bellow.\n\n\u003e **Tip❗** All make commands need to be run from the project's root folder (where the Makefile file is located).\n\n## Installing dependencies\n\nDependencies are managed through the `dotnet` command-line tool and all of them can be installed with:\n\n```sh\nmake deps\n```\n\nThat also includes downloading MySQL 8 docker image to make sure docker is correctly setup and speedup other steps.\n\n## Preparing the database\n\nThis project uses EntityFramework code-first approach and code migrations to generate and update the database.\n\nTo run the project for the first time, it is necessary to have a MySQL server running to apply migrations before the application can be started:\n\n```sh\n# runs a MySQL 8 container in a non-interactive/non-blocking way\nmake start-database\n\n# generate database schema, tables and seed data\nmake update-database\n```\n\nThe easiest way to see the database contents via command-line is to run the `mysql` tool within the container:\n\n```sh\n$ docker-compose exec -it mysql mysql -uroot -proot\n\nmysql\u003e USE TestePraticoDB;\nmysql\u003e SHOW TABLES;\nmysql\u003e SELECT * FROM __EFMigrationsHistory;\n```\n\n\u003e **Tip❗** The database server can be accessed through the localhost port `3306`. Depending on OS version and settings, it may be required to target the localhost IP address `127.0.0.1` or the unspecified address IP address `0.0.0.0` instad of using `localhost`.\n\n## Running the code\n\nThere are two ways of running the two applications, Web and gRPC services, and both are available through Makefile targets:\n\n**Local development with hot-reload:**\n\n```sh\n# start the web application in watch mode, with hot-reload enabled\nmake watch-web\n\n# start the gRPC services application in watch mode, with hot-reload enabled\nmake watch-services\n```\n\n**Running them locally in development mode:**\n\n```sh\n# start web application in development mode\nmake start-web\n\n# start gRPC services in development mode\nmake start-services\n```\n\n\u003e **Tip❗** All previous commands are blocking, so you may want to start them in a separate terminal window.\n\n## Running tests\n\n```sh\nmake tests\n```\n\n## Application settings\n\nApplication settings are stored in `appsettings.json` files, with environment specific settings on `appsettings.${environment}.json` (eg: `appsettings.Development.json`).\n\n## Project structure\n\nThe project structure is inspired on DDD (Domain Driven Design) approach, with layered or onion architecture, having the outer-most layers depending on inner-most layers and never the other way around.\n\nThe layers, presented in order of inner-most to outer-most:\n\n### TestePratico.Domain\n\nThe most central layer, where business logic should live, is the `Domain` layer. This layer houses business entities, main data interfaces and the domain services, which are responsible for business logic.\n\nThis project should't depend on any other layer to have pure domain specific logic.\n\n### TestePratico.Data\n\nThe `Data` layer, where the storage related code lies, with the respository implementations, entity configuration and migrations for EntityFramework.\n\nThis layer depends on the `Domain` layer and possibly `Common`.\n\n### TestePratico.Application\n\nThe `Application` layer contains the common application logic in application services that consume domain services to perform its operations. This layer is meant to be reused by any application that is built on top of the inner layers, like web applications, APIs, gRPC services or command-line interfaces.\n\nThis layer depends on the `Domain` layer and possibly `Common`. Although it works with repositories, it relies on interfaces and not the implementations from the `Data` layer.\n\n### TestePratico.Services\n\nThe `Services` layer is an example of gRPC server application that makes use of the `Application` services to perform CRUD operations.\n\nIn development mode, this server offers server reflection to make it easier to test it with gRPC enalbed tools, like Postman.\n\nIt's protobuf definitions are stored in the `TestePratico.Services/Protos` folder and can be used to generate client applications for it.\n\nThis layer depends on `Domain`, `Application` and possibly `Common` layers.\n\n### TestePratico.Web\n\nThe `Web` application layer is an example of UI application that is built on top of the `Application` services layer to perform CRUD operations on entities, using an MVC project structure for proper separation of concerns and easy maintainability.\n\nThis layer depends on `Domain`, `Application` and possibly `Common` layers.\n\n### TestePratico.Common\n\nThe `Common` cross-cutting concerns layer, where all logic that is not domain-specific and can be used in multiple layers should reside. Things like custom libraries, IoC/DI mappings, loggers, wrappers for utility tools, etc., must be implemented in this project.\n\nThis layer shouldn't depend on other layers, but the `Domain` one, to avoid cyclic dependency issues.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcdmk%2Ftestepraticoddd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frcdmk%2Ftestepraticoddd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcdmk%2Ftestepraticoddd/lists"}