✨ A complete, production-ready .NET 9.0 Web API template with Clean Architecture
Ready to use out of the box! Just clone, configure, and deploy.
Features • Quick Start • Documentation • API Endpoints • Contact
🟢 PRODUCTION READY - This project is fully functional and ready for immediate use.
- ✅ Complete authentication system
- ✅ Email verification workflow
- ✅ Password reset with OTP
- ✅ JWT token management
- ✅ File upload integration
- ✅ Database migrations included
- ✅ Error handling implemented
- ✅ Logging configured
- ✅ API documentation (Swagger)
Temp-Back_End is a professional backend API template built with Clean Architecture principles. It's designed to be a starting point for building enterprise-level applications, saving you weeks of development time.
- 🚀 Save Time - Start with a complete, working solution
- 🏗️ Best Practices - Follows industry-standard architecture patterns
- 🔒 Secure by Default - Built-in security features
- 📚 Well Documented - Comprehensive API documentation
- 🔧 Easy to Customize - Clean, maintainable code structure
- ⚡ Production Ready - Tested and ready for deployment
- ✅ User registration with email verification
- ✅ JWT-based authentication with refresh tokens
- ✅ Token validation and refresh
- ✅ Multi-session management
- ✅ Secure logout (single & all sessions)
- ✅ Role-based access control (User, Admin, Devo)
- ✅ Complete user registration flow
- ✅ Profile image upload (Cloudinary integration)
- ✅ Email verification via secure tokens
- ✅ Password reset with OTP codes
- ✅ User profile management
- ✅ PBKDF2 password hashing (100,000 iterations)
- ✅ Secure token generation
- ✅ Email domain validation
- ✅ Input validation with Value Objects
- ✅ SQL injection protection (EF Core)
- ✅ CORS configuration
- ✅ Email verification
- ✅ Password reset emails
- ✅ OTP code delivery
- ✅ HTML email templates
- ✅ Cloudinary integration
- ✅ Image upload with optimization
- ✅ Default image fallback
- ✅ Image deletion
- ✅ API Versioning
- ✅ Swagger/OpenAPI documentation
- ✅ Structured logging (Serilog)
- ✅ Global exception handling
- ✅ Database migrations
- ✅ Clean Architecture pattern
- .NET 9.0 SDK
- SQL Server (or SQL Server Express)
- Visual Studio 2022 or VS Code
git clone https://github.com/OmarMahamad/Temp-Back_End.git
cd Temp-Back_EndEdit sorc/BackEnd.Api/appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Server=YOUR_SERVER;Database=YourDatabase;Trusted_Connection=True;TrustServerCertificate=True;"
}
}cd sorc/BackEnd.Api
dotnet ef database update --project ../BackEnd.InfrastructureUpdate sorc/BackEnd.Api/appsettings.json with your settings:
{
"Jwt": {
"Key": "YOUR_SECRET_KEY_MIN_32_CHARACTERS_LONG",
"Issuer": "YourApp",
"Audience": "YourFrontend",
"DurationInMinutes": 40
},
"EmailSettings": {
"SmtpServer": "smtp.gmail.com",
"SmtpPort": 587,
"SmtpUser": "your-email@gmail.com",
"SmtpPassword": "your-app-password"
},
"Cloudinary": {
"CloudName": "your-cloud-name",
"ApiKey": "your-api-key",
"ApiSecret": "your-api-secret",
"Folder": "generated_images",
"DeliveryFormat": "webp"
}
}
⚠️ Important: For production, use Environment Variables instead of storing secrets inappsettings.json.
dotnet run --project sorc/BackEnd.ApiOpen your browser and navigate to:
- Swagger UI:
https://localhost:5001/swagger - API Base URL:
https://localhost:5001/api/v1
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/v1/Authorization/Register |
Register new user | ❌ |
| POST | /api/v1/Authorization/Login |
User login | ❌ |
| POST | /api/v1/Authorization/emailverify/{token} |
Verify email | ❌ |
| POST | /api/v1/Authorization/resend-verification-email |
Resend verification email | ❌ |
| POST | /api/v1/Authorization/ForgotPasswordAsync |
Request password reset | ❌ |
| POST | /api/v1/Authorization/Check-Otp-Code |
Verify OTP code | ❌ |
| POST | /api/v1/Authorization/Reset-Password |
Reset password | ❌ |
| POST | /api/v1/Authentication/Refresh-AccessToken |
Refresh access token | ✅ |
| POST | /api/v1/Authentication/ValidateToken |
Validate token | ✅ |
| POST | /api/v1/Authentication/Logout |
Logout (single session) | ✅ |
| POST | /api/v1/Authentication/Logout-FromAllSessions/{userid} |
Logout all sessions | ✅ |
POST /api/v1/Authorization/Register
Content-Type: multipart/form-data
{
"Name": "John Doe",
"Email": "john@example.com",
"Password": "SecurePassword123!",
"Phone": "+1234567890",
"verify_email_url": "https://yourfrontend.com/verify-email",
"file": "[Image File - Optional]",
"Address": {
"Street": "123 Main St",
"City": "New York"
}
}POST /api/v1/Authorization/Login
Content-Type: application/json
{
"Email": "john@example.com",
"Password": "SecurePassword123!"
}Response:
{
"isSuccess": true,
"message": "Success",
"code": 100,
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIs...",
"refreshToken": "base64-encoded-token..."
}
}- Navigate to
https://localhost:5001/swagger - Click Authorize button
- Enter:
Bearer {your-token} - Test all endpoints interactively
This project follows Clean Architecture with clear separation of concerns:
┌─────────────────────────────────────┐
│ BackEnd.Api (Presentation) │
│ Controllers, Middleware, Config │
└──────────────┬──────────────────────┘
│
┌──────────────▼──────────────────────┐
│ BackEnd.Application (Business) │
│ Services, DTOs, Application Logic │
└──────────────┬──────────────────────┘
│
┌──────────────▼──────────────────────┐
│ BackEnd.Domin (Domain) │
│ Entities, Value Objects, Domain │
└──────────────┬──────────────────────┘
│
┌──────────────▼──────────────────────┐
│ BackEnd.Infrastructure (Data) │
│ Database, External Services │
└──────────────────────────────────────┘
- Repository Pattern - Data access abstraction
- Unit of Work - Transaction management
- Factory Pattern - Entity creation
- Value Objects (DDD) - Domain modeling
- Response Pattern - Unified API responses
- ✅ Password Hashing: PBKDF2 with 100,000 iterations
- ✅ JWT Tokens: Secure token-based authentication
- ✅ Refresh Token Rotation: Enhanced security
- ✅ Email Validation: Domain whitelist and validation
- ✅ Input Validation: Value Objects pattern
- ✅ SQL Injection Protection: EF Core parameterized queries
- ✅ CORS: Configurable cross-origin policies
All API responses follow a consistent format:
Success:
{
"isSuccess": true,
"message": "Operation completed successfully",
"code": 100,
"data": { /* response data */ }
}Error:
{
"isSuccess": false,
"message": "Error message",
"code": 401,
"errors": { /* validation errors */ }
}# Create migration
dotnet ef migrations add MigrationName --project sorc/BackEnd.Infrastructure
# Apply migrations
dotnet ef database update --project sorc/BackEnd.Infrastructure- Users - User accounts and profiles
- Addresses - User addresses
- AuthoRepositories - Refresh tokens
- OtpCodes - OTP codes for password reset
- EmailVerificationTokens - Email verification tokens
JWT__Key=your-secret-key
JWT__Issuer=YourApp
JWT__Audience=YourFrontend
ConnectionStrings__DefaultConnection=Server=...;Database=...
EmailSettings__SmtpServer=smtp.gmail.com
EmailSettings__SmtpUser=your-email@gmail.com
EmailSettings__SmtpPassword=your-app-password
Cloudinary__CloudName=your-cloud-name
Cloudinary__ApiKey=your-api-key
Cloudinary__ApiSecret=your-api-secret- Create Azure App Service
- Configure connection strings
- Set environment variables
- Deploy using Visual Studio or Azure CLI
FROM mcr.microsoft.com/dotnet/aspnet:9.0
WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "BackEnd.Api.dll"]- .NET 9.0 - Latest .NET framework
- ASP.NET Core Web API - RESTful API
- Entity Framework Core 9.0 - ORM
- SQL Server - Database
- JWT Bearer - Authentication
- Serilog - Logging
- Swagger/OpenAPI - API documentation
- Cloudinary - Image hosting
- MailKit - Email delivery
Temp-Back_End/
├── sorc/
│ ├── BackEnd.Api/ # API Layer
│ ├── BackEnd.Application/ # Business Logic
│ ├── BackEnd.Domin/ # Domain Models
│ └── BackEnd.Infrastructure/ # Data Access
└── README.md
- Move JWT key to environment variables
- Configure CORS for specific origins
- Enable HTTPS only
- Set up proper logging
- Configure email service
- Set up Cloudinary account
- Review security settings
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License.
- 📧 Issues: GitHub Issues
- 📖 Documentation: Check Swagger UI at
/swagger - 💼 LinkedIn: Omar Mahamad
- 🐙 GitHub: @OmarMahamad
If you find this project helpful, please give it a ⭐ star on GitHub!