Base Template¶
The ConnectSoft Base Template (MicroserviceTemplate.Base) is the foundational layer that provides the core structure and common infrastructure for all specialized microservice templates. It is domain-agnostic and serves as the canonical foundation that specialized templates extend through overlays.
Overview¶
The Base Template provides the microservice "kernel" - all common structure and bootstrapping without domain-specific logic. It follows Clean Architecture principles and includes base projects for Host, Domain, Application, Infrastructure, and Tests. Specialized templates (Identity, Auth Server, Audit, Worker, etc.) extend this base template by including it as a Git submodule and adding domain-specific functionality.
When to Use This Template¶
Use the Base Template when:
- Creating new specialized template overlays
- Understanding the foundation structure of ConnectSoft microservices
- Building domain-agnostic microservice infrastructure
- Extending base template functionality for custom overlays
- Learning the template architecture and layering model
When to Use Specialized Templates Instead¶
Use specialized templates (Identity Backend, Authorization Server, etc.) when:
- Building production microservices with domain-specific functionality
- You need identity, authorization, audit, or worker capabilities
- Creating services that require domain logic and business rules
Key Features¶
Solution Structure¶
- Host Project: Application host and bootstrapping
- Domain Project: Base domain abstractions (entities, value objects)
- Application Project: Base application layer interfaces
- Infrastructure Project: Base infrastructure (persistence, messaging setup)
- Test Projects: Base testing infrastructure and acceptance test framework
Bootstrapping¶
- Program/Host Configuration: Base application startup and configuration
- Dependency Injection: Base service registration patterns
- Health Checks: Common health check implementations
- Resilience Patterns: Base retry, circuit breaker, and timeout patterns
Infrastructure¶
- Base Persistence: Repository patterns and base data access
- Base Messaging: Event bus abstractions and messaging patterns
- Base Observability: Logging, metrics, and tracing setup
- Base Security: Security middleware and authentication patterns
Testing¶
- Base Testing Infrastructure: Test helpers and utilities
- Base Acceptance Tests: Acceptance test framework
- Test Configuration: Base test configuration and setup
Documentation¶
- Base Documentation Structure: MkDocs-based documentation template
- Architecture Documentation: Base architecture documentation
- Getting Started Guides: Base getting started documentation
Generated Structure¶
The Base Template generates a domain-agnostic microservice structure:
MicroserviceTemplate.Base/
├── src/
│ ├── Host/ # Application host
│ │ ├── Program.cs
│ │ └── ...
│ ├── Domain/ # Base domain abstractions
│ │ ├── Entities/
│ │ ├── ValueObjects/
│ │ └── ...
│ ├── Application/ # Base application layer
│ │ ├── Interfaces/
│ │ └── ...
│ └── Infrastructure/ # Base infrastructure
│ ├── Persistence/
│ ├── Messaging/
│ └── ...
├── tests/
│ ├── Base.Testing.Infrastructure/ # Test helpers
│ └── Base.AcceptanceTests/ # Base acceptance tests
├── docs/
│ ├── overview.md
│ ├── architecture.md
│ └── getting-started.md
└── template/
├── template.json # Base template metadata
├── ide.host.json
└── dotnetcli.host.json
Template Architecture¶
The Base Template is part of ConnectSoft's three-layer template architecture:
Layer 1: Shared Libraries¶
- NuGet packages (
ConnectSoft.Extensions.*) - Cross-cutting infrastructure
- Used by Base Template and all specialized templates
Layer 2: Base Template (This Template)¶
- Domain-agnostic microservice structure
- Common bootstrapping and infrastructure
- Foundation for all specialized templates
Layer 3: Specialized Templates (Overlays)¶
- Extend Base Template via Git submodule
- Add domain-specific functionality
- Examples: Identity Backend, Authorization Server, Audit, Worker
Template Composition¶
Specialized templates extend the Base Template through:
Git Submodule¶
- Base Template included as
base-template/submodule - Specialized templates add domain projects alongside base projects
- Both base and specialized code coexist in the same solution
Build-Time Composition¶
- Templates are fully buildable as normal .NET solutions
- Base Template code is available at build time
- Full IDE support and IntelliSense
Generation-Time Composition¶
- At generation time, base + overlay are composed
- Final template includes both base structure and domain-specific code
- Template metadata (
template.json) is merged from base + extend files
Template Parameters¶
The Base Template defines canonical parameters that all specialized templates inherit:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
ServiceName |
string | Yes | MyService |
Name of the microservice |
RootNamespace |
string | No | Company.ServiceName |
Root namespace for generated code |
UseMassTransit |
bool | No | true |
Enable MassTransit messaging |
UseNHibernate |
bool | No | true |
Enable NHibernate persistence |
UseMongoDb |
bool | No | false |
Enable MongoDB persistence |
Specialized templates can extend these parameters through template.extend.json files.
Quick Start¶
Step 1: Understand Base Template Structure¶
The Base Template is typically not used directly. Instead, specialized templates extend it. To understand the base structure:
- Review the Base Template repository structure
- Examine the base projects (Host, Domain, Application, Infrastructure)
- Study the template architecture documentation
Step 2: Create a Specialized Template¶
To create a new specialized template that extends the Base Template:
# Create new specialized template repository
mkdir MySpecializedTemplate
cd MySpecializedTemplate
# Add Base Template as Git submodule
git submodule add <base-template-repo-url> base-template
# Add domain-specific projects
# Add domain-specific tests
# Create template.extend.json
Step 3: Extend Template Metadata¶
Create template/template.extend.json to extend base metadata:
{
"extends": "base-template/template/template.json",
"identity": "ConnectSoft.MySpecializedTemplate",
"name": "My Specialized Template",
"parameters": {
"ServiceName": {
"default": "MySpecializedService"
},
"MyCustomParameter": {
"type": "bool",
"default": true
}
}
}
Architecture¶
Design Principles¶
- Domain-Agnostic: No domain-specific logic or business rules
- Foundation First: Provides stable foundation for all specialized templates
- Clean Architecture: Follows Clean Architecture and DDD patterns
- Extensibility: Designed to be extended, not modified
- Reusability: Maximum code reuse across specialized templates
Template Inheritance¶
The Base Template uses a composition model rather than inheritance:
- No Code Duplication: Base code is included via Git submodule
- Metadata Extension: Template metadata extended via
template.extend.json - Documentation Overlay: Documentation extended via overlay files
- Build-Time Development: Full build and test support during development
Integration with AI Factory¶
The Base Template is used by:
- Template Architecture: Foundation for all specialized templates
- Template Composition Engine: Base layer in template composition
- Specialized Template Development: Reference for creating new overlays
- Template Catalog: Registered as base template in catalog
Best Practices¶
Template Development¶
- Never Modify Base Directly: Always extend through specialized templates
- Maintain Compatibility: Ensure base changes don't break specialized templates
- Version Management: Track base template version in specialized templates
- Documentation: Keep base documentation up to date
Specialized Template Creation¶
- Use Git Submodule: Include base template as submodule
- Extend, Don't Duplicate: Use extend files for metadata
- Test Compatibility: Ensure specialized template works with base
- Follow Patterns: Follow established patterns from other specialized templates
Related Documents¶
- Template Architecture - Template architecture overview
- Microservice Template - Full-featured microservice template
- Identity Backend Template - Identity domain template
- Authorization Server Template - OAuth2/OpenID Connect template
- Template Architecture Implementation - Factory-specific implementation