Refactor domain structure to business layer
- Renamed `domain/` to `business/` to better reflect the organization of code by business logic. - Updated all relevant file paths and references throughout the project to align with the new structure. - Ensured that all models and services are now located under the `business/` directory, maintaining existing functionality while improving clarity.
This commit is contained in:
@@ -49,11 +49,11 @@
|
||||
|
||||
| Task | File | Dependencies | Implementation |
|
||||
|------|------|--------------|----------------|
|
||||
| **AutomationRule Model** | `domain/automation/models.py` | Phase 1 | Create model with trigger, conditions, actions, schedule |
|
||||
| **AutomationRule Model** | `business/automation/models.py` | Phase 1 | Create model with trigger, conditions, actions, schedule |
|
||||
|
||||
**AutomationRule Model**:
|
||||
```python
|
||||
# domain/automation/models.py
|
||||
# business/automation/models.py
|
||||
class AutomationRule(SiteSectorBaseModel):
|
||||
name = models.CharField(max_length=255)
|
||||
description = models.TextField(blank=True)
|
||||
@@ -101,11 +101,11 @@ class AutomationRule(SiteSectorBaseModel):
|
||||
|
||||
| Task | File | Dependencies | Implementation |
|
||||
|------|------|--------------|----------------|
|
||||
| **ScheduledTask Model** | `domain/automation/models.py` | Phase 1 | Create model to track scheduled executions |
|
||||
| **ScheduledTask Model** | `business/automation/models.py` | Phase 1 | Create model to track scheduled executions |
|
||||
|
||||
**ScheduledTask Model**:
|
||||
```python
|
||||
# domain/automation/models.py
|
||||
# business/automation/models.py
|
||||
class ScheduledTask(SiteSectorBaseModel):
|
||||
automation_rule = models.ForeignKey(AutomationRule, on_delete=models.CASCADE)
|
||||
scheduled_at = models.DateTimeField()
|
||||
@@ -133,7 +133,7 @@ class ScheduledTask(SiteSectorBaseModel):
|
||||
|
||||
| Task | File | Dependencies | Implementation |
|
||||
|------|------|--------------|----------------|
|
||||
| **Automation Migrations** | `domain/automation/migrations/` | Phase 1 | Create initial migrations |
|
||||
| **Automation Migrations** | `business/automation/migrations/` | Phase 1 | Create initial migrations |
|
||||
|
||||
---
|
||||
|
||||
@@ -147,11 +147,11 @@ class ScheduledTask(SiteSectorBaseModel):
|
||||
|
||||
| Task | File | Dependencies | Implementation |
|
||||
|------|------|--------------|----------------|
|
||||
| **AutomationService** | `domain/automation/services/automation_service.py` | Phase 1 services | Main service for rule execution |
|
||||
| **AutomationService** | `business/automation/services/automation_service.py` | Phase 1 services | Main service for rule execution |
|
||||
|
||||
**AutomationService Methods**:
|
||||
```python
|
||||
# domain/automation/services/automation_service.py
|
||||
# business/automation/services/automation_service.py
|
||||
class AutomationService:
|
||||
def __init__(self):
|
||||
self.rule_engine = RuleEngine()
|
||||
@@ -202,11 +202,11 @@ class AutomationService:
|
||||
|
||||
| Task | File | Dependencies | Implementation |
|
||||
|------|------|--------------|----------------|
|
||||
| **Rule Execution Engine** | `domain/automation/services/rule_engine.py` | Phase 1 services | Orchestrates rule execution |
|
||||
| **Rule Execution Engine** | `business/automation/services/rule_engine.py` | Phase 1 services | Orchestrates rule execution |
|
||||
|
||||
**RuleEngine Methods**:
|
||||
```python
|
||||
# domain/automation/services/rule_engine.py
|
||||
# business/automation/services/rule_engine.py
|
||||
class RuleEngine:
|
||||
def execute_rule(self, rule, context):
|
||||
"""Orchestrate rule execution"""
|
||||
@@ -221,11 +221,11 @@ class RuleEngine:
|
||||
|
||||
| Task | File | Dependencies | Implementation |
|
||||
|------|------|--------------|----------------|
|
||||
| **Condition Evaluator** | `domain/automation/services/condition_evaluator.py` | None | Evaluates rule conditions |
|
||||
| **Condition Evaluator** | `business/automation/services/condition_evaluator.py` | None | Evaluates rule conditions |
|
||||
|
||||
**ConditionEvaluator Methods**:
|
||||
```python
|
||||
# domain/automation/services/condition_evaluator.py
|
||||
# business/automation/services/condition_evaluator.py
|
||||
class ConditionEvaluator:
|
||||
def evaluate(self, conditions, context):
|
||||
"""Evaluate rule conditions"""
|
||||
@@ -238,11 +238,11 @@ class ConditionEvaluator:
|
||||
|
||||
| Task | File | Dependencies | Implementation |
|
||||
|------|------|--------------|----------------|
|
||||
| **Action Executor** | `domain/automation/services/action_executor.py` | Phase 1 services | Executes rule actions |
|
||||
| **Action Executor** | `business/automation/services/action_executor.py` | Phase 1 services | Executes rule actions |
|
||||
|
||||
**ActionExecutor Methods**:
|
||||
```python
|
||||
# domain/automation/services/action_executor.py
|
||||
# business/automation/services/action_executor.py
|
||||
class ActionExecutor:
|
||||
def __init__(self):
|
||||
self.clustering_service = ClusteringService()
|
||||
@@ -290,7 +290,7 @@ from celery.schedules import crontab
|
||||
@shared_task
|
||||
def execute_scheduled_automation_rules():
|
||||
"""Execute all scheduled automation rules"""
|
||||
from domain.automation.services.automation_service import AutomationService
|
||||
from business.automation.services.automation_service import AutomationService
|
||||
|
||||
service = AutomationService()
|
||||
rules = AutomationRule.objects.filter(
|
||||
@@ -316,7 +316,7 @@ def execute_scheduled_automation_rules():
|
||||
@shared_task
|
||||
def replenish_monthly_credits():
|
||||
"""Replenish monthly credits for all active accounts"""
|
||||
from domain.billing.services.credit_service import CreditService
|
||||
from business.billing.services.credit_service import CreditService
|
||||
|
||||
service = CreditService()
|
||||
accounts = Account.objects.filter(status='active')
|
||||
@@ -528,14 +528,14 @@ export const automationApi = {
|
||||
|
||||
### Backend Tasks
|
||||
|
||||
- [ ] Create `domain/automation/models.py`
|
||||
- [ ] Create `business/automation/models.py`
|
||||
- [ ] Create AutomationRule model
|
||||
- [ ] Create ScheduledTask model
|
||||
- [ ] Create automation migrations
|
||||
- [ ] Create `domain/automation/services/automation_service.py`
|
||||
- [ ] Create `domain/automation/services/rule_engine.py`
|
||||
- [ ] Create `domain/automation/services/condition_evaluator.py`
|
||||
- [ ] Create `domain/automation/services/action_executor.py`
|
||||
- [ ] Create `business/automation/services/automation_service.py`
|
||||
- [ ] Create `business/automation/services/rule_engine.py`
|
||||
- [ ] Create `business/automation/services/condition_evaluator.py`
|
||||
- [ ] Create `business/automation/services/action_executor.py`
|
||||
- [ ] Create `infrastructure/messaging/automation_tasks.py`
|
||||
- [ ] Add scheduled automation task
|
||||
- [ ] Add monthly credit replenishment task
|
||||
|
||||
Reference in New Issue
Block a user