π§ Neuroglia Python FrameworkΒΆ
Keywords: Python microservices, FastAPI framework, clean architecture Python, CQRS Python, domain-driven design Python, event-driven architecture, dependency injection Python, microservices patterns
A lightweight, opinionated Python framework built on FastAPI that enforces clean architecture principles and provides comprehensive tooling for building production-ready microservices.
π― Perfect ForΒΆ
- Microservices: Clean architecture for scalable service development
- Event-Driven Systems: Built-in CloudEvents and domain event support
- API Development: FastAPI-based with automatic OpenAPI documentation
- Domain-Driven Design: Enforce DDD patterns and bounded contexts
- Clean Code: Opinionated structure that promotes maintainable code
π What's IncludedΒΆ
ποΈ Framework CoreΒΆ
Clean architecture patterns with dependency injection, CQRS, event-driven design, and comprehensive testing utilities.
οΏ½ Production-Ready Sample ApplicationsΒΆ
Learn by example with complete, runnable applications:
-
π¦ OpenBank - Event Sourcing & CQRS banking system demonstrating:
-
Complete event sourcing with KurrentDB (EventStoreDB)
- CQRS with separate write and read models
- Domain-driven design with rich aggregates
- Read model reconciliation and eventual consistency
- Snapshot strategy for performance
-
Perfect for financial systems and audit-critical applications
-
π¨ Simple UI - SubApp pattern with JWT authentication showing:
-
FastAPI SubApp mounting for UI/API separation
- Stateless JWT authentication architecture
- Role-based access control (RBAC) at application layer
- Bootstrap 5 frontend with Parcel bundler
-
Perfect for internal dashboards and admin tools
-
π Mario's Pizzeria - Complete e-commerce platform featuring:
- Order management and kitchen workflows
- Real-time event-driven processes
- Keycloak authentication integration
- MongoDB persistence with domain events
- Perfect for learning all framework patterns
οΏ½π Real-World SamplesΒΆ
Complete production examples like Mario's Pizzeria demonstrating every framework feature in realistic business scenarios.
π Comprehensive DocumentationΒΆ
- 9-Part Tutorial Series - Step-by-step hands-on learning
- Core Concepts Guide - Architectural pattern explanations
- Pattern Documentation - Includes "Common Mistakes" and "When NOT to Use"
- Complete Case Study - From business analysis to production deployment
βοΈ CLI ToolingΒΆ
PyNeuroctl command-line interface for managing, testing, and deploying your applications with zero configuration.
Why Neuroglia?ΒΆ
Choose Neuroglia for complex, domain-driven microservices that need to be maintained for years to come.
π― The PhilosophyΒΆ
Neuroglia believes that software architecture matters more than speed of initial development. While you can build APIs quickly with vanilla FastAPI or Django, Neuroglia is designed for applications that will:
- Scale in complexity over time with changing business requirements
- Be maintained by teams with varying levels of domain expertise
- Evolve and adapt without accumulating technical debt
- Integrate seamlessly with complex enterprise ecosystems
ποΈ When to Choose NeurogliaΒΆ
| Choose Neuroglia When | Choose Alternatives When |
|---|---|
| β Building domain-rich applications with complex business logic | β Creating simple CRUD APIs or prototypes |
| β Long-term maintenance is a primary concern | β You need something working "yesterday" |
| β Your team values architectural consistency | β Framework learning curve is a blocker |
| β You need enterprise patterns (CQRS, DDD, Event Sourcing) | β Simple request-response patterns suffice |
| β Multiple developers will work on the codebase | β Solo development or small, simple projects |
| β Integration with event-driven architectures | β Monolithic, database-first applications |
π The Neuroglia AdvantageΒΆ
Compared to vanilla FastAPI:
- Enforced Structure: No more "how should I organize this?" - clear architectural layers
- Built-in Patterns: CQRS, dependency injection, and event handling out of the box
- Enterprise Ready: Designed for complex domains, not just API endpoints
Compared to Django:
- Microservice Native: Built for distributed systems, not monolithic web apps
- Domain-Driven: Business logic lives in the domain layer, not mixed with web concerns
- Modern Async: Full async support without retrofitting legacy patterns
Compared to Spring Boot (Java):
- Python Simplicity: All the enterprise patterns without Java's verbosity
- Lightweight: No heavy application server - just the patterns you need
- Developer Experience: Pythonic APIs with comprehensive tooling
π‘ Real-World ScenariosΒΆ
Perfect for:
- π¦ Financial Services: Complex domain rules, audit trails, event sourcing
- π₯ Healthcare Systems: HIPAA compliance, complex workflows, integration needs
- π Manufacturing: Resource management, real-time monitoring, process orchestration
- π E-commerce Platforms: Order processing, inventory management, payment flows
- π― SaaS Products: Multi-tenant architectures, feature flags, usage analytics
Not ideal for:
- π Simple content management systems
- π Basic API proxies or data transformation services
- π± Mobile app backends with minimal business logic
- π§ͺ Proof-of-concept or throwaway prototypes
π¨ The Developer ExperienceΒΆ
Neuroglia optimizes for code that tells a story:
# Your business logic is clear and testable
class PlaceOrderHandler(CommandHandler[PlaceOrderCommand, OperationResult[OrderDto]]):
async def handle_async(self, command: PlaceOrderCommand) -> OperationResult[OrderDto]:
# Domain logic is explicit and isolated
order = Order(command.customer_id, command.items)
await self.repository.save_async(order)
return self.created(self.mapper.map(order, OrderDto))
# Infrastructure concerns are separated
class OrdersController(ControllerBase):
@post("/orders", response_model=OrderDto)
async def place_order(self, command: PlaceOrderCommand) -> OrderDto:
return await self.mediator.execute_async(command)
The result? Code that's easy to understand, test, and evolve - even years later.
π Key FeaturesΒΆ
- ποΈ Clean Architecture: Enforces separation of concerns with clearly defined layers (API, Application, Domain, Integration)
- π Dependency Injection: Lightweight container with automatic service discovery and registration
- π― CQRS & Mediation: Command Query Responsibility Segregation with built-in mediator pattern
- ποΈ State-Based Persistence: Alternative to event sourcing with automatic domain event dispatching
- π§ Pipeline Behaviors: Cross-cutting concerns like validation, caching, and transactions
- π‘ Event-Driven Architecture: Native support for CloudEvents, event sourcing, and reactive programming
- π― Resource Oriented Architecture: Declarative resource management with watchers, controllers, and reconciliation loops
- π MVC Controllers: Class-based API controllers with automatic discovery and OpenAPI generation
- ποΈ Repository Pattern: Flexible data access layer with support for MongoDB, Event Store, and in-memory repositories
- π Object Mapping: Bidirectional mapping between domain models and DTOs
- β‘ Reactive Programming: Built-in support for RxPy and asynchronous event handling
- π§ 12-Factor Compliance: Implements all 12-Factor App principles
- π Rich Serialization: JSON serialization with advanced features
π― Architecture OverviewΒΆ
Neuroglia promotes a clean, layered architecture that separates concerns and makes your code more maintainable:
src/
βββ api/ # π API Layer (Controllers, DTOs, Routes)
βββ application/ # πΌ Application Layer (Commands, Queries, Handlers, Services)
βββ domain/ # ποΈ Domain Layer (Entities, Value Objects, Business Rules)
βββ integration/ # π Integration Layer (External APIs, Repositories, Infrastructure)
π Quick StartΒΆ
Coming soon: Get started with Neuroglia in minutes:
# Install the framework
pip install neuroglia-python
# Create your first app
pyneuroctl new myapp --template minimal
cd myapp
# Run the application
python main.py
Visit http://localhost:8000/docs to explore the auto-generated API documentation.
π Learn MoreΒΆ
π Learning PathsΒΆ
New to the Framework?
- Start with Getting Started - Build your first app in 30 minutes
- Follow the 9-Part Tutorial Series - Comprehensive hands-on guide
- Study Core Concepts - Understand the architectural patterns
Ready to Build?
- Explore Mario's Pizzeria Case Study - Complete real-world example
- Review Architectural Patterns - Design patterns with anti-patterns to avoid
- Browse Framework Features - Detailed feature documentation
Need Help?
- Check Guides & How-Tos - Practical procedures and troubleshooting
- See Sample Applications - More complete working examples
- Consult Reference Documentation - Technical specifications
π Quick LinksΒΆ
- Tutorials - Step-by-step learning with the 9-part Mario's Pizzeria tutorial
- Sample Applications - Complete working examples:
- π¦ OpenBank - Event sourcing & CQRS banking system
- π¨ Simple UI - SubApp pattern with JWT auth & RBAC
- API Gateway - Microservice orchestration
- Core Concepts - Understand Clean Architecture, DDD, CQRS, and more
- Mario's Pizzeria - Complete case study with business analysis and implementation
- Patterns - Architectural patterns with "What & Why" and "Common Mistakes"
- Features - Framework capabilities and how to use them
- Guides - Practical how-to procedures
- RBAC & Authorization - Role-based access control patterns
- Simple UI Development - Step-by-step UI integration guide
π Reference DocumentationΒΆ
- OAuth, OIDC & JWT - Authentication and authorization patterns
- 12-Factor App Compliance - Cloud-native application standards
- Source Code Naming Conventions - Maintainable code patterns
- Python Typing Guide - Type hints, generics, and advanced typing
Neuroglia Python Framework - Building better software through better architecture π§ β¨