Pet-project focused on orchestrating workflows via python. Potential use cases: scenario automatization (for SOAR, SGRC systems, CRON-like routines).
flow-core/
├── src/
│ ├── domain/ # Core: business logic, bl entities, interfaces (ports)
│ │ ├── interfaces/
│ │ │ ├── action.py # Action (ABC)
│ │ │ ├── rule.py # Rule (ABC)
│ │ │ └── ...
│ │ ├── entities/ # Business objects with identity, not database models
│ │ │ └── workflow_event.py # WorkflowEvent (dataclass / Pydantic)
│ │ └── engine.py # WorkflowEngine (relies on interfaces)
│ │
│ ├── application/ # Use cases
│ │ ├── workflows/
│ │ │ └── process_event.py # ProcessEventUseCase
│ │ └── interfaces/ # Use Case interfaces
│ │
│ ├── presentation/ # Data serialization for outer world
│ │ ├── cli/ # For CLI
│ │ │ ├── commands/
│ │ │ │ └── run_workflow.py # CLI command (call use case via presenter)
│ │ │ └── presenters/
│ │ │ └── workflow_presenter.py # Format output for CLI
│ │ ├── web/ # Web-interface
│ │ │ ├── controllers/
│ │ │ │ └── workflow_controller.py
│ │ │ ├── serializers/
│ │ │ │ └── workflow_serializer.py # Request/Response models
│ │ │ └── presenters/
│ │ │ └── workflow_presenter.py # Format output for HTTP
│ │ └── dto/ # Data Transfer Objects (common for all presentation layers)
│ │ ├── requests/
│ │ │ └── process_event_request.py
│ │ └── responses/
│ │ └── process_event_response.py
│ │
│ ├── infrastructure/ # Interface implementations (outer systems)
│ │ ├── http/
│ │ │ ├── base.py # BaseHTTPClient (utility)
│ │ │ └── ...
│ │ ├── storage/ # DB repositories
│ │ ├── messaging/ # Message brokers
│ │ └── config/ # Config (read envs, etc)
│ │
│ ├── common/ # Common utils, do NOT depend on other layers
│ │ └── ...
│ │
│ └── main.py # Composition (compose all dependencies)
└──── tests/
| Layer | Responsibility | Depends on |
|---|---|---|
Domain |
|
Nothing external (only pydantic models are allowed) |
Application |
|
Domain |
Presentation |
|
Application, DTOs |
Infrastructure |
|
Domain, Application (sometimes) |
Composition (main.py) |
|
All layers as it's an entry point of the project |
[Outer world]
|
[CLI command / Web route] --> [Request DTO] --> [Presentation.presenter]
|
[Application] --> [Use case]
|
[Domain] --> [Engine] --> [Interfaces] --> [Infrastructure (interface implementations)]
|
[Result] --> [Presentation.presenter] --> [Response DTO] --> [CLI / web interface]
|
[Outer world]
- Complete layer isolation:
infrastructurechanges (such as HTTP-library swap, etc) should NOT impactdomainandapplicationlayers - Ease of testing: use cases should be testable via mock-implementations of interfaces
- Adaptability: new interfaces should be added with ease - just add a new presenter & a controller, no need to change core implementation
- Clean code and clear separation of concerns