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:
IGNY8 VPS (Salman)
2025-11-16 21:47:51 +00:00
parent cb0e42bb8d
commit 455358ecfc
11 changed files with 281 additions and 281 deletions

View File

@@ -48,13 +48,13 @@
| Task | File | Current State | Implementation |
|------|------|---------------|----------------|
| **Extend ModuleSettings Model** | `domain/system/models.py` | EXISTING (ModuleSettings) | Add `enabled` boolean field per module |
| **Extend ModuleSettings Model** | `business/system/models.py` | EXISTING (ModuleSettings) | Add `enabled` boolean field per module |
| **Module Settings API** | `modules/system/views.py` | EXISTING | Extend ViewSet to handle enable/disable |
| **Module Settings Serializer** | `modules/system/serializers.py` | EXISTING | Add enabled field to serializer |
**ModuleSettings Model Extension**:
```python
# domain/system/models.py (or core/system/models.py if exists)
# business/system/models.py (or core/system/models.py if exists)
class ModuleSettings(AccountBaseModel):
# Existing fields...
@@ -173,11 +173,11 @@ class Plan(models.Model):
| Task | File | Current State | Implementation |
|------|------|---------------|----------------|
| **Add Credit Costs** | `domain/billing/constants.py` | NEW | Define credit costs per operation |
| **Add Credit Costs** | `business/billing/constants.py` | NEW | Define credit costs per operation |
**Credit Cost Constants**:
```python
# domain/billing/constants.py
# business/billing/constants.py
CREDIT_COSTS = {
'clustering': 10, # Per clustering request
'idea_generation': 15, # Per cluster → ideas request
@@ -195,11 +195,11 @@ CREDIT_COSTS = {
| Task | File | Current State | Implementation |
|------|------|---------------|----------------|
| **Update CreditService** | `domain/billing/services/credit_service.py` | EXISTING | Add credit cost constants, update methods |
| **Update CreditService** | `business/billing/services/credit_service.py` | EXISTING | Add credit cost constants, update methods |
**CreditService Methods**:
```python
# domain/billing/services/credit_service.py
# business/billing/services/credit_service.py
class CreditService:
def check_credits(self, account, operation_type, amount=None):
"""Check if account has sufficient credits"""
@@ -256,11 +256,11 @@ class AIEngine:
| Task | File | Current State | Implementation |
|------|------|---------------|----------------|
| **Update Content Generation** | `domain/content/services/content_generation_service.py` | NEW (Phase 1) | Check credits before generation |
| **Update Content Generation** | `business/content/services/content_generation_service.py` | NEW (Phase 1) | Check credits before generation |
**Content Generation Credit Check**:
```python
# domain/content/services/content_generation_service.py
# business/content/services/content_generation_service.py
class ContentGenerationService:
def generate_content(self, task, account):
# Check credits before generation
@@ -331,11 +331,11 @@ credit_service.check_credits(account, 'clustering', keyword_count)
| Task | File | Current State | Implementation |
|------|------|---------------|----------------|
| **Update Usage Logging** | `domain/billing/models.py` | EXISTING | Ensure all operations log credits |
| **Update Usage Logging** | `business/billing/models.py` | EXISTING | Ensure all operations log credits |
**CreditUsageLog Model**:
```python
# domain/billing/models.py
# business/billing/models.py
class CreditUsageLog(AccountBaseModel):
account = models.ForeignKey(Account, on_delete=models.CASCADE)
operation_type = models.CharField(max_length=50)
@@ -399,7 +399,7 @@ class Migration(migrations.Migration):
**Migration 2: Add Credit Cost Tracking**:
```python
# domain/billing/migrations/XXXX_add_credit_tracking.py
# business/billing/migrations/XXXX_add_credit_tracking.py
class Migration(migrations.Migration):
operations = [
migrations.AddField(
@@ -461,7 +461,7 @@ class Migration(migrations.Migration):
### Backend Tasks
- [ ] Create `domain/billing/constants.py` with credit costs
- [ ] Create `business/billing/constants.py` with credit costs
- [ ] Update `CreditService` with credit cost methods
- [ ] Update `Plan` model - remove limit fields
- [ ] Create migration to remove plan limit fields