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:
@@ -27,7 +27,7 @@
|
||||
|
||||
| Principle | Description | Implementation |
|
||||
|-----------|-------------|----------------|
|
||||
| **Domain-Driven Design** | Organize by business domains, not technical layers | `domain/` folder with content, planning, linking, optimization, publishing domains |
|
||||
| **Domain-Driven Design** | Organize by business domains, not technical layers | `business/` folder with content, planning, linking, optimization, publishing domains |
|
||||
| **Service Layer Pattern** | Business logic in services, not ViewSets | All modules delegate to domain services |
|
||||
| **Single Responsibility** | Each layer has one clear purpose | Core → Domain → Module → Infrastructure |
|
||||
| **No Duplication** | Reuse services across modules | ContentGenerationService used by Writer + Site Builder |
|
||||
@@ -108,7 +108,7 @@ backend/igny8_core/
|
||||
│ ├── permissions.py # IsAuthenticatedAndActive, HasTenantAccess
|
||||
│ └── throttles.py # DebugScopedRateThrottle
|
||||
│
|
||||
├── domain/ # DOMAIN LAYER (Business Logic)
|
||||
├── business/ # BUSINESS LAYER (Business Logic)
|
||||
│ ├── content/ # Content domain
|
||||
│ │ ├── models.py # Content, Tasks, Images (unified, extended)
|
||||
│ │ ├── services/
|
||||
@@ -248,20 +248,20 @@ backend/igny8_core/
|
||||
|
||||
| Model | Current Location | New Location | Extensions Needed |
|
||||
|-------|------------------|-------------|-------------------|
|
||||
| `Content` | `modules/writer/models.py` | `domain/content/models.py` | Add: `entity_type`, `json_blocks`, `structure_data`, `linker_version`, `optimizer_version`, `internal_links`, `optimization_scores`, `published_to`, `external_ids`, `source`, `sync_status`, `external_id`, `external_url`, `sync_metadata` |
|
||||
| `Tasks` | `modules/writer/models.py` | `domain/content/models.py` | Add: `entity_type` choices (product, service, taxonomy, etc.) |
|
||||
| `Keywords` | `modules/planner/models.py` | `domain/planning/models.py` | No changes |
|
||||
| `Clusters` | `modules/planner/models.py` | `domain/planning/models.py` | No changes |
|
||||
| `ContentIdeas` | `modules/planner/models.py` | `domain/planning/models.py` | Add: `entity_type` support |
|
||||
| `InternalLinks` | - | `domain/linking/models.py` | NEW: `source_id`, `target_id`, `anchor`, `position`, `link_type` |
|
||||
| `OptimizationTask` | - | `domain/optimization/models.py` | NEW: `content_id`, `type`, `target_keyword`, `scores_before`, `scores_after`, `html_before`, `html_after` |
|
||||
| `SiteBlueprint` | - | `domain/site_building/models.py` | NEW: `tenant`, `site`, `config_json`, `structure_json`, `status`, `hosting_type` |
|
||||
| `PageBlueprint` | - | `domain/site_building/models.py` | NEW: `site_blueprint`, `slug`, `type`, `blocks_json`, `status` |
|
||||
| `SiteIntegration` | - | `domain/integration/models.py` | NEW: `site`, `platform`, `platform_type`, `config_json`, `credentials`, `is_active`, `sync_enabled` |
|
||||
| `PublishingRecord` | - | `domain/publishing/models.py` | NEW: `content_id`, `destination`, `destination_type`, `status`, `external_id`, `published_at`, `sync_status` |
|
||||
| `DeploymentRecord` | - | `domain/publishing/models.py` | NEW: `site_blueprint`, `version`, `status`, `build_url`, `deployed_at`, `deployment_type` |
|
||||
| `AutomationRule` | - | `domain/automation/models.py` | NEW: `name`, `trigger`, `conditions`, `actions`, `schedule`, `is_active` |
|
||||
| `ScheduledTask` | - | `domain/automation/models.py` | NEW: `automation_rule`, `scheduled_at`, `status`, `executed_at` |
|
||||
| `Content` | `modules/writer/models.py` | `business/content/models.py` | Add: `entity_type`, `json_blocks`, `structure_data`, `linker_version`, `optimizer_version`, `internal_links`, `optimization_scores`, `published_to`, `external_ids`, `source`, `sync_status`, `external_id`, `external_url`, `sync_metadata` |
|
||||
| `Tasks` | `modules/writer/models.py` | `business/content/models.py` | Add: `entity_type` choices (product, service, taxonomy, etc.) |
|
||||
| `Keywords` | `modules/planner/models.py` | `business/planning/models.py` | No changes |
|
||||
| `Clusters` | `modules/planner/models.py` | `business/planning/models.py` | No changes |
|
||||
| `ContentIdeas` | `modules/planner/models.py` | `business/planning/models.py` | Add: `entity_type` support |
|
||||
| `InternalLinks` | - | `business/linking/models.py` | NEW: `source_id`, `target_id`, `anchor`, `position`, `link_type` |
|
||||
| `OptimizationTask` | - | `business/optimization/models.py` | NEW: `content_id`, `type`, `target_keyword`, `scores_before`, `scores_after`, `html_before`, `html_after` |
|
||||
| `SiteBlueprint` | - | `business/site_building/models.py` | NEW: `tenant`, `site`, `config_json`, `structure_json`, `status`, `hosting_type` |
|
||||
| `PageBlueprint` | - | `business/site_building/models.py` | NEW: `site_blueprint`, `slug`, `type`, `blocks_json`, `status` |
|
||||
| `SiteIntegration` | - | `business/integration/models.py` | NEW: `site`, `platform`, `platform_type`, `config_json`, `credentials`, `is_active`, `sync_enabled` |
|
||||
| `PublishingRecord` | - | `business/publishing/models.py` | NEW: `content_id`, `destination`, `destination_type`, `status`, `external_id`, `published_at`, `sync_status` |
|
||||
| `DeploymentRecord` | - | `business/publishing/models.py` | NEW: `site_blueprint`, `version`, `status`, `build_url`, `deployed_at`, `deployment_type` |
|
||||
| `AutomationRule` | - | `business/automation/models.py` | NEW: `name`, `trigger`, `conditions`, `actions`, `schedule`, `is_active` |
|
||||
| `ScheduledTask` | - | `business/automation/models.py` | NEW: `automation_rule`, `scheduled_at`, `status`, `executed_at` |
|
||||
|
||||
---
|
||||
|
||||
@@ -366,8 +366,8 @@ sites/src/
|
||||
|
||||
| Component | Purpose | Implementation |
|
||||
|-----------|---------|----------------|
|
||||
| **AutomationRule Model** | Store automation rules | `domain/automation/models.py` |
|
||||
| **AutomationService** | Execute automation rules | `domain/automation/services/automation_service.py` |
|
||||
| **AutomationRule Model** | Store automation rules | `business/automation/models.py` |
|
||||
| **AutomationService** | Execute automation rules | `business/automation/services/automation_service.py` |
|
||||
| **Celery Beat Tasks** | Scheduled automation | `infrastructure/messaging/automation_tasks.py` |
|
||||
| **Automation API** | CRUD for rules | `modules/automation/views.py` |
|
||||
| **Automation UI** | Manage rules | `frontend/src/pages/Automation/` |
|
||||
@@ -409,8 +409,8 @@ class AutomationRule(SiteSectorBaseModel):
|
||||
|
||||
| Task | File | Implementation |
|
||||
|------|------|----------------|
|
||||
| **AutomationRule Model** | `domain/automation/models.py` | Create model with trigger, conditions, actions, schedule |
|
||||
| **AutomationService** | `domain/automation/services/automation_service.py` | `execute_rule()`, `check_conditions()`, `execute_actions()` |
|
||||
| **AutomationRule Model** | `business/automation/models.py` | Create model with trigger, conditions, actions, schedule |
|
||||
| **AutomationService** | `business/automation/services/automation_service.py` | `execute_rule()`, `check_conditions()`, `execute_actions()` |
|
||||
| **Celery Beat Tasks** | `infrastructure/messaging/automation_tasks.py` | `@periodic_task` decorators for scheduled rules |
|
||||
| **Automation API** | `modules/automation/views.py` | CRUD ViewSet for AutomationRule |
|
||||
| **Automation UI** | `frontend/src/pages/Automation/` | Dashboard, Rules management, History |
|
||||
@@ -434,9 +434,9 @@ class AutomationRule(SiteSectorBaseModel):
|
||||
|
||||
| Resource | Limit Type | Enforcement | Location |
|
||||
|-----------|------------|-------------|----------|
|
||||
| **Daily Content Tasks** | Per site | `Plan.daily_content_tasks` | `domain/content/services/content_generation_service.py` |
|
||||
| **Daily Content Tasks** | Per site | `Plan.daily_content_tasks` | `business/content/services/content_generation_service.py` |
|
||||
| **Daily AI Requests** | Per site | `Plan.daily_ai_requests` | `infrastructure/ai/engine.py` |
|
||||
| **Monthly Word Count** | Per site | `Plan.monthly_word_count_limit` | `domain/content/services/content_generation_service.py` |
|
||||
| **Monthly Word Count** | Per site | `Plan.monthly_word_count_limit` | `business/content/services/content_generation_service.py` |
|
||||
| **Daily Image Generation** | Per site | `Plan.daily_image_generation_limit` | `infrastructure/ai/functions/generate_images.py` |
|
||||
| **Storage Quota** | Per site | Configurable (default: 10GB) | `infrastructure/storage/file_storage.py` |
|
||||
| **Concurrent Tasks** | Per site | Configurable (default: 5) | Celery queue configuration |
|
||||
@@ -530,7 +530,7 @@ class FileStorageService:
|
||||
|
||||
**Site Builder File Management**:
|
||||
```python
|
||||
# domain/site_building/services/file_management_service.py
|
||||
# business/site_building/services/file_management_service.py
|
||||
class SiteBuilderFileService:
|
||||
def get_user_accessible_sites(self, user) -> List[Site]:
|
||||
"""Get sites user can access for file management"""
|
||||
@@ -645,11 +645,11 @@ docker-data/
|
||||
|
||||
| Task | Files | Status | Priority |
|
||||
|------|-------|--------|-----------|
|
||||
| **Extend Content Model** | `domain/content/models.py` | TODO | HIGH |
|
||||
| **Create Service Layer** | `domain/*/services/` | TODO | HIGH |
|
||||
| **Extend Content Model** | `business/content/models.py` | TODO | HIGH |
|
||||
| **Create Service Layer** | `business/*/services/` | TODO | HIGH |
|
||||
| **Refactor ViewSets** | `modules/*/views.py` | TODO | HIGH |
|
||||
| **Implement Automation Models** | `domain/automation/models.py` | TODO | HIGH |
|
||||
| **Implement Automation Service** | `domain/automation/services/` | TODO | HIGH |
|
||||
| **Implement Automation Models** | `business/automation/models.py` | TODO | HIGH |
|
||||
| **Implement Automation Service** | `business/automation/services/` | TODO | HIGH |
|
||||
| **Implement Automation API** | `modules/automation/` | TODO | HIGH |
|
||||
| **Implement Automation UI** | `frontend/src/pages/Automation/` | TODO | HIGH |
|
||||
| **Note**: Schedules functionality will be integrated into Automation UI, not as a separate page | - | - | - |
|
||||
@@ -659,8 +659,8 @@ docker-data/
|
||||
| Task | Files | Dependencies | Priority |
|
||||
|------|-------|--------------|----------|
|
||||
| **Create Site Builder Container** | `docker-compose.app.yml` | Phase 0 | HIGH |
|
||||
| **Site Builder Models** | `domain/site_building/models.py` | Phase 0 | HIGH |
|
||||
| **Structure Generation Service** | `domain/site_building/services/` | Phase 0 | HIGH |
|
||||
| **Site Builder Models** | `business/site_building/models.py` | Phase 0 | HIGH |
|
||||
| **Structure Generation Service** | `business/site_building/services/` | Phase 0 | HIGH |
|
||||
| **Structure Generation AI Function** | `infrastructure/ai/functions/generate_site_structure.py` | Phase 0 | HIGH |
|
||||
| **Site Builder API** | `modules/site_builder/` | Phase 0 | HIGH |
|
||||
| **Site Builder Frontend** | `site-builder/src/` | Phase 0 | HIGH |
|
||||
@@ -669,12 +669,12 @@ docker-data/
|
||||
|
||||
| Task | Files | Dependencies | Priority |
|
||||
|------|-------|--------------|----------|
|
||||
| **Linker Models** | `domain/linking/models.py` | Phase 0 | MEDIUM |
|
||||
| **Linker Service** | `domain/linking/services/` | Phase 0 | MEDIUM |
|
||||
| **Linker Models** | `business/linking/models.py` | Phase 0 | MEDIUM |
|
||||
| **Linker Service** | `business/linking/services/` | Phase 0 | MEDIUM |
|
||||
| **Linker API** | `modules/linker/` | Phase 0 | MEDIUM |
|
||||
| **Linker UI** | `frontend/src/pages/Linker/` | Phase 0 | MEDIUM |
|
||||
| **Optimizer Models** | `domain/optimization/models.py` | Phase 0 | MEDIUM |
|
||||
| **Optimizer Service** | `domain/optimization/services/` | Phase 0 | MEDIUM |
|
||||
| **Optimizer Models** | `business/optimization/models.py` | Phase 0 | MEDIUM |
|
||||
| **Optimizer Service** | `business/optimization/services/` | Phase 0 | MEDIUM |
|
||||
| **Optimizer AI Function** | `infrastructure/ai/functions/optimize_content.py` | Phase 0 | MEDIUM |
|
||||
| **Optimizer API** | `modules/optimizer/` | Phase 0 | MEDIUM |
|
||||
| **Optimizer UI** | `frontend/src/pages/Optimizer/` | Phase 0 | MEDIUM |
|
||||
@@ -685,22 +685,22 @@ docker-data/
|
||||
|------|-------|--------------|----------|
|
||||
| **Create Sites Container** | `docker-compose.app.yml` | Phase 1 | MEDIUM |
|
||||
| **Sites Renderer Frontend** | `sites/src/` | Phase 1 | MEDIUM |
|
||||
| **Publisher Service** | `domain/publishing/services/` | Phase 0 | MEDIUM |
|
||||
| **Sites Renderer Adapter** | `domain/publishing/services/adapters/` | Phase 1 | MEDIUM |
|
||||
| **Publisher Service** | `business/publishing/services/` | Phase 0 | MEDIUM |
|
||||
| **Sites Renderer Adapter** | `business/publishing/services/adapters/` | Phase 1 | MEDIUM |
|
||||
| **Publisher API** | `modules/publisher/` | Phase 0 | MEDIUM |
|
||||
| **Deployment Service** | `domain/publishing/services/deployment_service.py` | Phase 1 | MEDIUM |
|
||||
| **Deployment Service** | `business/publishing/services/deployment_service.py` | Phase 1 | MEDIUM |
|
||||
|
||||
### 9.5 Phase 4: Universal Content Types
|
||||
|
||||
| Task | Files | Dependencies | Priority |
|
||||
|------|-------|--------------|----------|
|
||||
| **Extend Content Model** | `domain/content/models.py` | Phase 0 | LOW |
|
||||
| **Extend Content Model** | `business/content/models.py` | Phase 0 | LOW |
|
||||
| **Product Content Prompts** | `infrastructure/ai/prompts.py` | Phase 0 | LOW |
|
||||
| **Service Page Prompts** | `infrastructure/ai/prompts.py` | Phase 0 | LOW |
|
||||
| **Taxonomy Prompts** | `infrastructure/ai/prompts.py` | Phase 0 | LOW |
|
||||
| **Content Type Support in Writer** | `domain/content/services/` | Phase 0 | LOW |
|
||||
| **Content Type Support in Linker** | `domain/linking/services/` | Phase 2 | LOW |
|
||||
| **Content Type Support in Optimizer** | `domain/optimization/services/` | Phase 2 | LOW |
|
||||
| **Content Type Support in Writer** | `business/content/services/` | Phase 0 | LOW |
|
||||
| **Content Type Support in Linker** | `business/linking/services/` | Phase 2 | LOW |
|
||||
| **Content Type Support in Optimizer** | `business/optimization/services/` | Phase 2 | LOW |
|
||||
|
||||
---
|
||||
|
||||
@@ -750,11 +750,11 @@ docker-data/
|
||||
| Location | Check | Implementation |
|
||||
|----------|-------|----------------|
|
||||
| **AI Engine** | Before AI call | `infrastructure/ai/engine.py` - Check credits, deduct before request |
|
||||
| **Content Generation** | Before generation | `domain/content/services/content_generation_service.py` |
|
||||
| **Content Generation** | Before generation | `business/content/services/content_generation_service.py` |
|
||||
| **Image Generation** | Before generation | `infrastructure/ai/functions/generate_images.py` |
|
||||
| **Linking** | Before linking | `domain/linking/services/linker_service.py` (NEW) |
|
||||
| **Optimization** | Before optimization | `domain/optimization/services/optimizer_service.py` (NEW) |
|
||||
| **Site Building** | Before structure gen | `domain/site_building/services/structure_generation_service.py` (NEW) |
|
||||
| **Linking** | Before linking | `business/linking/services/linker_service.py` (NEW) |
|
||||
| **Optimization** | Before optimization | `business/optimization/services/optimizer_service.py` (NEW) |
|
||||
| **Site Building** | Before structure gen | `business/site_building/services/structure_generation_service.py` (NEW) |
|
||||
|
||||
### 10.5 Credit Logging
|
||||
|
||||
@@ -784,8 +784,8 @@ These are **NOT** business limits - they're technical constraints for request pr
|
||||
|
||||
| Feature | Implementation | Location |
|
||||
|---------|----------------|----------|
|
||||
| **Credit Check** | Before every AI operation | `domain/billing/services/credit_service.py` |
|
||||
| **Credit Deduction** | After successful operation | `domain/billing/services/credit_service.py` |
|
||||
| **Credit Check** | Before every AI operation | `business/billing/services/credit_service.py` |
|
||||
| **Credit Deduction** | After successful operation | `business/billing/services/credit_service.py` |
|
||||
| **Credit Top-up** | On-demand purchase | `modules/billing/views.py` |
|
||||
| **Monthly Replenishment** | Celery Beat task | `infrastructure/messaging/automation_tasks.py` |
|
||||
| **Low Credit Warning** | When < 10% remaining | Frontend + Email notification |
|
||||
@@ -893,7 +893,7 @@ publisher_service.publish(
|
||||
### 11.6 Site Integration Service
|
||||
|
||||
```python
|
||||
# domain/integration/services/integration_service.py
|
||||
# business/integration/services/integration_service.py
|
||||
class IntegrationService:
|
||||
def create_integration(self, site, platform, config, credentials):
|
||||
"""Create new site integration"""
|
||||
@@ -945,12 +945,12 @@ Content/Site Publishing Flow:
|
||||
|
||||
| Component | File | Purpose |
|
||||
|-----------|------|---------|
|
||||
| **SiteIntegration Model** | `domain/integration/models.py` | Store integration configs |
|
||||
| **IntegrationService** | `domain/integration/services/integration_service.py` | Manage integrations |
|
||||
| **SyncService** | `domain/integration/services/sync_service.py` | Handle two-way sync |
|
||||
| **WordPressAdapter** | `domain/publishing/services/adapters/wordpress_adapter.py` | WordPress publishing |
|
||||
| **SitesRendererAdapter** | `domain/publishing/services/adapters/sites_renderer_adapter.py` | IGNY8 Sites deployment |
|
||||
| **ShopifyAdapter** | `domain/publishing/services/adapters/shopify_adapter.py` | Shopify publishing (future) |
|
||||
| **SiteIntegration Model** | `business/integration/models.py` | Store integration configs |
|
||||
| **IntegrationService** | `business/integration/services/integration_service.py` | Manage integrations |
|
||||
| **SyncService** | `business/integration/services/sync_service.py` | Handle two-way sync |
|
||||
| **WordPressAdapter** | `business/publishing/services/adapters/wordpress_adapter.py` | WordPress publishing |
|
||||
| **SitesRendererAdapter** | `business/publishing/services/adapters/sites_renderer_adapter.py` | IGNY8 Sites deployment |
|
||||
| **ShopifyAdapter** | `business/publishing/services/adapters/shopify_adapter.py` | Shopify publishing (future) |
|
||||
| **Integration API** | `modules/integration/views.py` | CRUD for integrations |
|
||||
| **Integration UI** | `frontend/src/pages/Settings/Integrations.tsx` | Manage integrations |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user