Skip to content
/ dotnet-boilterplate Public template

A modern boilerplate for authentication and session management using ADO.NET and PostgreSQL.

License

Notifications You must be signed in to change notification settings

Xjectro/dotnet-boilterplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

34 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

.NET Boilerplate

A production-ready .NET 10 boilerplate with microservices architecture, featuring ScyllaDB (Cassandra-compatible), Redis, RabbitMQ, and comprehensive service implementations.

πŸš€ Features

  • βœ… RESTful API with Swagger/ReDoc documentation
  • βœ… ScyllaDB (Cassandra-compatible) for distributed NoSQL storage
  • βœ… Redis for high-performance caching
  • βœ… RabbitMQ for asynchronous message processing
  • βœ… JWT Authentication for secure API access
  • βœ… Rate Limiting with multiple strategies (Fixed Window, Token Bucket, Sliding Window)
  • βœ… Mail Service with queue-based async sending
  • βœ… Media Service with MinIO object storage and ImageSharp optimization
  • βœ… Worker Service for background job processing
  • βœ… Logging with Serilog and Seq dashboard
  • βœ… Docker containerization with Docker Compose
  • βœ… Health Checks for all services
  • βœ… BCrypt password hashing
  • βœ… Repository Pattern with dependency injection

πŸ“‹ Prerequisites

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Client    │────▢│   API    │────▢│ ScyllaDB  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
                    β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
                    β”‚           β”‚
              β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
              β”‚  Redis   β”‚ β”‚ RabbitMQ β”‚
              β”‚  Cache   β”‚ β”‚  Queue   β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
                    β”‚           β”‚
              β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
              β”‚  MinIO   β”‚ β”‚  Worker   β”‚
              β”‚  Media   β”‚ β”‚  Service  β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Using Docker (Recommended)

git clone https://github.com/Xjectro/dotnet-boilterplate.git
cd dotnet-boilterplate

make dev

# API: http://localhost:5143
# Swagger: http://localhost:5143/swagger
# MinIO Console: http://localhost:9001 (minioadmin/minioadmin123)
# RabbitMQ Management: http://localhost:15672 (admin/admin123)

Local Development

# Restore dependencies
dotnet restore

# Run the API locally
dotnet run --project src/presentation/api/Api.csproj

πŸ“š Documentation

Comprehensive documentation is available in the docs folder:

πŸ› οΈ Configuration

Environment Variables

Key configuration can be set via environment variables:

# JWT
JwtSettings__Secret=your-secret-key
JwtSettings__ExpiryMinutes=60

# Redis
Redis__Host=redis:6379

# Scylla (Cassandra-compatible settings)
Cassandra__ContactPoints=scylla
Cassandra__Port=9042
Cassandra__Keyspace=default_keyspace

# RabbitMQ
RabbitMq__Host=rabbitmq
RabbitMq__Port=5672
RabbitMq__Username=admin
RabbitMq__Password=admin123

# Media (MinIO)
Media__Endpoint=http://minio:9000
Media__AccessKey=minioadmin
Media__SecretKey=minioadmin123
Media__BucketName=uploads
Media__PublicUrl=http://localhost:9000
Media__MaxFileSize=10485760

πŸ“‘ API Endpoints

Mail Service

POST /api/mail/send
Content-Type: application/json

{
      "to": ["user@example.com"],
      "subject": "Welcome!",
      "body": "<h1>Hello World</h1>",
      "isHtml": true
}

Media Service

# Upload file
POST /api/media/upload?folder=images&generateThumbnail=true
Content-Type: multipart/form-data

# Get file
GET /api/media/{fileName}

# Delete file
DELETE /api/media/{fileName}

# List files
GET /api/media/list?folder=images

Client Management

GET /api/client
POST /api/client
PUT /api/client/{id}
DELETE /api/client/{id}

Visit /swagger for complete API documentation.

πŸ—οΈ Project Structure

β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ core/               # Domain entities and shared contracts
β”‚   β”œβ”€β”€ application/        # Use cases, validation, and interfaces
β”‚   β”œβ”€β”€ infrastructure/     # External adapters (DB, messaging, storage)
β”‚   └── presentation/
β”‚       └── api/            # ASP.NET Core API host and middleware
β”œβ”€β”€ deploy/
β”‚   └── docker/             # Dockerfiles and compose configurations
β”œβ”€β”€ docs/                   # Additional documentation (guides, ADRs)
β”œβ”€β”€ tests/                  # Unit and integration test projects
β”œβ”€β”€ ops/                    # CI/CD pipelines and operational scripts
β”œβ”€β”€ api.sln                 # Solution file
└── README.md

πŸ”§ Development

Build

dotnet build

Run Tests

dotnet test

Format Code

dotnet format

🐳 Docker Commands

# Start development environment (with build)
make dev

# Start production environment (detached with build)
make prod

# View logs
docker compose -f deploy/docker/dev/docker-compose.yml logs -f

# Stop services
docker compose -f deploy/docker/dev/docker-compose.yml down

# Stop and remove volumes
docker compose -f deploy/docker/dev/docker-compose.yml down -v

πŸ“Š Services

ScyllaDB

  • Port: 9042
  • Keyspace: default_keyspace
  • Replication: SimpleStrategy (Dev)

Redis

  • Port: 6379
  • Persistence: AOF enabled

RabbitMQ

API

πŸ” Security

  • JWT token-based authentication
  • BCrypt password hashing
  • Environment variable configuration
  • Docker secrets support
  • HTTPS ready

🚦 Health Checks

All services include health checks:

# API Health
curl http://localhost:5143/health

# Docker health status
docker ps --format "table {{.Names}}\t{{.Status}}"

🀝 Contributing

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

πŸ“ License

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

πŸ“§ Contact

For questions or support, please open an issue on GitHub.

πŸ™ Acknowledgments

  • .NET Team for the amazing framework
  • Docker for containerization
  • ScyllaDB for distributed database
  • Redis for caching
  • RabbitMQ for message queuing

Built with ❀️ using .NET 10