This document contains a comprehensive audit of all branding, coupling, hardcoded configuration, and fashion-vertical specific logic across the codebase, mapping them to specific roadmap phases for clean, generic refactoring.
---
## 1. Canifa Brand & Platform Coupling (Phase 6)
The following references to "Canifa" exist in the core backend code and must be de-branded, genericized, or extracted into the `fashion-retail` blueprint/plugin pack in **Phase 6**:
| File Path | Line(s) | Description / Type of Coupling |
| `"company_123"` | `backend/tests/test_agent_flow.py` & `backend/scratch/*.py` | Multiple | Keep in test suite (mocking), but remove from database initialization seed scripts in `seed_db.py` (replace with dynamic seed from blueprint). |
| `"PAP"` | [backend/models/companies.py](file:///d:/a/ai_canifa_company/backend/models/companies.py) | 23 | Default issue prefix. Should be read dynamically from the database row (which is seeded by the company blueprint). |
| `"http://localhost:13001"` | [backend/services/nocobase_connector.py](file:///d:/a/ai_canifa_company/backend/services/nocobase_connector.py) | 9, 12 | Default NocoBase host URL. Must be fetched dynamically from `CompanySecret` or company-scoped database configs. |
| `"admin@nocobase.com"` / `"admin123"` | [backend/services/nocobase_connector.py](file:///d:/a/ai_canifa_company/backend/services/nocobase_connector.py) | 21 | Default NocoBase administrator credentials. Must be loaded from secrets. |
| `"admin@paperclip.ai"` | `backend/scratch/*.py` | Multiple | Default admin email. Convert to a dynamic config parameter. |
---
## 3. Hardcoded Swarm Role Pipeline (Phase 1)
Swarm orchestration stages are currently hardcoded in [backend/services/project_orchestrator.py](file:///d:/a/ai_canifa_company/backend/services/project_orchestrator.py):
["marketing", "ecom", "coder"], # Stage 3: Depends on design/spec output
["qa"], # Stage 4: QA reviews everything
["devops"], # Stage 5: DevOps deploys (optional)
]
```
***ROLE_ORDER** (Line 37): Flattened version of the above.
**Phase 1 Action**: Refactor `ProjectOrchestrator` to accept a dynamic topological sorting of roles (pipeline DAG spec) loaded from the `CompanyBlueprint`. If none is specified, fall back to the default `PIPELINE_STAGES` list to maintain backward compatibility.
We investigated the issue completion triggers in `backend/api/routes/issues.py` and `backend/tasks/agent_tasks.py`:
***Current state**: There is **no automated chain-reaction issue auto-spawn logic** running inside the backend core when an issue transitions to `"completed"` or `"resolved"`.
***Trigger structure**: Waking up agent checkout runs is handled via the explicit POST endpoint `/api/issues-checkout-wakeup` (in `backend/api/routes/issues_checkout_wakeup.py`) which inserts a queued `HeartbeatRun` record.
***Conclusion**: Since there is no existing chain-reaction logic to refactor, we do not need to worry about breaking implicit triggers. Building a true auto-spawning rule engine is scheduled as an extension task (E3) in the roadmap rather than a core refactoring item.
---
## 5. Fashion-Vertical Specific Features (Phase 6)
The following modules contain business logic coupled directly to fashion retail, styling, and product description generation. These should be isolated as plugins or blueprints in **Phase 6**:
1.[backend/common/canifa_api.py](file:///d:/a/ai_canifa_company/backend/common/canifa_api.py): Magento client integration with Canifa customer and authentication APIs.
2.[backend/common/content_templates.py](file:///d:/a/ai_canifa_company/backend/common/content_templates.py): Custom social/marketing templates in Vietnamese specifically customized for Canifa clothing, outfit styling, and campaigns.
3.[backend/common/outfit_db.py](file:///d:/a/ai_canifa_company/backend/common/outfit_db.py): Helper classes and DB wrappers for outfit compositions and "stylist pins".
4.[backend/common/ultra_desc_db.py](file:///d:/a/ai_canifa_company/backend/common/ultra_desc_db.py): Special generator and database connector for ultra-long fashion marketing descriptions.
5.[backend/common/social/approval_gate.py](file:///d:/a/ai_canifa_company/backend/common/social/approval_gate.py): References to the AI stylist engine generating fashion suggestions.
The following existing components provide structures that can be utilized to implement company-level blueprints:
***Marketplace Templates**: [backend/data/marketplace_templates.json](file:///d:/a/ai_canifa_company/backend/data/marketplace_templates.json) defines an array of deployment templates (e.g., `landing-page-builder`, `mobile-app-team`) containing fields like `name`, `description`, and `agents` (with `role`, `name`, `skills`).
***Deploy Logic**: [backend/api/routes/pipelines.py](file:///d:/a/ai_canifa_company/backend/api/routes/pipelines.py)(Lines 73-96) shows how agents are instantiated from templates.
***Portability Exports**: [backend/api/routes/company_portability.py](file:///d:/a/ai_canifa_company/backend/api/routes/company_portability.py) defines how company data (agents, pipelines, secrets) is serialized/deserialized, serving as a base model for importing blueprints.