Caravel-Template

Caravel Template - code less, ship more.

MIT License

Stars
5
Committers
2

Caravel Template

This template uses Caravel package as an SDK and it bootstraps a full functional web api following the Hexagonal Architecture:

  • CaravelTemplate (Application Domain)
  • CaravelTemplate.Application (Application business logic)
  • CaravelTemplate.Adapter.MassTransit (Adapter to enable message queuing using MassTransit)
  • CaravelTemplate.Adapter.Quartz (Adapter to enable scheduling jobs using Quartz)
  • CaravelTemplate.Adapter.PostgreSql (Adapter to enable database assess queuing using Entity Framework and PostgreSql)
  • CaravelTemplate.Adapter.Identity (Adapter to enable user management using ASP.NET Identity)
  • CaravelTemplate.Adapter.API (HTTP API Server using ASP.NET 8.0)
  • CaravelTemplate.Host (The program entry point that glues all the adapters and server)
  • CaravelTemplate.Migrator (A slim program to handle entity framework migrations)

Features

Aspire Dashboard

Installation

Download and Install Template

git clone [email protected]:Talento90/caravel-template.git
dotnet new --install ~/caravel-template

Generate Project

dotnet new caravel-webapi -n MyProject -o ./

Note: MyProject is going to replace the CaravelTemplate

Run Web Api

dotnet run --project src/MyProject.WebApi

open http://localhost:5000/swagger/index.html

Docker Compose

  • Setup PostgreSql container
  • Setup RabbitMQ container
  • Setup Aspire Dashboard container
# Setup and run docker compose
docker compose up

# Remove containers
docker compose down

Entity Framework Migrations

# Install dotnet-ef tool
dotnet tool install --global dotnet-ef

# Update dotnet-ef tool
dotnet tool update --global dotnet-ef

# List all migrations
dotnet ef migrations list --startup-project src/CaravelTemplate.Migrator --project src/CaravelTemplate.Adapter.PostgreSql --context ApplicationDbContext --no-build

# Generate SQL Scripts
dotnet ef migrations script --startup-project src/CaravelTemplate.Migrator --project src/CaravelTemplate.Adapter.PostgreSql --context ApplicationDbContext --no-build 

# Add new database migration changes to the Application DbContext
dotnet ef migrations add CreateApplicationSchema --startup-project src/CaravelTemplate.Migrator --output-dir Migrations --project src/CaravelTemplate.Adapter.PostgreSql --context ApplicationDbContext --no-build
 
# Apply the migration changes
dotnet ef database update --startup-project src/CaravelTemplate.Migrator --project src/CaravelTemplate.Adapter.PostgreSql --context ApplicationDbContext --no-build