ordering 1.0.0
ordering: ^1.0.0 copied to clipboard
Core ordering domain logic (clean architecture).
Ordering
A clean-architecture based ordering domain package for Dart. This package contains pure business logic for handling orders, independent of UI, frameworks, or infrastructure.
It is designed to be:
Framework-agnostic
Highly testable
Easy to integrate into any backend or Flutter app
Stable and reusable across projects
โจ Features
Pure domain models (Order, OrderItem, Money, TimeSlot, etc.)
Clear order lifecycle (created โ confirmed โ completed / cancelled)
Port-based design for external dependencies (Inventory, Pricing, Loyalty)
Strong validation and rule enforcement
60+ unit tests covering domain & service behavior
No runtime dependencies
๐ง Architecture Philosophy
This package follows Clean Architecture / Hexagonal Architecture principles.
Separation of concerns:
Domain โ Business rules & entities
Ports โ External contracts (interfaces)
Services โ Use-case orchestration
No framework, database, or API logic is included here by design.
๐ Project Structure lib/ โโโ domain/ โ โโโ order.dart โ โโโ order_item.dart โ โโโ order_status.dart โ โโโ money.dart โ โโโ subscription.dart โ โโโ time_slot.dart โ โโโ ports/ โ โโโ inventory_port.dart โ โโโ pricing_port.dart โ โโโ loyalty_port.dart โ โโโ services/ โ โโโ order_service.dart โ โโโ order_repo.dart โ โโโ order_req.dart โ โโโ ordering.dart // Public entry point
Consumers should import only:
import 'package:ordering/ordering.dart';
๐ Installation
Add the dependency:
dependencies: ordering: ^1.0.0
Then run:
dart pub get
๐งฉ Usage Example Implement required ports class InventoryAdapter implements InventoryPort { @override bool isAvailable(Order order) { return true; } }
class PricingAdapter implements PricingPort { @override Money calculatePrice(Order order) { return Money(500); } }
class LoyaltyAdapter implements LoyaltyPort { @override void reward(Order order) {} }
Create OrderService final orderService = OrderService( inventoryPort: InventoryAdapter(), pricingPort: PricingAdapter(), loyaltyPort: LoyaltyAdapter(), orderRepository: MyOrderRepository(), );
Use the service orderService.confirm(order); orderService.markDelivered(order);
Business rules are enforced automatically.
๐งช Testing
This package is heavily tested.
Run all tests:
dart test
Tests cover:
Domain invariants
Order lifecycle rules
Failure scenarios
Port interactions
๐ Stability & Versioning
This package follows Semantic Versioning.
PATCH โ Bug fixes
MINOR โ Backward-compatible features
MAJOR โ Breaking changes
Public APIs are intentionally minimal to keep them stable.
โ What This Package Does NOT Do
No database access
No HTTP / API logic
No Flutter UI
No framework coupling
These belong in adapter layers, not in the domain.
๐ License
MIT License ยฉ 2026 Shivam Gupta
๐งญ Intended Audience
This package is ideal for:
Backend systems
Flutter apps with serious business logic
Developers practicing Clean Architecture
Teams that want long-term maintainability