@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml

LAYOUT_WITH_LEGEND()

title Kell Creations Platform - Container Diagram

Person(owner, "Business Owner", "Oversees business operations, governance, and growth")
Person(staff, "Operations Staff", "Supports production, publishing, fulfillment, and administration")

System_Ext(wordpress, "WordPress", "Website and content publishing platform")
System_Ext(n8n, "n8n", "Workflow automation and AI-enabled process orchestration")
System_Ext(mail, "Mail Server", "Business notifications, approvals, and communications")
System_Ext(git, "Forgejo Git", "Source control and auditable documentation history")
System_Ext(facebook, "Facebook", "Social media publishing and engagement")
System_Ext(instagram, "Instagram", "Social media publishing and engagement")
System_Ext(xsocial, "X", "Social media publishing and engagement")

System_Boundary(platform, "Kell Creations Platform") {
  Container(inventory, "Inventory Application", "Web App", "Tracks materials, finished goods, stock adjustments, and availability")
  Container(social, "Social Media Management", "Web App", "Plans campaigns, schedules content, and tracks social engagement")
  Container(wpmanage, "WordPress Management", "Web App / Admin Service", "Manages WordPress publishing, content sync, and site administration")
  Container(mrp, "Craft Manufacturing / MRP", "Web App", "Manages BOMs, work orders, production planning, and fulfillment preparation")
  Container(finance, "Financial Analysis", "Web App", "Supports reporting, forecasting, and business performance analysis")
  Container(txdb, "Transaction Database", "Database", "Stores product, order, customer, material, and transaction records")
  Container(auth, "Authentication Service", "Shared Service", "Provides authentication and identity controls across applications")
  Container(datarepo, "Shared Data Repository", "Shared Service", "Provides common data access patterns and shared business entities")
  Container(api, "API Orchestrator", "API / Integration Service", "Coordinates integrations and internal service communication")
  Container(notify, "Notification Service", "Shared Service", "Generates approval, alert, and workflow notifications")
  Container(policyrepo, "Policy Repository", "Docs / Controlled Content", "Maintains policies, procedures, standards, and records under document control")
}

Rel(owner, inventory, "Uses")
Rel(owner, social, "Uses")
Rel(owner, wpmanage, "Uses")
Rel(owner, mrp, "Uses")
Rel(owner, finance, "Uses")
Rel(owner, policyrepo, "Governs")

Rel(staff, inventory, "Uses")
Rel(staff, social, "Uses")
Rel(staff, wpmanage, "Uses")
Rel(staff, mrp, "Uses")
Rel(staff, policyrepo, "Reads")

Rel(inventory, txdb, "Reads from and writes to")
Rel(social, txdb, "Reads from and writes to")
Rel(wpmanage, txdb, "Reads from and writes to")
Rel(mrp, txdb, "Reads from and writes to")
Rel(finance, txdb, "Reads from and writes to")

Rel(inventory, auth, "Authenticates through")
Rel(social, auth, "Authenticates through")
Rel(wpmanage, auth, "Authenticates through")
Rel(mrp, auth, "Authenticates through")
Rel(finance, auth, "Authenticates through")

Rel(inventory, datarepo, "Uses shared data from")
Rel(social, datarepo, "Uses shared data from")
Rel(wpmanage, datarepo, "Uses shared data from")
Rel(mrp, datarepo, "Uses shared data from")
Rel(finance, datarepo, "Uses shared data from")

Rel(inventory, api, "Sends and receives integration events through")
Rel(social, api, "Sends and receives integration events through")
Rel(wpmanage, api, "Sends and receives integration events through")
Rel(mrp, api, "Sends and receives integration events through")
Rel(finance, api, "Sends and receives integration events through")

Rel(api, wordpress, "Publishes and synchronizes with")
Rel(api, n8n, "Triggers and receives workflows from")
Rel(api, mail, "Sends messages through")
Rel(api, facebook, "Publishes content to")
Rel(api, instagram, "Publishes content to")
Rel(api, xsocial, "Publishes content to")

Rel(policyrepo, git, "Stores version-controlled policy source in")
Rel(policyrepo, notify, "Uses for review and approval reminders")

@enduml