Краткое описание backend-части проекта LifeOS.
Решение разделено на слои:
LifeOS.Domain— доменная модель, агрегаты, value objects, domain eventsLifeOS.Application— application services, orchestration, DI-регистрация, resilienceLifeOS.Infrastructure— EF Core, PostgreSQL, репозитории, outbox, loggingLifeOS.Api— REST API, Swagger, health checks, ProblemDetails
- .NET SDK
- PostgreSQL
dotnet-ef
Установка EF CLI:
dotnet tool install --global dotnet-efdotnet restore
dotnet buildПример appsettings.Development.json для API:
{
"ConnectionStrings": {
"LifeOS": "Host=localhost;Port=5432;Database=lifeos;Username=postgres;Password=postgres"
}
}dotnet ef migrations add InitialCreate \
--project src/LifeOS.Infrastructure \
--startup-project src/LifeOS.Api \
--output-dir Persistence/Migrationsdotnet ef database update \
--project src/LifeOS.Infrastructure \
--startup-project src/LifeOS.Apidotnet run --project src/LifeOS.ApiПосле запуска открой Swagger UI по адресу приложения, например:
https://localhost:5001/swagger
http://localhost:5000/swagger
Точный адрес зависит от launchSettings.json и конфигурации проекта.
Запуск всех тестов:
dotnet testОтдельно по слоям:
dotnet test tests/LifeOS.Domain.Tests
dotnet test tests/LifeOS.Application.Tests
dotnet test tests/LifeOS.Infrastructure.Tests
dotnet test tests/LifeOS.Api.TestsОчистка артефактов сборки:
dotnet cleanСписок миграций:
dotnet ef migrations list \
--project src/LifeOS.Infrastructure \
--startup-project src/LifeOS.ApiУдаление последней миграции, если она еще не применена:
dotnet ef migrations remove \
--project src/LifeOS.Infrastructure \
--startup-project src/LifeOS.ApiВ Program.cs API:
builder.Services.AddApplication(builder.Configuration);
builder.Services.AddInfrastructure(builder.Configuration);dotnet restore
dotnet build
dotnet ef migrations add InitialCreate \
--project src/LifeOS.Infrastructure \
--startup-project src/LifeOS.Api \
--output-dir Persistence/Migrations
dotnet ef database update \
--project src/LifeOS.Infrastructure \
--startup-project src/LifeOS.Api
dotnet run --project src/LifeOS.Api