# hemanth354/relay_campaign_service architecture

> Architecture diagram of the GitHub repository hemanth354/relay_campaign_service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hemanth354/relay_campaign_service
- Repository: https://github.com/hemanth354/relay_campaign_service

## Overview

The repository’s main product is an in-memory campaign-events HTTP service: clients submit event batches, the service rejects invalid records and deduplicates accepted events, then exposes campaign statistics and paginated event history. A separate command-line debugging program processes JSONL input and prints deterministic per-campaign summaries. The sampled service code supports the API, validation, aggregation, and concurrency-safe storage links shown here; the debugging program is also sampled. The README documents these capabilities, but no external database or provider integration is shown.

Main entry points: [`starter/main.go`](https://github.com/hemanth354/relay_campaign_service/blob/main/starter/main.go) (HTTP Server and Handlers), [`debugging/main.go`](https://github.com/hemanth354/relay_campaign_service/blob/main/debugging/main.go) (Batch Processing), [`starter/store.go`](https://github.com/hemanth354/relay_campaign_service/blob/main/starter/store.go) (Memory Store), [`starter/types.go`](https://github.com/hemanth354/relay_campaign_service/blob/main/starter/types.go) (Campaign Event Model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_http["HTTP Server and Handlers<br/>[main.go]"]
end

subgraph group_domain["Event Data and Storage"]
  node_event["Campaign Event Model<br/>[types.go]"]
  node_validation["Event Validation<br/>[types.go]"]
  node_store[("Memory Store<br/>[store.go]")]
  node_aggregation["Campaign Statistics<br/>[store.go]"]
  node_history["Paginated Event History<br/>[store.go]"]
end

subgraph group_debug["Debugging Utility"]
  node_debug_input["JSONL Input<br/>[main.go]"]
  node_batch["Batch Processing<br/>[main.go]"]
  node_dedupe["Event Deduplication<br/>[main.go]"]
  node_tracking["Unique and Daily Tracking<br/>[main.go]"]
  node_workers["Concurrent Counter Updates<br/>[main.go]"]
  node_report["Sorted Summary Output<br/>[main.go]"]
end

node_client(("API Client"))

node_client -->|"submits events"| node_http
node_http -->|"decodes events"| node_event
node_http -->|"validates events"| node_validation
node_http -->|"ingests valid events"| node_store
node_http -->|"requests statistics"| node_store
node_http -->|"requests event page"| node_store
node_store -->|"computes rates"| node_aggregation
node_store -->|"pages campaign events"| node_history
node_http -->|"returns API results"| node_client
node_debug_input -->|"reads event lines"| node_batch
node_batch -->|"deduplicates batches"| node_dedupe
node_batch -->|"tracks unique opens"| node_tracking
node_batch -->|"dispatches counters"| node_workers
node_batch -->|"prints report"| node_report
node_dedupe -->|"tracks accepted events"| node_tracking
node_workers -->|"provides counters"| node_report

click node_http "https://github.com/hemanth354/relay_campaign_service/blob/main/starter/main.go"
click node_event "https://github.com/hemanth354/relay_campaign_service/blob/main/starter/types.go"
click node_validation "https://github.com/hemanth354/relay_campaign_service/blob/main/starter/types.go"
click node_store "https://github.com/hemanth354/relay_campaign_service/blob/main/starter/store.go"
click node_aggregation "https://github.com/hemanth354/relay_campaign_service/blob/main/starter/store.go"
click node_history "https://github.com/hemanth354/relay_campaign_service/blob/main/starter/store.go"
click node_debug_input "https://github.com/hemanth354/relay_campaign_service/blob/main/debugging/main.go"
click node_batch "https://github.com/hemanth354/relay_campaign_service/blob/main/debugging/main.go"
click node_dedupe "https://github.com/hemanth354/relay_campaign_service/blob/main/debugging/main.go"
click node_tracking "https://github.com/hemanth354/relay_campaign_service/blob/main/debugging/main.go"
click node_workers "https://github.com/hemanth354/relay_campaign_service/blob/main/debugging/main.go"
click node_report "https://github.com/hemanth354/relay_campaign_service/blob/main/debugging/main.go"

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_http,node_client toneBlue
class node_event,node_validation,node_store,node_aggregation,node_history toneAmber
class node_debug_input,node_batch,node_dedupe,node_tracking,node_workers,node_report toneMint
```

## Components

### HTTP API

- [HTTP Server and Handlers](https://github.com/hemanth354/relay_campaign_service/blob/main/starter/main.go): `starter/main.go`

### Event Data and Storage

- [Campaign Event Model](https://github.com/hemanth354/relay_campaign_service/blob/main/starter/types.go): `starter/types.go`
- [Event Validation](https://github.com/hemanth354/relay_campaign_service/blob/main/starter/types.go): `starter/types.go`
- [Memory Store](https://github.com/hemanth354/relay_campaign_service/blob/main/starter/store.go): `starter/store.go`
- [Campaign Statistics](https://github.com/hemanth354/relay_campaign_service/blob/main/starter/store.go): `starter/store.go`
- [Paginated Event History](https://github.com/hemanth354/relay_campaign_service/blob/main/starter/store.go): `starter/store.go`

### Debugging Utility

- [JSONL Input](https://github.com/hemanth354/relay_campaign_service/blob/main/debugging/main.go): `debugging/main.go`
- [Batch Processing](https://github.com/hemanth354/relay_campaign_service/blob/main/debugging/main.go): `debugging/main.go`
- [Event Deduplication](https://github.com/hemanth354/relay_campaign_service/blob/main/debugging/main.go): `debugging/main.go`
- [Unique and Daily Tracking](https://github.com/hemanth354/relay_campaign_service/blob/main/debugging/main.go): `debugging/main.go`
- [Concurrent Counter Updates](https://github.com/hemanth354/relay_campaign_service/blob/main/debugging/main.go): `debugging/main.go`
- [Sorted Summary Output](https://github.com/hemanth354/relay_campaign_service/blob/main/debugging/main.go): `debugging/main.go`

### Other components

- **API Client**

## Connections

- API Client → HTTP Server and Handlers: submits events (evidence: `README.md`)
- HTTP Server and Handlers → Campaign Event Model: decodes events (evidence: `starter/main.go`)
- HTTP Server and Handlers → Event Validation: validates events (evidence: `starter/main.go`)
- HTTP Server and Handlers → Memory Store: ingests valid events (evidence: `starter/main.go`)
- HTTP Server and Handlers → Memory Store: requests statistics (evidence: `starter/main.go`)
- HTTP Server and Handlers → Memory Store: requests event page (evidence: `starter/main.go`)
- Memory Store → Campaign Statistics: computes rates (evidence: `starter/store.go`)
- Memory Store → Paginated Event History: pages campaign events (evidence: `starter/store.go`)
- HTTP Server and Handlers → API Client: returns API results (evidence: `README.md`)
- JSONL Input → Batch Processing: reads event lines (evidence: `debugging/main.go`)
- Batch Processing → Event Deduplication: deduplicates batches (evidence: `debugging/main.go`)
- Batch Processing → Unique and Daily Tracking: tracks unique opens (evidence: `debugging/main.go`)
- Batch Processing → Concurrent Counter Updates: dispatches counters (evidence: `debugging/main.go`)
- Batch Processing → Sorted Summary Output: prints report (evidence: `debugging/main.go`)
- Event Deduplication → Unique and Daily Tracking: tracks accepted events (evidence: `debugging/main.go`)
- Concurrent Counter Updates → Sorted Summary Output: provides counters (evidence: `debugging/main.go`)
