@gustavovalle23/churros
v0.0.1
Published
A Clean Architecture & DDD Framework using Fastify + TypeScript
Maintainers
Readme
Features of the DDD + Clean Architecture Framework
This Fastify + TypeScript framework will be designed to abstract layers and focus on domain logic, inspired by Herbs.js but with better CQRS, event-driven support, and DI.
1. Core Architectural Features
- 🏛 Layered Architecture (Domain, Application, Interface, Infrastructure)
- ✅ Strictly Enforces DDD Principles
- 🏗 Scaffolded Project Structure
- ⚡ Fastify Integration for High-Performance APIs
- 🛠 Pluggable ORM (Prisma, TypeORM, MikroORM, etc.)
- 🧩 Flexible Dependency Injection System
- ⚙️ Automatic Repository & Use Case Registration
- 📦 Supports Microservices & Monoliths
2. Domain-Centric Features
- 📌 Entity & Value Object Abstraction
- 🔗 Aggregate Root Pattern
- 🗂 Repository Pattern (Persistence Abstraction)
- ⚡ Domain-Driven Services
- 🔄 Automatic Business Rule Validation
- 🔥 Event-Driven Architecture (Domain Events)
- 🛑 Invariants & Business Rule Enforcement
- 🛡 Unit of Work Pattern for Transactional Consistency
- ⏳ Lazy-Loaded and Cached Aggregates
- ⚠️ Domain Exception Handling
3. Application Layer Features (Use Cases & CQRS)
- 🎯 Use Case Abstraction (Command & Query Pattern)
- 🏹 Command Bus & Query Bus
- 💡 CQRS Support (Separate Read & Write Models)
- 🏗 Use Case Middleware (Logging, Caching, etc.)
- 🔌 Plug-and-Play Dependency Injection
- 🏷 DTO (Data Transfer Object) Validation
- ⚡ Event Sourcing Ready
- 🏭 Factory Methods for Use Cases
- ✅ Middleware Hooks for Pre/Post Execution Logic
4. API & Interface Layer Features
- 🚀 Automatic Route Mapping for Use Cases
- 📌 Decorator-Based Controller Definitions
- 🏗 GraphQL & REST API Support
- 🌍 Multi-Protocol Support (WebSockets, gRPC, etc.)
- 🔧 Automatic Request Validation
- 📑 Auto-Generated Swagger / OpenAPI Docs
- ⚙️ Error Handling Middleware
- 🔄 API Versioning Support
- 🧩 Flexible Authentication & Authorization (JWT, OAuth, RBAC)
- 🎭 Multi-Tenant API Support
- 📝 Logging & Monitoring Middleware
- ⚡ Hot Reload for Fast Development
5. Infrastructure & ORM Features
- 🗄 Repository Implementations for Multiple ORMs
- 🔄 Unit of Work for Transaction Handling
- 🔌 Database Adapter for Prisma, TypeORM, Sequelize, etc.
- 📦 Automatic Dependency Injection for Repositories
- 🌿 Soft Deletes & Auditing Support
- 🚀 Optimized Query Performance (Caching, Indexing)
- 🛠 Background Jobs & Worker Support
- 🗂 Automatic Schema Migration & Seeding
6. Event-Driven & Messaging Features
- 📡 Domain Events Out-of-the-Box
- 🔥 Event Bus for In-App Event Dispatching
- 🔄 Synchronous & Asynchronous Event Handlers
- 🕵️ Saga Pattern for Long-Running Workflows
- 📊 Message Queue Integrations (Kafka, RabbitMQ, NATS, Redis)
- ⚡ Outbox Pattern Support
- 🛠 Event Store for Persisting Domain Events
- 🔗 Webhook Support for External Events
- 💾 Snapshot & Replay Mechanism for Event Sourcing
- 📣 Pub/Sub Pattern Support
7. Dependency Injection & Config Management
- 🏗 Built-in Dependency Injection System
- 🔄 Automatic Dependency Resolution
- ⚙️ Customizable Dependency Scopes
- 🔌 Supports Third-Party IoC Containers (tsyringe, InversifyJS)
- 🔥 Environment-Based Configurations
- 🏗 Hierarchical Configuration Loading
- 📊 Centralized Logging & Monitoring
- 🛑 Graceful Shutdown & Cleanup Handlers
- 🚀 Performance Optimizations via Lazy-Loading
8. DevTools & CLI Features
- 🔥 CLI for Bootstrapping New Projects
- 📜 Code Generators (Entities, Repositories, Use Cases, Controllers)
- 🛠 Auto-Scaffold Folder Structures
- 🔄 Live Reload for Development
- 🔧 Automated Unit & Integration Test Scaffolding
- 🔍 Tracing & Profiling Tools
- 🔬 Performance Benchmarking Utilities
- 📊 Real-Time Metrics Dashboard
- 📦 Plugin System for Extensibility
- ⚡ Hot Module Replacement (HMR)
9. Security & Best Practices
- 🔑 Automatic API Key & JWT Handling
- 🔒 Role-Based & Attribute-Based Access Control (RBAC/ABAC)
- 🚀 Secure Headers & Middleware Protection
- 🛡 Request Rate Limiting & DDoS Protection
- 🏗 CSRF & CORS Support
- 🛠 Input Validation & Data Sanitization
- 📜 Audit Logging for Security Events
- 🔎 Secrets & Config Management
- 🔥 Automatic Data Encryption & Hashing
10. Testing & Quality Assurance
- 🏗 Built-in Test Suite (Unit, Integration, E2E)
- 🛠 Mocking & Dependency Injection for Tests
- 🔄 Automatic Test Fixtures & Seed Data
- ⚡ Fuzz Testing & Load Testing Support
- 📊 Code Coverage & Linting
- 🎯 BDD & TDD Ready
- 🚀 Mutation Testing
- 📝 Snapshot Testing for APIs
- 🔌 Pluggable Test Runners (Jest, Mocha, Vitest)
Summary: Why This Framework?
✅ Strict DDD and Clean Architecture
✅ Zero Boilerplate, High Productivity
✅ Automatic API & Repository Wiring
✅ Event-Driven, Microservice-Ready
✅ Flexible ORM & DI Support
✅ CLI & Code Generators for Speed
✅ Security & Performance Optimized
🗂️ Project Breakdown & Timeline Overview
🔹 Phase 1: Planning & Architecture Design (Weeks 1-3)
- Define the core architecture (Domain, Application, Infrastructure, Interface layers).
- Decide on key design patterns (CQRS, Event Bus, Dependency Injection).
- Select dependencies & libraries (Fastify, Prisma, tsyringe, Kafka, etc.).
- Draft an initial project specification & RFC.
🔹 Phase 2: Core Framework Development (Weeks 4-12)
- Implement Domain Model Abstractions (Entities, Aggregates, Repositories).
- Build Use Case Management & Command Bus.
- Implement Fastify API Layer with automatic routing.
- Create Infrastructure Layer (ORM & Event Bus).
- Develop CLI Tooling for scaffolding projects.
🔹 Phase 3: Advanced Features & Enhancements (Weeks 13-22)
- Add CQRS Read/Write Separation.
- Implement Event Sourcing & Outbox Pattern.
- Integrate GraphQL & WebSockets.
- Add Security Enhancements (RBAC, JWT, OAuth).
- Implement Testing & Quality Assurance.
🔹 Phase 4: Optimization, Documentation & Release (Weeks 23-28)
- Performance Tuning & Benchmarking.
- Comprehensive Documentation & Examples.
- Beta Testing & Developer Feedback.
- First Public Release (v1.0.0).
📅 Gantt-Style Development Timeline
🟢 Phase 1: Planning & Architecture (Weeks 1-3)
| Task | Start | Duration | Status | |------|------|---------|--------| | Define architecture & design patterns | Week 1 | 1 week | 🔄 In Progress | | Select core dependencies | Week 1 | 1 week | ✅ Completed | | Draft RFC & Project Specification | Week 2 | 1 week | 🔄 In Progress | | Create initial GitHub repository & project setup | Week 3 | 1 week | ⏳ Pending |
🟡 Phase 2: Core Framework Development (Weeks 4-12)
| Task | Start | Duration | Status | |------|------|---------|--------| | Implement Entity & Value Object Abstractions | Week 4 | 2 weeks | ⏳ Pending | | Implement Repository Pattern | Week 6 | 2 weeks | ⏳ Pending | | Develop Aggregate Root & Unit of Work | Week 8 | 2 weeks | ⏳ Pending | | Implement Use Case & Command Bus | Week 10 | 2 weeks | ⏳ Pending | | Build Fastify API Layer with Auto-Routing | Week 11 | 1 week | ⏳ Pending | | Implement Infrastructure Layer (ORM Adapter, Kafka, etc.) | Week 12 | 1 week | ⏳ Pending | | Develop CLI for Code Generation | Week 12 | 1 week | ⏳ Pending |
🟠 Phase 3: Advanced Features (Weeks 13-22)
| Task | Start | Duration | Status | |------|------|---------|--------| | Add CQRS Read/Write Separation | Week 13 | 3 weeks | ⏳ Pending | | Implement Event Bus & Domain Events | Week 16 | 2 weeks | ⏳ Pending | | Implement Event Sourcing & Outbox Pattern | Week 18 | 2 weeks | ⏳ Pending | | Integrate GraphQL & WebSockets | Week 20 | 2 weeks | ⏳ Pending | | Add Security Features (JWT, OAuth, RBAC) | Week 22 | 2 weeks | ⏳ Pending |
🔵 Phase 4: Optimization & Release (Weeks 23-28)
| Task | Start | Duration | Status | |------|------|---------|--------| | Performance Optimization & Benchmarking | Week 23 | 2 weeks | ⏳ Pending | | Write Full Documentation & API Reference | Week 24 | 2 weeks | ⏳ Pending | | Conduct Beta Testing & Gather Feedback | Week 26 | 1 week | ⏳ Pending | | First Public Release (v1.0.0) 🚀 | Week 28 | 🚀 | ⏳ Pending |
🛠️ Detailed Task Breakdown
🔹 Domain Layer Development (Weeks 4-8)
- Implement base classes for Entities, Value Objects, Aggregates.
- Implement Repository Interface (Generic & Concrete).
- Implement Domain Services & Business Rules.
- Implement Unit of Work & Transaction Management.
🔹 Application Layer Development (Weeks 8-12)
- Implement Use Case Abstraction (Command & Query).
- Implement Command Bus & Query Bus.
- Implement Automatic Dependency Injection (tsyringe/InversifyJS).
🔹 Infrastructure & API Development (Weeks 12-18)
- Implement ORM Adapter Layer (Prisma, TypeORM, MikroORM).
- Implement Fastify API Layer (Decorator-based Controllers).
- Implement Event Bus & Pub/Sub Integration.
- Implement Outbox Pattern for Event Persistence.
🔹 DevTools & CLI (Weeks 12-16)
- Create CLI Tool for Code Scaffolding.
- Implement Auto-Generate Command for Entities, Repositories, Use Cases.
- Implement Automatic Fastify Route Registration.
🔹 Security & Middleware (Weeks 18-22)
- Implement RBAC & OAuth Authorization.
- Implement JWT Authentication Middleware.
- Implement Request Validation & Data Sanitization.
🔹 Optimization & Testing (Weeks 23-28)
- Write Unit & Integration Tests.
- Implement Mutation Testing & Fuzz Testing.
- Run Load & Performance Benchmarks.
- Conduct Beta Testing with Developers.
📊 Key Milestones
| Milestone | Estimated Completion | Status | |-----------|---------------------|--------| | Core Domain Layer Ready | Week 8 | ⏳ Pending | | Fastify API Layer Functional | Week 12 | ⏳ Pending | | CQRS & Event Sourcing Implemented | Week 20 | ⏳ Pending | | Security & Performance Optimized | Week 24 | ⏳ Pending | | Beta Release (v0.9.0) | Week 26 | ⏳ Pending | | Public Release (v1.0.0) | Week 28 | 🚀 Pending |
🛠️ Tools & Technologies Used
| Category | Tools | |----------|-------| | Language | TypeScript | | Framework | Fastify | | ORMs | Prisma, TypeORM, MikroORM | | Dependency Injection | tsyringe, InversifyJS | | Message Brokers | Kafka, RabbitMQ, NATS | | Authentication | JWT, OAuth, RBAC | | Testing | Jest, Vitest, Supertest | | DevOps | Docker, Kubernetes, Terraform | | CI/CD | GitHub Actions, CircleCI |
