{"id":23235708,"url":"https://github.com/madslundt/dotnetbasesample","last_synced_at":"2025-08-19T21:32:41.219Z","repository":{"id":52439172,"uuid":"358031472","full_name":"madslundt/DotNetBaseSample","owner":"madslundt","description":"Template to get started with a simple .NET 5 API including CQRS including event based models as well","archived":false,"fork":false,"pushed_at":"2021-04-30T20:20:15.000Z","size":54,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-24T07:04:07.717Z","etag":null,"topics":["command-handlers","cqrs","dotnet5","event-handlers"],"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/madslundt.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}},"created_at":"2021-04-14T20:16:53.000Z","updated_at":"2022-09-26T19:17:59.000Z","dependencies_parsed_at":"2022-09-07T22:00:39.589Z","dependency_job_id":null,"html_url":"https://github.com/madslundt/DotNetBaseSample","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madslundt%2FDotNetBaseSample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madslundt%2FDotNetBaseSample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madslundt%2FDotNetBaseSample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madslundt%2FDotNetBaseSample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/madslundt","download_url":"https://codeload.github.com/madslundt/DotNetBaseSample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230371886,"owners_count":18215806,"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":["command-handlers","cqrs","dotnet5","event-handlers"],"created_at":"2024-12-19T03:29:18.445Z","updated_at":"2024-12-19T03:29:19.051Z","avatar_url":"https://github.com/madslundt.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DotNetBaseSample\nTemplate to get started with a simple .NET 5 API including CQRS and event-based models.\n\nSrc has been split into several projects:\n - **Api**: Api entry point containing controllers and configurations.\n - **Components**: Business logic implementations.\n - **Events**: Event models.\n - **DataModel**: Database context containing all data models.\n - **Infrastructure**: Infrastructure to be used in the application.\n\n## Api\nApi is the entry point of the application.\nAll endpoints for the API can be found here as well as the configurations of the application.\n\nAPI uses mediator to send commands and queries to their handlers.\n\nIt might also publish events to one or more handlers.\n\n## Components\nComponents contain the business logic. These have been split into handlers like query handlers (for getting data), command handlers (for changing data), and event handlers (for handling events).\n\nHandlers expect a request and return a result. Where requests are verified via a validator.\n\nQuery- and command handlers are async and return a result. A query and command can only be handled by one handler.\n\nEvent handlers are async as well but don't return a result. The reason for the no result is that an event can be handled in multiple places (without knowing the order).\n\n## Events\nAll event models to be used in event handlers. All events are immutable and often only the reference is used in the model.\nThe naming of the models is in past tense because an event usually defines something that has happened or has been triggered.\n\nThe reason this is abstracted into its project is that it might be needed for other projects that don't need to know about the business logic or anything else (e.g. notification service, logging service, etc.).\n\n## DataModel\nDataModel contains all the database models with data migrations. In case a model changes or a new model is introduced a new migration must be generated and later applied to a database.\n\nSome helper functions as `BaseModel.cs` and `BaseModelContextExtensions.cs` have been added to generalize tables with UUID id as primary key and Datetime created date in UTC.\n\nOther helper functions as `BaseModelEnum.cs` and `BaseModelEnumContextExtensions.cs` have been added to generalize reference tables containing only int id and string name. Where id is the enum value and name is the string representation of the enum.\nAlso, it makes sure to populate the enum values into the table once created.\n\n`DatabaseContext.cs` contain all the models and makes sure that an event is published once executing `SaveChangesAsync`.\n\n## Infrastructure\nInfrastructure contains configuration and helper functions to from the API implementations.\nIt makes it way easier to read `Startup.cs` when every addition is referred to as a function. Also it makes it a lot easier to set up multiple projects within the solution.\n\nThe reason this is a project in the solution and not a Nuget dependency is that it becomes a lot more transparent and possible to change in case it's needed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadslundt%2Fdotnetbasesample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadslundt%2Fdotnetbasesample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadslundt%2Fdotnetbasesample/lists"}