# vasanthgeethanraju/sf-penya-agent architecture

> Architecture diagram of the GitHub repository vasanthgeethanraju/sf-penya-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vasanthgeethanraju/sf-penya-agent
- Repository: https://github.com/vasanthgeethanraju/sf-penya-agent

## Overview

SF Penya Agent automates match-day communications for Barça watch parties: it gathers match and San Francisco context, generates channel content and optionally a poster, assembles and emails an approval package, then lets a human approve or reject it. Approval triggers sandbox publishing to Instagram, email, and WhatsApp. The graph follows the documented workflow and sampled calls; unsampled integrations are included only where the README or source index supports their role.

Main entry points: [`src/index.ts`](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/index.ts) (Package runner), [`src/tools/getMatchContext.ts`](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/tools/getMatchContext.ts) (Context coordinator), [`src/sandbox/publishSandboxPackage.ts`](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/sandbox/publishSandboxPackage.ts) (Sandbox dispatcher), [`src/agent.ts`](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/agent.ts) (Content agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_context["Match context"]
  node_match_context["Context coordinator<br/>[getMatchContext.ts]"]
  node_next_match["Next match lookup"]
  node_schedule["Official schedule"]
  node_weather["Weather lookup<br/>[getSfWeather.ts]"]
  node_events["SF events lookup<br/>[getSfEvents.ts]"]
  node_event_filter["Event relevance filter"]
  node_transit["Transit alerts"]
  node_transit_filter["Transit relevance filter"]
end

subgraph group_content["Content and poster"]
  node_runner["Package runner<br/>[index.ts]"]
  node_agent["Content agent<br/>[agent.ts]"]
  node_prompt["System prompt"]
  node_content_schema["Content schema"]
  node_poster_config["Poster configuration"]
  node_poster_prompt["Poster prompt"]
  node_poster_image["Poster image generation"]
  node_poster_upload["Poster upload<br/>[uploadPoster.ts]"]
end

subgraph group_approval["Approval workflow"]
  node_approval_package["Approval package"]
  node_approval_types["Approval data model<br/>[approvalTypes.ts]"]
  node_approval_storage[("Approval storage<br/>[approvalStorage.ts]")]
  node_approval_email["Approval email builder"]
  node_email_sender["Approval email sender"]
  node_gmail_auth["Gmail authentication<br/>[getGmailAuth.ts]"]
  node_approval_server["Approval server<br/>[server.ts]"]
end

subgraph group_publishing["Sandbox publishing"]
  node_publish_package["Sandbox dispatcher"]
  node_instagram["Instagram publisher"]
  node_sandbox_email["Sandbox email publisher"]
  node_whatsapp["WhatsApp publisher"]
  node_execution_types["Execution results<br/>[sandboxTypes.ts]"]
end

node_operator(("Match-day operator"))
node_human(("Human approver"))

node_operator -->|"starts run"| node_runner
node_runner -->|"requests content"| node_agent
node_agent -->|"gets context"| node_match_context
node_agent -->|"uses prompt"| node_prompt
node_agent -->|"validates output"| node_content_schema
node_match_context -->|"fetches match"| node_next_match
node_match_context -->|"fetches weather"| node_weather
node_match_context -->|"fetches events"| node_events
node_match_context -->|"filters events"| node_event_filter
node_match_context -->|"fetches alerts"| node_transit
node_match_context -->|"filters alerts"| node_transit_filter
node_next_match -->|"uses schedule"| node_schedule
node_runner -->|"builds config"| node_poster_config
node_runner -->|"builds prompt"| node_poster_prompt
node_runner -->|"generates image"| node_poster_image
node_runner -->|"uploads poster"| node_poster_upload
node_runner -->|"creates package"| node_approval_package
node_approval_package -->|"saves package"| node_approval_storage
node_runner -->|"builds email"| node_approval_email
node_runner -->|"sends email"| node_email_sender
node_email_sender -->|"gets credentials"| node_gmail_auth
node_human -->|"approves or rejects"| node_approval_server
node_approval_server -->|"loads and updates"| node_approval_storage
node_approval_server -->|"dispatches approved"| node_publish_package
node_publish_package -->|"publishes post"| node_instagram
node_publish_package -->|"sends email"| node_sandbox_email
node_publish_package -->|"sends message"| node_whatsapp
node_publish_package -->|"records results"| node_execution_types

click node_runner "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/index.ts"
click node_agent "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/agent.ts"
click node_prompt "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/prompts/matchDaySystemPrompt.ts"
click node_content_schema "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/schemas/matchDayContentSchema.ts"
click node_match_context "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/tools/getMatchContext.ts"
click node_next_match "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/tools/getNextBarcaMatch.ts"
click node_schedule "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/providers/barcaOfficialSchedule.ts"
click node_weather "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/tools/getSfWeather.ts"
click node_events "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/tools/getSfEvents.ts"
click node_event_filter "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/events/filterRelevantEvents.ts"
click node_transit "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/tools/getTransitAlerts.ts"
click node_transit_filter "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/transit/filterRelevantTransitAlerts.ts"
click node_poster_config "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/poster/buildPosterConfig.ts"
click node_poster_prompt "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/poster/buildPosterPrompt.ts"
click node_poster_image "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/poster/generatePosterImage.ts"
click node_poster_upload "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/storage/uploadPoster.ts"
click node_approval_package "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/approval/createApprovalPackage.ts"
click node_approval_types "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/approval/approvalTypes.ts"
click node_approval_storage "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/storage/approvalStorage.ts"
click node_approval_email "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/approval/buildApprovalEmail.ts"
click node_email_sender "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/email/sendApprovalEmail.ts"
click node_gmail_auth "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/email/getGmailAuth.ts"
click node_approval_server "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/server.ts"
click node_publish_package "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/sandbox/publishSandboxPackage.ts"
click node_instagram "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/sandbox/publishSandboxInstagram.ts"
click node_sandbox_email "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/sandbox/publishSandboxEmail.ts"
click node_whatsapp "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/sandbox/publishSandboxWhatsApp.ts"
click node_execution_types "https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/sandbox/sandboxTypes.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_match_context,node_next_match,node_schedule,node_weather,node_events,node_event_filter,node_transit,node_transit_filter toneBlue
class node_runner,node_agent,node_prompt,node_content_schema,node_poster_config,node_poster_prompt,node_poster_image,node_poster_upload toneAmber
class node_approval_package,node_approval_types,node_approval_storage,node_approval_email,node_email_sender,node_gmail_auth,node_approval_server toneMint
class node_publish_package,node_instagram,node_sandbox_email,node_whatsapp,node_execution_types toneRose
class node_operator,node_human toneIndigo
```

## Components

### Match context

- [Context coordinator](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/tools/getMatchContext.ts): `src/tools/getMatchContext.ts`
- [Next match lookup](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/tools/getNextBarcaMatch.ts): `src/tools/getNextBarcaMatch.ts`
- [Official schedule](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/providers/barcaOfficialSchedule.ts): `src/providers/barcaOfficialSchedule.ts`
- [Weather lookup](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/tools/getSfWeather.ts): `src/tools/getSfWeather.ts`
- [SF events lookup](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/tools/getSfEvents.ts): `src/tools/getSfEvents.ts`
- [Event relevance filter](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/events/filterRelevantEvents.ts): `src/events/filterRelevantEvents.ts`
- [Transit alerts](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/tools/getTransitAlerts.ts): `src/tools/getTransitAlerts.ts`
- [Transit relevance filter](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/transit/filterRelevantTransitAlerts.ts): `src/transit/filterRelevantTransitAlerts.ts`

### Content and poster

- [Package runner](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/index.ts): `src/index.ts`
- [Content agent](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/agent.ts): `src/agent.ts`
- [System prompt](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/prompts/matchDaySystemPrompt.ts): `src/prompts/matchDaySystemPrompt.ts`
- [Content schema](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/schemas/matchDayContentSchema.ts): `src/schemas/matchDayContentSchema.ts`
- [Poster configuration](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/poster/buildPosterConfig.ts): `src/poster/buildPosterConfig.ts`
- [Poster prompt](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/poster/buildPosterPrompt.ts): `src/poster/buildPosterPrompt.ts`
- [Poster image generation](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/poster/generatePosterImage.ts): `src/poster/generatePosterImage.ts`
- [Poster upload](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/storage/uploadPoster.ts): `src/storage/uploadPoster.ts`

### Approval workflow

- [Approval package](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/approval/createApprovalPackage.ts): `src/approval/createApprovalPackage.ts`
- [Approval data model](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/approval/approvalTypes.ts): `src/approval/approvalTypes.ts`
- [Approval storage](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/storage/approvalStorage.ts): `src/storage/approvalStorage.ts`
- [Approval email builder](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/approval/buildApprovalEmail.ts): `src/approval/buildApprovalEmail.ts`
- [Approval email sender](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/email/sendApprovalEmail.ts): `src/email/sendApprovalEmail.ts`
- [Gmail authentication](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/email/getGmailAuth.ts): `src/email/getGmailAuth.ts`
- [Approval server](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/server.ts): `src/server.ts`

### Sandbox publishing

- [Sandbox dispatcher](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/sandbox/publishSandboxPackage.ts): `src/sandbox/publishSandboxPackage.ts`
- [Instagram publisher](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/sandbox/publishSandboxInstagram.ts): `src/sandbox/publishSandboxInstagram.ts`
- [Sandbox email publisher](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/sandbox/publishSandboxEmail.ts): `src/sandbox/publishSandboxEmail.ts`
- [WhatsApp publisher](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/sandbox/publishSandboxWhatsApp.ts): `src/sandbox/publishSandboxWhatsApp.ts`
- [Execution results](https://github.com/vasanthgeethanraju/sf-penya-agent/blob/main/src/sandbox/sandboxTypes.ts): `src/sandbox/sandboxTypes.ts`

### Other components

- **Match-day operator**
- **Human approver**

## Connections

- Match-day operator → Package runner: starts run (evidence: `README.md`)
- Package runner → Content agent: requests content (evidence: `src/index.ts`)
- Content agent → Context coordinator: gets context (evidence: `src/agent.ts`)
- Content agent → System prompt: uses prompt (evidence: `src/agent.ts`)
- Content agent → Content schema: validates output (evidence: `src/agent.ts`)
- Context coordinator → Next match lookup: fetches match (evidence: `src/tools/getMatchContext.ts`)
- Context coordinator → Weather lookup: fetches weather (evidence: `src/tools/getMatchContext.ts`)
- Context coordinator → SF events lookup: fetches events (evidence: `src/tools/getMatchContext.ts`)
- Context coordinator → Event relevance filter: filters events (evidence: `src/tools/getMatchContext.ts`)
- Context coordinator → Transit alerts: fetches alerts (evidence: `src/tools/getMatchContext.ts`)
- Context coordinator → Transit relevance filter: filters alerts (evidence: `src/tools/getMatchContext.ts`)
- Next match lookup → Official schedule: uses schedule (evidence: `src/tools/getNextBarcaMatch.ts`)
- Package runner → Poster configuration: builds config (evidence: `src/index.ts`)
- Package runner → Poster prompt: builds prompt (evidence: `src/index.ts`)
- Package runner → Poster image generation: generates image (evidence: `src/index.ts`)
- Package runner → Poster upload: uploads poster (evidence: `src/index.ts`)
- Package runner → Approval package: creates package (evidence: `src/index.ts`)
- Approval package → Approval storage: saves package (evidence: `src/approval/createApprovalPackage.ts`)
- Package runner → Approval email builder: builds email (evidence: `src/index.ts`)
- Package runner → Approval email sender: sends email (evidence: `src/index.ts`)
- Approval email sender → Gmail authentication: gets credentials (evidence: `src/email/sendApprovalEmail.ts`)
- Human approver → Approval server: approves or rejects (evidence: `README.md`)
- Approval server → Approval storage: loads and updates (evidence: `src/server.ts`)
- Approval server → Sandbox dispatcher: dispatches approved (evidence: `src/server.ts`)
- Sandbox dispatcher → Instagram publisher: publishes post (evidence: `src/sandbox/publishSandboxPackage.ts`)
- Sandbox dispatcher → Sandbox email publisher: sends email (evidence: `src/sandbox/publishSandboxPackage.ts`)
- Sandbox dispatcher → WhatsApp publisher: sends message (evidence: `src/sandbox/publishSandboxPackage.ts`)
- Sandbox dispatcher → Execution results: records results (evidence: `src/sandbox/publishSandboxPackage.ts`)
