kronix 0.2.0 copy "kronix: ^0.2.0" to clipboard
kronix: ^0.2.0 copied to clipboard

A high-performance, architecturally hardened web framework for Dart.

Kronix Logo

๐Ÿ Kronix #

The Architecturally Hardened Web Framework for Dart. #

pub package License: MIT Build Status

Kronix is a high-performance, batteries-included web framework for the Dart ecosystem. It is designed for developers who demand speed, type-safety, and architectural integrity without the boilerplate of traditional enterprise frameworks.


๐Ÿš€ Key Features #

  • โšก Radix-Trie Router: O(log n) path matching with pre-compiled middleware chains.
  • ๐Ÿ—๏ธ Sophisticated DI: Hierarchical Dependency Injection with automatic request scoping.
  • ๐Ÿ“ฆ Advanced ORM: Active Record pattern with typed relationships (belongsTo, hasMany).
  • ๐Ÿ›ก๏ธ HARDENED Security: Built-in backpressure control, body size limits, and JWT/Session support.
  • ๐Ÿš„ Unified Caching: Elegant Cache facade supporting Memory and Redis drivers.
  • โš™๏ธ CLI Power: Rapid scaffolding of controllers, models (with migrations), and services.
  • ๐Ÿšฅ Real-time: First-class WebSocket support with Hubs, Rooms, and Middleware protection.

๐Ÿ Quick Start #

1. Installation #

Add Kronix to your pubspec.yaml:

dependencies:
  kronix: ^0.2.0

2. A Simple Server #

import 'package:kronix/kronix.dart';

void main() async {
  final app = App();

  // Basic Route
  app.get('/welcome', (ctx) async {
    return Response.json({'message': 'Welcome to Kronix!'});
  });

  // Typed Validation
  app.post('/register', (ctx) async {
    final data = await ctx.validate({
      'email': 'required|email',
      'password': 'required|min:8',
    });
    
    return Response.json({'status': 'registered', 'user': data['email']});
  });

  await app.listen(port: 3000);
}

๐Ÿ› ๏ธ Deep Dive #

๐Ÿ“ฆ The ORM (Model) #

Define your relationships easily:

class User extends Model {
  @override String get tableName => 'users';
  
  // Relationship: User has many Posts
  Future<List<Post>> posts() => hasMany<Post>(Post.fromRow);
}

๐Ÿš„ Caching #

Switch from Memory to Redis with one line in .env:

// Fetch from cache or compute and store for 1 hour
final stats = await Cache.remember('users.count', Duration(hours: 1), () async {
  return await User.query().count();
});

๐Ÿšฅ Middleware #

Compose logic across routes globally or in groups:

app.group('/api/v1', middleware: [AuthMiddleware()], callback: (router) {
  router.get('/profile', ProfileController().show);
});

๐Ÿ’Ž Why Kronix? #

In a world of micro-frameworks, Kronix provides the structure needed for long-term maintainability. It is not just a router; it's a foundation that handles the "boring" parts of web developmentโ€”security, concurrency, and data integrityโ€”so you can focus on building your product.

  • Drained Gracefully: Handles SIGINT/SIGTERM to allow active requests to finish.
  • Isolated Tests: Built-in MockHttpRequest and container-swapping for 100% test coverage.
  • Type Casting: Automatic conversion of query/body parameters to int, double, or bool.

๐Ÿค Contributing #

We welcome contributions! Please see our Contributing Guide to get started.

๐Ÿ“„ License #

Kronix is open-sourced software licensed under the MIT license.

2
likes
130
points
45
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A high-performance, architecturally hardened web framework for Dart.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

args, crypto, dart_jsonwebtoken, dotenv, http, mime, path, postgres, redis, test, watcher

More

Packages that depend on kronix