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
0
points
19
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

Topics

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

Documentation

Documentation

License

unknown (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