MiCake.Templates 10.0.0-preview.5

Prefix Reserved
This is a prerelease version of MiCake.Templates.
There is a newer version of this package available.
See the version list below for details.
dotnet new install MiCake.Templates::10.0.0-preview.5
                    
This package contains a .NET Template Package you can call from the shell/command line.

MiCake.Templates

A collection of production-ready project templates based on the MiCake framework, designed to help developers quickly scaffold high-quality ASP.NET Core applications following Domain-Driven Design (DDD) principles.

🌟 Features

  • Production-Ready: Built with best practices and real-world scenarios in mind
  • DDD Architecture: Clear separation of Domain, Application, and Infrastructure layers
  • Modern Stack: ASP.NET Core 9.0, EF Core, MySQL, JWT Authentication
  • Developer Experience: Integrated logging (Serilog + Seq), API documentation (Scalar), hot reload support
  • Extensible: Modular design makes it easy to add new features and customize for your needs

πŸ“¦ Available Templates

StandardWeb

An opinionated ASP.NET Core starter template featuring:

  • Layered Architecture: Domain, Application, Common, Web layers with clear dependencies
  • Authentication: JWT-based auth with refresh token support
  • Database: MySQL with EF Core migrations
  • API Documentation: OpenAPI (Swagger) + Scalar UI
  • Logging: Serilog with Seq integration
  • Validation: FluentValidation for request validation
  • Mapping: AutoMapper for DTO conversions
  • Error Handling: Standardized error codes and responses

πŸ“– Detailed Documentation: See StandardWeb README (English) or StandardWeb README (Chinese)

πŸš€ Quick Start

Installation

  1. Install the template package:

    dotnet new install .
    
  2. Create a new project:

    dotnet new micake-standardweb -n YourProject.Name
    
  3. Navigate to the project:

    cd YourProject.Name/src/StandardWeb
    
  4. Restore dependencies:

    dotnet restore StandardWeb.sln
    
  5. Configure database connection:

    • Update StandardWeb.Web/appsettings.json with your MySQL connection string
    • Set the AESEncryption:Key (minimum 16 characters)
  6. Apply database migrations:

    dotnet ef database update --project StandardWeb.Web
    
  7. Run the application:

    dotnet watch --project StandardWeb.Web
    
  8. Access API documentation:

    • Open your browser to https://localhost:5001/scalar/v1 (or the configured port)

πŸ—οΈ Architecture Overview

The StandardWeb template follows a clean layered architecture:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Web Layer (StandardWeb.Web)                    β”‚
β”‚  - Controllers, DTOs, Startup configuration     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚ depends on
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Application Layer (StandardWeb.Application)    β”‚
β”‚  - Services, Providers, Cache, Use Cases        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚ depends on
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Domain Layer (StandardWeb.Domain)              β”‚
β”‚  - Entities, Aggregates, Repositories, DbContextβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚                 β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Common        β”‚  β”‚ CommonWebLib      β”‚
β”‚ (Helpers,     β”‚  β”‚ (Base Controllers,β”‚
β”‚  Auth Config) β”‚  β”‚  HTTP Clients)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Layer Responsibilities

  • Web: HTTP request handling, API endpoints, request/response DTOs
  • Application: Business logic, orchestration, use cases, caching
  • Domain: Core business entities, domain logic, repository interfaces
  • Common: Shared utilities, helpers, and cross-cutting concerns
  • CommonWebLib: Reusable web infrastructure components

πŸ“ Configuration

Key configuration sections in appsettings.json:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Database=standardweb;User=root;Password=yourpassword;"
  },
  "Jwt": {
    "Issuer": "YourIssuer",
    "Audience": "YourAudience",
    "SecretKey": "your-secret-key-min-32-chars",
    "AccessTokenExpirationMinutes": 30,
    "RefreshTokenExpirationDays": 7
  },
  "AESEncryption": {
    "Key": "your-16-char-key!"
  },
  "AllowedOrigins": "https://yourdomain.com,https://*.yourdomain.com",
  "Serilog": {
    "Using": ["Serilog.Sinks.Seq"],
    "WriteTo": [
      { "Name": "Seq", "Args": { "serverUrl": "http://localhost:5341" } }
    ]
  }
}

πŸ”§ Adding a New Feature Module

Follow these steps to add a new business module:

  1. Define Domain Models in StandardWeb.Domain/Models/[YourModule]
  2. Create Repository Interface in StandardWeb.Domain/Repositories/Interfaces
  3. Implement Repository in StandardWeb.Domain/Repositories
  4. Create Application Service in StandardWeb.Application/Services/[YourModule]
  5. Define DTOs in StandardWeb.Web/Dtos/[YourModule]
  6. Create Controller in StandardWeb.Web/Controllers/[YourModule]Controller.cs
  7. Add AutoMapper Profile in StandardWeb.Web/Mapper/[YourModule]Profile.cs
  8. Add Validators in StandardWeb.Web/Validators/[YourModule] (if needed)

Example controller structure:

[Route("api/[controller]")]
public class ProductController : BaseApiController
{
    private readonly IProductService _service;

    public ProductController(InfrastructureTools tools, IProductService service) 
        : base(tools)
    {
        ModuleCode = "03"; // Unique module code
        _service = service;
    }

    [HttpGet("{id}")]
    public async Task<IActionResult> GetById(long id)
    {
        var result = await _service.GetByIdAsync(id, HttpCancellationToken);
        return result.IsSuccess 
            ? Ok(result.Data) 
            : BadRequest(ErrorCodeDefinition.NotFound, result.ErrorMessage);
    }
}

πŸ§ͺ Testing

The template is designed to be easily testable:

  1. Unit Tests: Test domain logic and services in isolation
  2. Integration Tests: Test API endpoints with in-memory database
  3. E2E Tests: Test complete workflows through HTTP clients

Example test structure:

YourProject.Tests/
β”œβ”€β”€ Unit/
β”‚   β”œβ”€β”€ Domain/
β”‚   β”œβ”€β”€ Application/
β”‚   └── Helpers/
β”œβ”€β”€ Integration/
β”‚   └── Controllers/
└── TestUtilities/

πŸ“š Additional Resources

🀝 Contributing

Contributions are welcome! Please feel free to submit issues or pull requests to improve these templates.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ’¬ Support

🎯 Roadmap

  • Add more template variants (Microservices, Blazor, etc.)
  • Include Docker and Docker Compose configurations
  • Add example test projects
  • Create migration guides from existing projects
  • Add CI/CD pipeline templates (GitHub Actions, Azure DevOps)

Happy Coding! πŸŽ‰

  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.0 112 5/11/2026
10.0.0-preview.9 197 1/21/2026
10.0.0-preview.8 182 1/18/2026
10.0.0-preview.7 183 1/16/2026
10.0.0-preview.5 179 1/16/2026