A CLI tool for generating DDD/CQRS microservices applications
Project description
Nagraj
Nagraj is a powerful CLI tool for generating Domain-Driven Design (DDD) and Command Query Responsibility Segregation (CQRS) based microservices applications in Python. It provides a robust project structure with best practices baked in.
Features
-
๐๏ธ DDD Architecture: Built-in support for DDD patterns including:
- Aggregates, Entities, Value Objects
- Domain Events and Event Handlers
- Repositories and Specifications
- Domain Services and Facades
-
๐ CQRS Pattern: Clear separation of commands and queries with:
- Command handlers and validators
- Query handlers and DTOs
- Event sourcing support
-
๐ Authentication & Authorization: Pre-configured auth bounded context with:
- JWT-based authentication
- Role-based authorization
- Password hashing with Argon2
- User management APIs
-
๐ ๏ธ Modern Tech Stack:
- FastAPI for high-performance APIs
- SQLModel for type-safe ORM
- Pydantic for data validation
- Alembic for database migrations
- Poetry for dependency management
-
๐งช Testing & Quality:
- Pytest configuration with async support
- Hurl for API testing
- Coverage reporting
- Ruff for linting and formatting
Installation
pip install nagraj
Quick Start
- Create a new project:
nagraj init --project-name my_cool_app
- Additional options:
nagraj init \
--project-name my_cool_app \
--project-description "My awesome microservice" \
--project-author-name "John Doe" \
--project-author-email "john@example.com" \
--python-version 3.12 \
--version 0.1.0
Project Structure
The generated project follows a clean DDD/CQRS architecture:
my_cool_app/
โโโ my_cool_app/
โ โโโ common/
โ โ โโโ base/ # Base classes for DDD building blocks
โ โ โโโ bounded_contexts/ # Shared bounded contexts (e.g., auth)
โ โ โโโ core/ # Core functionality
โ โ โโโ exceptions/ # Exception hierarchy
โ โโโ example_domain_one/ # Domain-specific code
โ โโโ bounded_contexts/ # Domain bounded contexts
โ โโโ context_maps/ # Context mapping
โ โโโ interface/ # Domain interfaces
โโโ tests/
โ โโโ unit/
โ โโโ integration/
โ โโโ apis/ # API tests using Hurl
โโโ alembic.ini # Database migration config
โโโ pyproject.toml # Project dependencies
โโโ .nagraj.yaml # Project configuration
Configuration
The .nagraj.yaml file in your project root contains the complete configuration:
- Project metadata and versioning
- Base class configurations
- Infrastructure settings
- Common components
- Domain configurations
- Testing setup
- Development tools
Development Workflow
-
Add a New Domain:
- Create domain folder structure
- Define bounded contexts
- Implement domain models
- Add API interfaces
-
Testing:
# Run all tests pytest # Run API tests hurl tests/apis/*.hurl
-
Database Migrations:
# Create a new migration alembic revision --autogenerate -m "description" # Apply migrations alembic upgrade head
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Credits
Created and maintained by Abhishek Pathak (@krabhishek)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nagraj-0.1.1.tar.gz.
File metadata
- Download URL: nagraj-0.1.1.tar.gz
- Upload date:
- Size: 52.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47e451c3d9f3f3791b4f585a20fd31ac73073d0766167aa19a7ae0f7ec1e2a69
|
|
| MD5 |
aee649836c99c8c4d2bc633d4a0c467d
|
|
| BLAKE2b-256 |
2a5e33f81943b81b9d201fd4f549e27dd7c2410bfdf5751f3fefe0d3ae841fc8
|
File details
Details for the file nagraj-0.1.1-py3-none-any.whl.
File metadata
- Download URL: nagraj-0.1.1-py3-none-any.whl
- Upload date:
- Size: 131.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c4d9fb5c2d7161d089ab89733e076223e7a92d2276f561fc2400c67a9fa01d5
|
|
| MD5 |
8970f6f734eddf33b7e22dadbb1dc7d8
|
|
| BLAKE2b-256 |
7d66d8e8bb1941e04a5b34c4b4b9631847ef4dab63ad05be52d888e00cb3af0a
|