⭐⭐ When imagination meets innovation, dreams become reality. ⭐⭐
V1 Primary knight |
V2 Moon knight |
V3 Arabian knight |
- Knight Template Overview
- Aim and Purpose
- Why KnightHedgeArchitecture?
- Design Approach
- Features
- Screenshots
- Used Packages
- Upcoming in Version 2: Ultimate Knight Hedge
- Postman collection
- Getting Started
- Contact owner
The KnightArchitecture
template is a comprehensive, modular solution for developers looking to accelerate the development of enterprise-grade applications. This template provides a solid foundation of essential building blocks such as authentication, authorization, auditing, caching, background jobs, and real-time notifications. Each component is crafted with simplicity and scalability in mind, allowing developers to focus on core business logic rather than setting up repetitive foundational features.
The primary aim of this template is to save developers time and effort by offering a fully functional, extensible starting point for any new project. By integrating commonly used services and best practices, KnightHedgeArchitecture
allows teams to jumpstart their development process while maintaining a focus on best practices. Whether building a new API, a web service, or a complex enterprise application, this template provides a reliable, efficient backbone that’s both flexible and easy to extend.
- Ease of Use: This template follows a simple and intuitive design approach, making it easy to understand, set up, and extend.
- Modularity: Each building block (e.g., authentication, caching, auditing) is a self-contained module, allowing developers to pick and use components as needed.
- Scalability: Built with scalability in mind, this template is suitable for applications of all sizes, from small projects to large, enterprise-grade solutions.
- Standardization: Provides a structured approach that standardizes code patterns and promotes maintainability, reducing technical debt over time.
Setting up the foundational components of an application can be repetitive and time-consuming. The KnightHedgeArchitecture
template handles these essentials, enabling developers to:
- Accelerate Development: Quickly get up and running with a well-designed foundation, eliminating the need to set up repetitive boilerplate code.
- Implement Best Practices: Adhere to best practices in security, scalability, and modular design, which are critical in production-grade applications.
- Focus on Business Logic: By abstracting core services like authentication, auditing, and error handling, developers can concentrate on implementing business-specific features.
- Improve Collaboration: The standardized structure allows team members to understand and contribute to the codebase more efficiently, with clearly defined modules and services.
The KnightHedgeArchitecture
template is built with simplicity and readability at its core. Every feature follows a straightforward approach, ensuring that the codebase is easy to understand and modify. This approach makes it ideal for developers of varying experience levels and ensures that new team members can quickly get up to speed.
- Single Responsibility Principle: Each service, module, and class focuses on a single responsibility, promoting code clarity and ease of maintenance.
- Plug-and-Play: Each building block is designed to be independent, meaning developers can include or exclude modules without affecting the core functionality.
- Configuration-Driven: Using configuration files, developers can quickly set up or modify features (e.g., caching, logging, background jobs) without diving into the codebase.
- Separation of Concerns: The codebase is organized into layers (e.g., Domain, Application, Infrastructure), ensuring a clean separation between core logic, infrastructure dependencies, and API logic.
- Dual Authentication (JWT & Basic): Enables flexible identity verification.
- Role-Based Access Control: Manages user access with roles and permissions.
- Permission Middleware: Enforces granular access control on endpoints.
- Permission-Based Protection: Implements
PermissionAuthorizeAttribute
for secure API endpoints. - Dynamic Policies: Allows configurable policies based on role and permission changes without modifying code.
- User Registration and Profile Management: Enables user sign-up, profile updates, and role assignment.
- Role and Permission Management: Admins can dynamically manage roles and permissions.
- Change Tracking: Logs create, update, and delete actions with detailed record history.
- Excel Export of Logs: Allows exporting audit trails for compliance and review purposes.
- Request and Error Logging: Tracks HTTP requests, responses, and errors for audit and troubleshooting.
- Single and Bulk Emails: Supports customized templates for welcome and notification emails.
- Email Tracking: Logs email statuses for audits and follow-up.
- Retry and Scheduling: Failed emails can be retried or scheduled for future delivery.
- Template-based Messaging: Customizable SMS templates for various alerts.
- Logging: Tracks SMS delivery statuses, including failures.
- SMS and Email Notifications: Manages notifications with customizable templates.
- Tracking and Logging: Logs SMS and email statuses, maintaining a detailed record of communications.
- Quartz.NET and Hangfire Integration: Manages scheduled jobs and supports retries.
- Automated Tasks: Supports tasks like email dispatch and SMS notifications.
- DinkToPdf Integration: Provides PDF generation capabilities.
- Automated Export: Supports transactional documents and custom reports.
- Dynamic PDF Generation: Create PDFs using predefined HTML templates and dynamic placeholders.
- Invoice Generation: Generate invoices with multi-language support and localized content.
- PDF Merging: Combine multiple PDFs into a single document.
- Flexible Libraries: Supports multiple tools like QuestPDF, PDFsharp, and NReco for diverse use cases.
- QuestPDF: For building complex layouts with precise control over content styling.
- PDFsharp: For merging and manipulating PDF documents.
- NReco.PdfGenerator: For converting raw HTML into PDF files.
- Data Export: Allows offline reporting and analysis.
- Bulk Data Import: Supports audit logs and user lists, maintaining a consistent format with customizable templates.
- StackExchange.Redis Integration: Distributed caching to reduce database load.
- Flexible Caching: Enhances data retrieval efficiency and performance.
- Localized Error Messages: Supports languages like English and Arabic.
- User Language Preferences: Customizable for a personalized experience.
- Independent Services: Provides separate modules for notifications, caching, auditing, and file handling.
- Scalability: Allows easy addition of new modules and features.
- FluentValidation: Ensures structured model validation.
- Localized Error Handling: Provides language-specific error messages.
- Secure File Uploads: Processes files with validation checks.
- Media Management: Organizes and retrieves media files efficiently.
- Push Notifications: Provides real-time updates using SignalR.
- Compatibility: Supports WebSockets and Long Polling.
- Configurable CORS Policies: Allows secure cross-domain interactions based on origin.
- Simplified CRUD Operations: Standard methods for Create, Read, Update, and Delete make data interactions consistent across all entities.
- Reusability and Maintainability: A single repository for all entities means less code duplication, reduced errors, and easy maintenance.
- Enhanced Performance with Caching: Built-in support for caching frequently accessed data reduces load on the database.
- Advanced Querying: Supports complex filters, eager loading, pagination, and projections, offering flexibility for data retrieval.
This section provides visual examples of key output formats in KnightHedgeArchitecture, including PDF exports, email templates, and SMS notifications.
Below is an example of a generated PDF document for transactional records or user reports. This PDF is generated using DinkToPdf, ensuring customized layouts and consistency across exports.
Here’s a sample email sent through the Email Service, utilizing Razor templates for a professional, branded appearance. Emails can be customized for different notifications, such as welcome emails, alerts, or updates.
Example SMS message generated for alerts and notifications. SMS notifications are template-based, allowing easy customization for different types of messages.
Example Auditing data generated automatically by ef core.
Here is a list of key packages used in this project and their purpose:
- Purpose: Provides Object-Relational Mapping (ORM) to interact with databases.
- Features: Supports migrations, change tracking, and database querying capabilities, making database operations simpler and more organized.
- Purpose: Lightweight ORM for more efficient SQL queries and database access.
- Usage: Used in performance-critical operations where Entity Framework might be slower, enabling rapid and optimized data retrieval.
- Purpose: Simplifies object-to-object mapping, reducing boilerplate code.
- Usage: Maps domain entities to Data Transfer Objects (DTOs) and vice versa, used across services and entities to enhance modularity and maintainability.
- Purpose: Validation framework used to enforce data integrity.
- Usage: Validates DTOs and requests, ensuring that incoming data conforms to expected formats in API controllers and services.
- Purpose: Generates interactive API documentation.
- Usage: Provides a visual interface for API endpoints via Swagger UI, allowing for easy testing and documentation of API functions.
- Purpose: Structured logging for easy-to-read logs.
- Usage: Logs application behavior and helps with troubleshooting, enhancing error tracking and performance monitoring.
- Purpose: JSON library for serialization and deserialization.
- Usage: Formats and processes JSON requests and responses, crucial for APIs that handle JSON data.
- Purpose: Robust job scheduling library.
- Usage: Enables background job scheduling, allowing automation of repetitive tasks and scheduled processing.
- Purpose: PDF generation library.
- Usage: Used for creating and customizing PDF documents, particularly in reporting and documentation modules.
- Purpose: Redis cache support for distributed caching.
- Usage: Reduces database load and improves performance by caching frequently accessed data.
- Purpose: Background job processing library.
- Usage: Manages tasks like email dispatching, SMS notifications, and other background processes, making asynchronous task handling efficient.
The upcoming version, **Ultimate Knight Hedge**, introduces new, trending .NET libraries and tools to enhance functionality, improve performance, and simplify integrations. Below are some key additions planned for version 2:
-
Polly: Advanced resilience and transient fault-handling library. Polly will enable the application to handle retries, circuit breakers, and fallback mechanisms gracefully, improving system reliability.
-
Keycloak: For secure authentication and authorization.
-
Camunda: Powerful process automation and workflow management.
-
Angular Dashboard: An intuitive, responsive UI for managing application data and operations.
-
Escalation
-
Refit: A RESTful API client library for .NET. Refit will simplify API integrations, enabling effortless setup of HTTP clients with strongly-typed, interface-based HTTP requests.
-
Fluent Assertions: A powerful assertion library for .NET, designed to improve the readability and maintainability of tests. Fluent Assertions will be used to write expressive, readable test assertions, making unit testing more efficient and reliable.
-
GitHub Actions: Built-in CI/CD support using GitHub Actions for automated testing, deployment, and monitoring. Version 2 will provide pre-configured GitHub Action workflows, making continuous integration and deployment simpler and faster.
-
Rate Limiting: Improved rate-limiting controls to manage API consumption, preventing abuse and ensuring fair resource usage. This will provide better control over API traffic and reduce the risk of service overload.
-
Health check: Improved monitoring for app status.
-
Advanced looging: Improved monitoring for app performance and sending emails to it department is slow performance detected.
-
Auto Escalation: Automatically escalate tasks or incidents based on predefined rules and timelines, ensuring timely responses and efficient workflow management.
-
Enhanced Modular Architecture: With additional extensions, such as better support for microservices and domain-driven design (DDD) patterns, Ultimate Knight Hedge will allow for more fine-grained customization and scalability across services.
All API found here.
- .NET SDK
- Entity Framework Core (for migrations)
- Database (e.g., SQL Server, PostgreSQL)
Using the
KnightHedgeArchitecture
template is simple:
- Clone the Repository: Download the repository and open it in your IDE.
- Configure Dependencies: Modify configuration files (
appsettings.json
) for services like database, caching, email, and SMS. - Apply database migrations: by running: Update-database - dotnet ef database update
- Enable/Disable Modules: Decide on the modules you need and integrate them as required.
- Build Your Features: Start building your application on top of a robust and reliable architecture.
-
DevOps Pre-requisite Course on KodeKloud: This course provides foundational knowledge of Docker and DevOps essentials, crucial for setting up this project.
-
Docker Guide for .NET Developers by Code With Mukesh: A detailed guide that helped in effectively containerizing .NET applications using Docker.
-
Deploy ASP.NET Core Web API to Amazon ECS by Code With Mukesh: This tutorial guided the deployment process of the ASP.NET Core Web API on Amazon ECS.
-
Microservices Architecture and Implementation on .NET by Udemy: A comprehensive course that influenced the microservices architecture and design patterns implemented in this project.
-
postman simulation: postman-api-performance-testing