1. Core System
1.1 Authentication
JWT‑based auth with refresh tokens and MFA for admin roles.
{
"flows": ["login", "refresh", "logout", "password_reset", "mfa_admin_only"],
"errors": {
"AUTH-001": "Invalid credentials",
"AUTH-002": "Token expired",
"AUTH-003": "MFA required",
"AUTH-004": "Unauthorized"
}
}
1.2 RBAC
{
"roles": [
"owner",
"staff",
"admin_support",
"admin_ops",
"admin_billing",
"admin_compliance",
"super_admin"
],
"permission_object": {
"permission_id": "crm.view",
"description": "Allows viewing CRM records"
}
}
1.3 Multi‑Tenant Isolation
Every record is scoped by business_id. Every API call is validated against the tenant in the JWT claims.
2. Data Schema
2.1 Core Tables
business( business_id PK, owner_id FK, business_name, category, industry, status, created_at, updated_at ) user( user_id PK, business_id FK, name, email, role, permissions JSON, status, last_login ) module_activation( business_id, module_id, activated_at, activated_by, status ) event_log( event_id PK, business_id, user_id, event_type, payload JSON, created_at ) audit_log( audit_id PK, business_id, user_id, action, table_name, record_id, before_state JSON, after_state JSON, timestamp )
3. Modules – CRM
3.1 Schema
customers( customer_id PK, business_id, name, email, phone, tags JSON, created_at, updated_at ) interactions( interaction_id PK, business_id, customer_id, type, channel, notes, created_at )
3.2 API
GET /v1/crm/customers
POST /v1/crm/customers
GET /v1/crm/customers/{id}
POST /v1/crm/interactions
3.3 Events
customer.created interaction.logged
3.4 Permissions
crm.view crm.edit
4. API Specification
4.1 Structure
/v1/auth/... /v1/business/... /v1/crm/... /v1/invoices/... /v1/payments/... /v1/inventory/... /v1/hr/... /v1/accounting/... /v1/procurement/... /v1/ai/... /v1/automation/... /v1/notifications/... /v1/admin/...
4.2 Response Envelope
{
"success": true,
"data": { ... },
"error": null
}
5. AI Advisor Specification
{
"modes": ["sp", "compliance", "growth", "team", "finance"],
"context": {
"business": { ... },
"modules": [ ... ],
"kpis": { ... },
"events": [ ... ],
"goals": [ ... ],
"ai_mode": "growth"
}
}
6. Automation Specification
{
"workflow_id": "uuid",
"trigger": { ... },
"conditions": [ ... ],
"actions": [ ... ],
"status": "active"
}
7. Notification Specification
{
"notification_id": "uuid",
"business_id": "uuid",
"user_id": "uuid",
"type": "payment.received",
"priority": "high",
"channels": ["in_app", "email"],
"payload": { ... },
"status": "sent"
}
8. Billing Specification
{
"business_id": "uuid",
"tier": "entrepreneur",
"price": 49,
"billing_cycle": "monthly",
"next_billing_date": "2026-04-01"
}
9. Admin Console Specification
Admin actions: - Impersonate - Suspend business - Activate module - Change tier - Issue refund - View audit logs
- v0.1.0 – Initial Master Technical Specification scaffold created.