khadem 1.0.4-beta copy "khadem: ^1.0.4-beta" to clipboard
khadem: ^1.0.4-beta copied to clipboard

A modern Dart backend framework with CLI tools, ORM, authentication, and caching for scalable web applications.

Khadem Framework
Status Version Dart License

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:

dart pub global activate khadem

Requirements #

  • Dart SDK: >=3.0.0
  • Supported Platforms: Windows, macOS, Linux
  • Database: MySQL (optional)
  • Cache: Redis (optional)

⚑ Quick Start #

Get started with Khadem in minutes:

1. Create New Project Structure #

# Create new project from GitHub template
khadem new --name=my_app
cd my_app
dart pub get

2. Start Development Server #

# Run your Khadem application
dart run lib/main.dart

# Or for development with 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 modern structure:

my_app/
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ main.dart              # Application entry point
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ http/
β”‚   β”‚   β”‚   β”œβ”€β”€ controllers/   # HTTP controllers
β”‚   β”‚   β”‚   └── middleware/    # HTTP middleware
β”‚   β”‚   β”œβ”€β”€ jobs/             # Background job classes
β”‚   β”‚   β”œβ”€β”€ listeners/        # Event listeners
β”‚   β”‚   β”œβ”€β”€ models/           # Data models
β”‚   β”‚   └── providers/        # Service providers
β”‚   β”œβ”€β”€ bin/                  # CLI commands and utilities
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── app.dart         # Application configuration
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   └── kernel.dart      # Application kernel
β”‚   β”œβ”€β”€ database/
β”‚   β”‚   β”œβ”€β”€ migrations/      # Database migrations
β”‚   β”‚   └── seeders/         # Database seeders
β”‚   └── routes/
β”‚       β”œβ”€β”€ web.dart         # Web routes
β”‚       └── socket.dart      # Socket routes
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ development/         # Development environment configs
β”‚   β”‚   └── logging.json
β”‚   └── production/          # Production environment configs
β”‚       └── logging.json
β”œβ”€β”€ lang/
β”‚   β”œβ”€β”€ ar/                  # Arabic translations
β”‚   β”‚   β”œβ”€β”€ ar.json
β”‚   β”‚   β”œβ”€β”€ fields.json
β”‚   β”‚   └── validation.json
β”‚   └── en/                  # English translations
β”‚       β”œβ”€β”€ en.json
β”‚       β”œβ”€β”€ fields.json
β”‚       └── validation.json
β”œβ”€β”€ public/
β”‚   └── assets/              # Public assets
β”‚       └── logo.png
β”œβ”€β”€ resources/
β”‚   └── views/               # View templates
β”‚       └── welcome.khdm.html
β”œβ”€β”€ storage/
β”‚   └── logs/                # Application logs
β”‚       └── app.log
β”œβ”€β”€ tests/                   # Test files
β”œβ”€β”€ .env                     # Environment variables
β”œβ”€β”€ .gitignore              # Git ignore rules
β”œβ”€β”€ pubspec.yaml            # Package configuration
└── pubspec.lock            # Package lock file

πŸ› οΈ CLI Commands #

Khadem features a powerful CLI with automatic command discovery:

🎯 Available Commands #

Project Management #

# Create new project with modern structure
khadem new --name=project_name

# Start development server with hot reload
khadem serve

# Build Docker containers and production assets
khadem build --services=mysql,redis

Code Generation #

# Create models, controllers, and more in the proper lib/app/ structure
khadem make:model --name=User                    # β†’ lib/app/models/
khadem make:controller --name=UserController     # β†’ lib/app/http/controllers/
khadem make:middleware --name=AuthMiddleware     # β†’ lib/app/http/middleware/
khadem make:provider --name=AuthServiceProvider # β†’ lib/app/providers/
khadem make:job --name=SendEmailJob              # β†’ lib/app/jobs/
khadem make:listener --name=UserEventListener   # β†’ lib/app/listeners/
khadem make:migration --name=users               # β†’ lib/database/migrations/

# Support for nested folders
khadem make:controller --name=api/v1/UserController  # β†’ lib/app/http/controllers/api/v1/
khadem make:job --name=email/SendWelcomeEmailJob     # β†’ lib/app/jobs/email/

Version Information #

khadem --version                  # Show version information

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:

// lib/app/providers/app_service_provider.dart
class AppServiceProvider extends ServiceProvider {
  @override
  void register(container) {
    // Register services in the container
  }

  @override
  Future<void> boot(container) async {
    // Boot services after registration
  }
}

Background Jobs #

Create background jobs for asynchronous processing:

// lib/app/jobs/send_email_job.dart
class SendEmailJob extends QueueJob {
  final String email;
  final String message;

  SendEmailJob(this.email, this.message);

  @override
  Future<void> handle() async {
    // Send email logic here
    print('πŸ“§ Sending email to $email: $message');
  }
}

Dependency Injection #

Use the container for clean dependency management:

// lib/app/http/controllers/user_controller.dart
class UserController {
  final UserRepository repository;

  UserController(this.repository);

  Future<Response> index(Request request) async {
    final users = await repository.all();
    return Response.json(users);
  }
}

Middleware System #

Add cross-cutting concerns with middleware:

// lib/app/http/middleware/auth_middleware.dart
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;
}

Database Migrations #

Manage database schema with migrations:

// lib/database/migrations/123456_create_users_table.dart
class CreateUsersTable extends MigrationFile {
  @override
  Future<void> up(builder) async {
    builder.create('users', (table) {
      table.id();
      table.string('name');
      table.string('email').unique();
      table.string('password');
      table.timestamps();
    });
  }

  @override
  Future<void> down(builder) async {
    builder.dropIfExists('users');
  }
}

🌟 Why Choose Khadem? #

  • ⚑ Performance First: Built with Dart for exceptional speed and efficiency
  • 🎯 Developer Experience: Intuitive API design with excellent tooling and auto-discovery
  • πŸ—οΈ Modern Structure: Follows Dart package conventions with lib/ directory organization
  • πŸ”§ 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 and nested folder support
  • πŸ”₯ Modern: Takes advantage of latest Dart features and best practices
  • πŸ“Š Dynamic Configuration: Version and metadata automatically synchronized
  • 🐳 Production Ready: Docker support with optimized containers for deployment

οΏ½πŸ“ž Support & Community #

  • πŸ› Bug Reports: GitHub Issues
  • πŸ’‘ Feature Requests: GitHub Discussions
  • πŸ’¬ Community: Join our growing community of Dart backend developers

Getting Help #

  1. Check the README - Most common questions are answered here
  2. Browse existing issues - Your question might already be answered
  3. Create a new issue - For bugs, include code examples and error messages
  4. 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"


2
likes
160
points
249
downloads

Publisher

unverified uploader

Weekly Downloads

A modern Dart backend framework with CLI tools, ORM, authentication, and caching for scalable web applications.

Repository (GitHub)
View/report issues
Contributing

Topics

#web-framework #backend #server #api #database

Documentation

Documentation
API reference

License

Apache-2.0 (license)

Dependencies

archive, args, crypto, dart_jsonwebtoken, glob, intl, mime, mysql1, package_config, path, recase, redis, timezone, uuid, vm_service, watcher, yaml, yaml_edit

More

Packages that depend on khadem