khadem 1.0.0-beta
khadem: ^1.0.0-beta copied to clipboard
A powerful and modern Dart backend framework for building scalable web applications with built-in CLI tools, code generation, database management, caching, authentication, and production-ready deploym [...]
Khadem #
โก A powerful, modern Dart backend framework for building scalable web applications
Khadem is a comprehensive backend framework built with Dart, designed for developers who demand performance, elegance, and full control. It provides a complete toolkit for building robust web applications with features like dependency injection, modular architecture, built-in CLI tools with automatic command discovery, database management, caching, authentication, and production-ready deployment capabilities.
๐ Key Features #
Core Architecture #
- ๐ High Performance: Built with Dart for exceptional speed and efficiency
- ๐งฑ Modular Design: Service provider architecture for clean, maintainable code
- ๐ฆ Dependency Injection: Flexible container-based dependency management
- โ๏ธ Configuration System: Environment-aware configuration with dot-notation support
Development Tools #
- ๐ ๏ธ Powerful CLI: Comprehensive command-line tools with auto-discovery
- ๐ค Code Generation: Automated generation of models, controllers, middleware, providers, jobs, and listeners
- ๐ฅ Hot Reload: Development server with hot reload support
- ๐ Migration System: Database migration and seeding support
Data & Storage #
- ๐๏ธ Database Layer: Support for MySQL with ORM capabilities
- ๐พ Multiple Drivers: MySQL, Redis, and extensible driver system
- ๐งต Queue System: Background job processing with Redis support
- ๐ File Storage: Flexible file upload and storage management
Security & Auth #
- ๐ JWT Authentication: Secure token-based authentication system
- ๐ก๏ธ Middleware System: Request/response middleware for security and processing
- โ Input Validation: Comprehensive validation rules and error handling
- ๐ Security Features: Built-in protection against common web vulnerabilities
Production Ready #
- ๐ Caching: Multiple caching drivers (Redis, memory-based)
- โฐ Task Scheduling: Background job scheduling and processing
- ๐ Logging: Structured logging with multiple output formats
๐ฆ Installation #
Install Khadem CLI globally for project management:
# Install from local source (for development)
dart pub global activate --source path /path/to/khadem
Requirements #
- Dart SDK: >=3.0.0
- Supported Platforms: Windows, macOS, Linux
- Database: MySQL (optional)
- Cache: Redis (optional)
Core Dependencies #
Khadem uses these key dependencies for optimal performance:
- args: Command-line argument parsing for CLI tools
- mysql1: MySQL database connectivity
- redis: Redis caching and queue support
- dart_jsonwebtoken: JWT authentication
- dotenv: Environment variable management
- watcher: File watching for hot reload
- yaml: YAML configuration parsing
โก Quick Start #
Get started with Khadem in minutes:
1. Create New Project Structure #
khadem new --name=my_app
cd my_app
dart pub get
2. Start Development Server #
# Run your Khadem application
dart run bin/server.dart
# Or use CLI for hot reload:
# khadem serve
Your application will be running at http://localhost:3000 with hot reload enabled!
๐ Project Structure #
A typical Khadem project follows this structure:
my_app/
โโโ app/
โ โโโ http/
โ โ โโโ controllers/ # HTTP controllers
โ โ โโโ middleware/ # HTTP middleware
โ โโโ jobs/ # Background job classes
โ โโโ listeners/ # Event listeners
โ โโโ models/ # Data models
โ โโโ providers/ # Service providers
โโโ bin/
โ โโโ server.dart # Application entry point
โโโ config/
โ โโโ app.dart # Application configuration
โ โโโ development/ # Environment-specific configs
โโโ core/
โ โโโ kernel.dart # Application kernel
โโโ database/
โ โโโ migrations/ # Database migrations
โ โโโ seeders/ # Database seeders
โโโ lang/
โ โโโ ar/ # Arabic translations
โ โโโ en/ # English translations
โโโ public/
โ โโโ index.html # Static files
โโโ resources/
โ โโโ views/ # View templates
โโโ routes/
โ โโโ web.dart # Web routes
โ โโโ socket.dart # Socket routes
โโโ storage/ # File storage
โโโ tests/ # Test files
โโโ .env # Environment variables
โโโ pubspec.yaml
๐ ๏ธ CLI Commands #
Khadem features a powerful CLI with automatic command discovery:
๐ฏ Available Commands #
Project Management #
# Create new project
khadem new --name=project_name
# Start development server with hot reload
khadem serve
# Build for production
khadem build
Code Generation #
khadem make:model --name=User
khadem make:controller --name=UserController
khadem make:middleware --name=AuthMiddleware
khadem make:provider --name=AuthServiceProvider
khadem make:job --name=SendEmailJob
khadem make:listener --name=UserEventListener
khadem make:migration --name=create_users_table
Version Information #
khadem --version # Show version information
khadem version --verbose # Show detailed version info
The version command reads information dynamically from pubspec.yaml, ensuring version information is always up-to-date and synchronized with your package configuration.
๐ก Core Concepts #
Service Providers #
Organize your application logic with service providers:
class AppServiceProvider extends ServiceProvider {
@override
void register(container) {}
@override
Future<void> boot(container) async {}
}
Dependency Injection #
Use the container for clean dependency management:
class UserController {
final UserRepository repository;
UserController(this.repository);
// Constructor injection
}
Middleware System #
Add cross-cutting concerns with middleware:
class AuthMiddleware implements Middleware {
@override
MiddlewareHandler get handler => (req, res, next) async {
// Check authentication logic here (e.g., verify JWT token)
await next();
};
@override
String get name => 'Auth';
@override
MiddlewarePriority get priority => MiddlewarePriority.global;
}
๐ Why Choose Khadem? #
- โก Performance First: Built with Dart for exceptional speed and efficiency
- ๐ฏ Developer Experience: Intuitive API design with excellent tooling and auto-discovery
- ๐ง Full Control: No magic - complete transparency and control over your application
- ๐ Scalable: Designed to handle growth from prototype to production scale
- ๐ Secure: Security best practices built-in from the ground up
- ๐ Growing Ecosystem: Active development with expanding feature set
- ๐ค Smart CLI: Powerful command-line tools with automatic discovery
- ๐ฅ Modern: Takes advantage of latest Dart features and best practices
- ๐ Dynamic Configuration: Version and metadata automatically synchronized
๏ฟฝ License #
Khadem is licensed under the Apache License 2.0. This permissive license allows you to use, modify, and distribute the framework freely, including for commercial purposes, as long as you include the original copyright notice and license text.
For more details, see the LICENSE.md file in this repository.
๏ฟฝ๐ Support & Community #
- ๐ Bug Reports: GitHub Issues
- ๐ก Feature Requests: GitHub Discussions
- ๐ฌ Community: Join our growing community of Dart backend developers
Getting Help #
- Check the README - Most common questions are answered here
- Browse existing issues - Your question might already be answered
- Create a new issue - For bugs, include code examples and error messages
- Start a discussion - For feature requests and general questions
Built with โค๏ธ for the Dart community by Khedr Mahmoud
"Empowering developers to build powerful backend applications with the elegance and performance of Dart"