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

LAYOUT_WITH_LEGEND()

title Social Media Management - Component Diagram

Person(owner, "Business Owner", "Approves campaigns, reviews messaging, and oversees brand presence")
Person(staff, "Operations Staff", "Creates content, schedules posts, and manages publishing workflows")

ContainerDb(txdb, "Transaction Database", "Database", "Stores campaigns, content records, schedules, engagement metrics, and workflow history")
Container(auth, "Authentication Service", "Shared Service", "Provides authentication and identity controls")
Container(datarepo, "Shared Data Repository", "Shared Service", "Provides access to shared business entities and reference data")
Container(api, "API Orchestrator", "API / Integration Service", "Coordinates internal and external integrations")
Container(audit, "Audit & Logging Service", "Observability Service", "Captures publishing, approval, and compliance-relevant events")
Container(notify, "Notification Service", "Shared Service", "Generates alerts, reminders, approvals, and exception notifications")

System_Ext(facebook, "Facebook", "@kellcreation", "Social publishing platform")
System_Ext(instagram, "Instagram", "@kellcreations", "Social publishing platform")
System_Ext(xsocial, "X", "@kellcreations", "Social publishing platform")

Container_Boundary(social_app, "Social Media Management") {
  Component(ui, "Social Media Management UI", "Web UI", "Provides campaign views, scheduling controls, approval status, and engagement dashboards")
  Component(campaign_service, "Campaign Management Service", "Application Service", "Manages campaign plans, themes, objectives, and lifecycle state")
  Component(content_service, "Content Planning Service", "Application Service", "Maintains post drafts, captions, hashtags, creative associations, and publishing metadata")
  Component(schedule_service, "Publishing Schedule Service", "Application Service", "Controls publish timing, queue state, cadence, and readiness")
  Component(approval_service, "Approval Workflow Service", "Application Service", "Manages review, approval, rejection, and exception handling for publishable content")
  Component(publish_service, "Social Publishing Service", "Application Service", "Publishes approved content to external social platforms")
  Component(engagement_service, "Engagement Tracking Service", "Application Service", "Collects and analyzes post status, reach, and engagement metrics")
  Component(reporting_service, "Social Reporting Service", "Application Service", "Produces campaign performance, schedule status, and exception reports")
  Component(repository, "Social Media Repository", "Data Access Component", "Reads and writes social-media-related data")
}

Rel(owner, ui, "Uses")
Rel(staff, ui, "Uses")

Rel(ui, campaign_service, "Sends requests to")
Rel(ui, content_service, "Sends requests to")
Rel(ui, schedule_service, "Sends requests to")
Rel(ui, approval_service, "Sends requests to")
Rel(ui, publish_service, "Sends requests to")
Rel(ui, engagement_service, "Sends requests to")
Rel(ui, reporting_service, "Sends requests to")

Rel(campaign_service, repository, "Reads from and writes to")
Rel(content_service, repository, "Reads from and writes to")
Rel(schedule_service, repository, "Reads from and writes to")
Rel(approval_service, repository, "Reads from and writes to")
Rel(publish_service, repository, "Reads from and writes to")
Rel(engagement_service, repository, "Reads from and writes to")
Rel(reporting_service, repository, "Reads from")

Rel(repository, txdb, "Reads from and writes to")

Rel(campaign_service, datarepo, "Uses shared business data from")
Rel(content_service, datarepo, "Uses shared business data from")
Rel(schedule_service, datarepo, "Uses shared business data from")
Rel(approval_service, datarepo, "Uses shared business data from")

Rel(ui, auth, "Authenticates through")
Rel(approval_service, notify, "Triggers approval and exception notifications through")
Rel(publish_service, api, "Publishes external platform events through")
Rel(engagement_service, api, "Receives external engagement data through")
Rel(reporting_service, api, "Sends reporting outputs through")

Rel(publish_service, facebook, "Publishes content to")
Rel(publish_service, instagram, "Publishes content to")
Rel(publish_service, xsocial, "Publishes content to")

Rel(campaign_service, audit, "Logs campaign changes to")
Rel(content_service, audit, "Logs content changes to")
Rel(schedule_service, audit, "Logs scheduling activity to")
Rel(approval_service, audit, "Logs approval decisions to")
Rel(publish_service, audit, "Logs publishing activity to")
Rel(engagement_service, audit, "Logs engagement collection activity to")

@enduml