# 0xfurai/peekaping architecture

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

- Interactive diagram: https://gitdiagram.com/0xfurai/peekaping
- Repository: https://github.com/0xfurai/peekaping

## Overview

1. **This is a multi-app monorepo, not a single service.**  
   The core product is the **Go backend** in `apps/server`, the **React/TypeScript admin UI** in `apps/web`, plus separate **marketing/docs sites** (`apps/landing`, `apps/docs`). Architecture diagrams should treat these as distinct deployable frontends/backends rather than one web app.

2. **The backend is a modular monolith split into multiple runtime binaries.**  
   `apps/server/cmd` contains separate processes for `api`, `producer`, `worker`, `ingester`, and `migrate` (`bun`). These are the primary operational boundaries: one HTTP/API process, one scheduling process, one execution process, one ingestion process, and one migration job.

3. **The `api` process is the system’s control plane.**  
   It serves the REST API, auth/session endpoints, webhooks, status-page endpoints, badges, websocket updates, and the admin surface used by the UI. Most `internal/modules/*` packages expose controller/route/service layers here.

4. **`producer` is the scheduler and coordination layer.**  
   It is responsible for deciding when checks should run, with leader-election support so only one scheduler is active in a clustered setup. It emits work onto the shared queue/event infrastructure rather than executing checks itself.

5. **`worker` is the execution layer for health checks.**  
   The `healthcheck/executor` package contains protocol-specific executors for HTTP, TCP, ping, DNS, gRPC, Docker, databases, MQTT, RabbitMQ, Kafka producer, SNMP, Redis, etc. The worker consumes queued jobs, runs the appropriate executor, and persists results/state.

6. **`ingester` handles externally received monitoring results.**  
   This is a separate entry point and module boundary for ingesting push-style or remote-origin health data. It complements the worker path by accepting results from outside the local execution flow.

7. **Data storage is abstracted behind repository interfaces with multiple backends.**  
   Many domain modules have both `*.sql.repository.go` and `*.mongo.repository.go`, with shared interfaces in `*.repository.go`. The repo supports **SQLite / PostgreSQL / MongoDB** using backend-specific wiring in `internal/infra/sql.go` and `internal/infra/mongo.go`.

8. **Redis is used for coordination/eventing rather than primary persistence.**  
   `internal/infra/redis_event_bus.go` and `internal/infra/queue.go` indicate Redis-backed messaging/queue semantics between the API, producer, worker, and related listeners. This is the main asynchronous boundary in the system.

9. **Domain modules map closely to product features.**  
   The largest modules are `monitor`, `notification_channel`, `status_page`, `maintenance`, `tag`, `proxy`, `heartbeat`, `stats`, `badge`, `api_key`, `auth`, `bruteforce`, `monitor_notification`, `monitor_status_page`, `monitor_tag`, and `monitor_tls_info`. These should appear as business-domain subsystems around the core monitoring pipeline.

10. **Notifications are adapter-based and highly extensible.**  
    `notification_channel/providers` contains many provider implementations such as Slack, Telegram, Discord, WhatsApp, PagerDuty, Opsgenie, SMTP/SendGrid, Webhook, NTFY, Gotify, and others. A registry/sender layer routes alerts to the correct provider, making notifications a pluggable integration boundary.

11. **The UI is a generated-client consumer of the API, with realtime updates.**  
    `apps/web` uses a generated OpenAPI client (`src/api/*`), React Query, and websocket context. Its route structure is split into public auth pages, protected CRUD pages for monitors/channels/status pages/settings, and public status pages for end users.

12. **There are separate public-facing presentation surfaces.**  
    `apps/landing` is the marketing site, while `apps/docs` is Docusaurus documentation. `apps/web/src/app/status/[slug]` is the public status-page view generated from backend state and custom domains.

13. **Security is built into the API boundary.**  
    The backend includes JWT/auth middleware, MFA/2FA, API key management, and brute-force protection. These are not separate services; they are cross-cutting controls around the API and privileged admin flows.

14. **Deployment is designed for multiple topologies.**  
    The repo includes Dockerfiles for bundled single-container modes (`Dockerfile.bundle.*`), separate service images under `apps/server/infra`, Docker Compose files for dev/prod and each database, plus Helm charts in `charts/` for Kubernetes-style deployment. The backend is therefore intended to run either as an all-in-one bundle or as split services.

15. **Testing and fixtures are part of the architecture story.**  
    `e2e/` covers auth and monitor CRUD from the UI side, and `test_utils/` contains protocol-specific harnesses for Kafka, MQTT, MSSQL, RabbitMQ, and Redis. `apps/fake-server` provides mock gRPC/MTLS endpoints for exercising healthcheck executors.

Main entry points: [`apps/server/cmd/api`](https://github.com/0xfurai/peekaping/tree/main/apps/server/cmd/api) (API), [`apps/server/internal/server.go`](https://github.com/0xfurai/peekaping/blob/main/apps/server/internal/server.go) (Server Core), [`apps/server/internal/modules/monitor`](https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/monitor) (Monitor Domain), [`charts`](https://github.com/0xfurai/peekaping/tree/main/charts) (Deployments)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_backend["Backend"]
  node_node_api["API<br/>go binary"]
  node_node_producer["Producer<br/>go binary"]
  node_node_worker["Worker<br/>go binary"]
  node_node_ingester["Ingester<br/>go binary"]
  node_node_migrate["Migrate<br/>job"]
  node_node_server_core["Server Core<br/>bootstrap<br/>[server.go]"]
  node_node_infra["Infra<br/>adapters"]
  node_node_monitor_domain["Monitor Domain<br/>feature module"]
  node_node_notification_domain["Notifications<br/>feature module"]
  node_node_status_domain["Status Pages<br/>feature module"]
  node_node_security_domain["Security<br/>cross-cutting"]
  node_node_ops_domain["Operations<br/>feature module"]
  node_node_healthcheck["Health Checks<br/>execution pipeline"]
  node_node_queue_domain["Queue<br/>coordination module"]
end

subgraph group_group_frontends["Frontends"]
  node_node_api_ui["Admin UI<br/>React app"]
  node_node_landing["Landing<br/>Astro site"]
  node_node_docs["Docs<br/>Docusaurus site"]
end

subgraph group_group_ops["Ops"]
  node_node_deploy["Deployments<br/>manifests"]
end

subgraph group_group_testing["Testing"]
  node_node_fake_server["Fake Server<br/>test harness"]
  node_node_e2e["E2E<br/>ui tests"]
  node_node_protocol_fixtures["Protocol Fixtures<br/>test assets"]
end

node_node_api -->|"boots"| node_node_server_core
node_node_producer -->|"boots"| node_node_server_core
node_node_worker -->|"boots"| node_node_server_core
node_node_ingester -->|"boots"| node_node_server_core
node_node_migrate -->|"boots"| node_node_server_core
node_node_server_core -->|"wires"| node_node_infra
node_node_server_core -->|"includes"| node_node_security_domain
node_node_api -->|"serves"| node_node_monitor_domain
node_node_api -->|"serves"| node_node_notification_domain
node_node_api -->|"serves"| node_node_status_domain
node_node_api -->|"serves"| node_node_ops_domain
node_node_api -->|"publishes"| node_node_queue_domain
node_node_producer -->|"schedules"| node_node_monitor_domain
node_node_producer -->|"enqueues"| node_node_queue_domain
node_node_producer -->|"coordinates"| node_node_infra
node_node_worker -->|"executes"| node_node_healthcheck
node_node_worker -->|"consumes"| node_node_queue_domain
node_node_worker -->|"updates"| node_node_monitor_domain
node_node_ingester -->|"ingests"| node_node_healthcheck
node_node_ingester -->|"updates"| node_node_monitor_domain
node_node_healthcheck -->|"alerts"| node_node_notification_domain
node_node_notification_domain -->|"uses"| node_node_infra
node_node_monitor_domain -->|"stores"| node_node_infra
node_node_status_domain -->|"reflects"| node_node_monitor_domain
node_node_api_ui -->|"consumes"| node_node_api
node_node_api_ui -->|"views"| node_node_status_domain
node_node_api_ui -->|"authenticates"| node_node_security_domain
node_node_landing -.->|"markets"| node_node_api
node_node_docs -.->|"documents"| node_node_api
node_node_deploy -->|"deploys"| node_node_api
node_node_deploy -->|"deploys"| node_node_producer
node_node_deploy -->|"deploys"| node_node_worker
node_node_deploy -->|"deploys"| node_node_ingester
node_node_deploy -->|"deploys"| node_node_migrate
node_node_e2e -->|"tests"| node_node_api_ui
node_node_protocol_fixtures -->|"exercises"| node_node_healthcheck
node_node_fake_server -->|"mocks"| node_node_healthcheck

click node_node_api "https://github.com/0xfurai/peekaping/tree/main/apps/server/cmd/api"
click node_node_producer "https://github.com/0xfurai/peekaping/tree/main/apps/server/cmd/producer"
click node_node_worker "https://github.com/0xfurai/peekaping/tree/main/apps/server/cmd/worker"
click node_node_ingester "https://github.com/0xfurai/peekaping/tree/main/apps/server/cmd/ingester"
click node_node_migrate "https://github.com/0xfurai/peekaping/tree/main/apps/server/cmd/bun"
click node_node_server_core "https://github.com/0xfurai/peekaping/blob/main/apps/server/internal/server.go"
click node_node_infra "https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/infra"
click node_node_monitor_domain "https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/monitor"
click node_node_notification_domain "https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/notification_channel"
click node_node_status_domain "https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/status_page"
click node_node_security_domain "https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/auth"
click node_node_ops_domain "https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/maintenance"
click node_node_healthcheck "https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/healthcheck"
click node_node_queue_domain "https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/queue"
click node_node_api_ui "https://github.com/0xfurai/peekaping/tree/main/apps/web"
click node_node_landing "https://github.com/0xfurai/peekaping/tree/main/apps/landing"
click node_node_docs "https://github.com/0xfurai/peekaping/tree/main/apps/docs"
click node_node_fake_server "https://github.com/0xfurai/peekaping/tree/main/apps/fake-server"
click node_node_deploy "https://github.com/0xfurai/peekaping/tree/main/charts"
click node_node_e2e "https://github.com/0xfurai/peekaping/tree/main/e2e"
click node_node_protocol_fixtures "https://github.com/0xfurai/peekaping/tree/main/test_utils"

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_node_api,node_node_producer,node_node_worker,node_node_ingester,node_node_migrate,node_node_server_core,node_node_infra,node_node_monitor_domain,node_node_notification_domain,node_node_status_domain,node_node_security_domain,node_node_ops_domain,node_node_healthcheck,node_node_queue_domain toneBlue
class node_node_api_ui,node_node_landing,node_node_docs toneAmber
class node_node_deploy toneMint
class node_node_fake_server,node_node_e2e,node_node_protocol_fixtures toneRose
```

## Components

### Backend

Go server, runtime binaries, and core domain modules

- [API](https://github.com/0xfurai/peekaping/tree/main/apps/server/cmd/api): go binary · HTTP control plane for auth, admin CRUD, status pages, badges, websockets, and public endpoints · `apps/server/cmd/api`
- [Producer](https://github.com/0xfurai/peekaping/tree/main/apps/server/cmd/producer): go binary · Scheduler and coordination process with leader election that enqueues check work · `apps/server/cmd/producer`
- [Worker](https://github.com/0xfurai/peekaping/tree/main/apps/server/cmd/worker): go binary · Queued execution process that runs health check executors and persists outcomes · `apps/server/cmd/worker`
- [Ingester](https://github.com/0xfurai/peekaping/tree/main/apps/server/cmd/ingester): go binary · Separate entrypoint for accepting externally pushed monitoring results · `apps/server/cmd/ingester`
- [Migrate](https://github.com/0xfurai/peekaping/tree/main/apps/server/cmd/bun): job · Schema migration job for database bootstrap and upgrades · `apps/server/cmd/bun`
- [Server Core](https://github.com/0xfurai/peekaping/blob/main/apps/server/internal/server.go): bootstrap · Shared runtime wiring, config, logging, and module composition for server processes · `apps/server/internal/server.go`
- [Infra](https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/infra): adapters · SQL, Mongo, Redis event bus, queue, and event helper wiring · `apps/server/internal/infra`
- [Monitor Domain](https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/monitor): feature module · Monitor CRUD, lifecycle state, listeners, and protocol validations · `apps/server/internal/modules/monitor`
- [Notifications](https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/notification_channel): feature module · Notification channels, provider registry, sender, and alert listeners · `apps/server/internal/modules/notification_channel`
- [Status Pages](https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/status_page): feature module · Public status page management, domains, and monitor-to-page mapping · `apps/server/internal/modules/status_page`
- [Security](https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/auth): cross-cutting · Auth, JWT, API keys, brute-force protection, and privileged middleware · `apps/server/internal/modules/auth`
- [Operations](https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/maintenance): feature module · Maintenance windows, tags, proxies, heartbeat, stats, badges, and TLS info · `apps/server/internal/modules/maintenance`
- [Health Checks](https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/healthcheck): execution pipeline · Tick handling, push ingestion path, listeners, and protocol-specific executors · `apps/server/internal/modules/healthcheck`
- [Queue](https://github.com/0xfurai/peekaping/tree/main/apps/server/internal/modules/queue): coordination module · Shared queue abstraction used to move scheduled checks into execution · `apps/server/internal/modules/queue`

### Frontends

Admin UI plus public marketing and docs sites

- [Admin UI](https://github.com/0xfurai/peekaping/tree/main/apps/web): React app · TypeScript admin frontend with generated API client, React Query, and realtime websocket updates · `apps/web`
- [Landing](https://github.com/0xfurai/peekaping/tree/main/apps/landing): Astro site · Marketing and public-facing product site · `apps/landing`
- [Docs](https://github.com/0xfurai/peekaping/tree/main/apps/docs): Docusaurus site · Documentation and architecture reference site · `apps/docs`

### Ops

Deployment manifests, bundles, and runtime topology

- [Deployments](https://github.com/0xfurai/peekaping/tree/main/charts): manifests · Docker bundle modes, compose files, Helm charts, and service images for split or bundled topologies · `charts`

### Testing

End-to-end and protocol fixture assets

- [Fake Server](https://github.com/0xfurai/peekaping/tree/main/apps/fake-server): test harness · Mock gRPC and mTLS endpoints used to exercise executors · `apps/fake-server`
- [E2E](https://github.com/0xfurai/peekaping/tree/main/e2e): ui tests · End-to-end browser tests covering auth and monitor CRUD flows · `e2e`
- [Protocol Fixtures](https://github.com/0xfurai/peekaping/tree/main/test_utils): test assets · Kafka, MQTT, MSSQL, RabbitMQ, and Redis integration fixtures and scripts · `test_utils`

## Connections

- API → Server Core: boots · API process is assembled by shared server bootstrap
- Producer → Server Core: boots · Producer process uses the same shared runtime wiring
- Worker → Server Core: boots · Worker process uses the same shared runtime wiring
- Ingester → Server Core: boots · Ingester process uses the same shared runtime wiring
- Migrate → Server Core: boots · Migration job is launched through shared server tooling
- Server Core → Infra: wires · Shared runtime composes storage, queue, and event adapters
- Server Core → Security: includes · API boundary is wrapped by auth and anti-abuse controls
- API → Monitor Domain: serves · Control plane exposes monitor CRUD and lifecycle endpoints
- API → Notifications: serves · Admin surface manages notification channels and dispatch rules
- API → Status Pages: serves · API manages public status pages and custom domains
- API → Operations: serves · API exposes maintenance, tags, proxies, heartbeat, stats, and badges
- API → Queue: publishes · API and listeners can enqueue asynchronous work
- Producer → Monitor Domain: schedules · Scheduler evaluates monitors and decides when checks should run
- Producer → Queue: enqueues · Scheduler emits work onto the shared queue
- Producer → Infra: coordinates · Leader election and event bus integration are handled through infra
- Worker → Health Checks: executes · Worker runs protocol executors for each queued check
- Worker → Queue: consumes · Worker pulls jobs from the shared queue
- Worker → Monitor Domain: updates · Execution results are persisted back into monitor state
- Ingester → Health Checks: ingests · Push-style monitoring results enter through the ingester boundary
- Ingester → Monitor Domain: updates · Externally received results update monitor state and history
- Health Checks → Notifications: alerts · Failures and state changes flow into alerting and provider delivery
- Notifications → Infra: uses · Notification events rely on shared persistence and event infrastructure
- Monitor Domain → Infra: stores · Monitor data is backed by SQL or Mongo repositories
- Status Pages → Monitor Domain: reflects · Status pages are built from monitor and availability state
- Admin UI → API: consumes · Admin UI uses generated OpenAPI client against the backend API
- Admin UI → Status Pages: views · Public status pages are rendered from backend state
- Admin UI → Security: authenticates · Login, MFA, and API key flows are driven by backend security features
- Landing → API: markets · Marketing site points users toward the product and backend service
- Docs → API: documents · Docs describe backend processes, deployment, and feature boundaries
- Deployments → API: deploys · Charts and bundle images package the API runtime
- Deployments → Producer: deploys · Charts and bundle images package the scheduler runtime
- Deployments → Worker: deploys · Charts and bundle images package the execution runtime
- Deployments → Ingester: deploys · Charts and bundle images package the ingestion runtime
- Deployments → Migrate: deploys · Deployment manifests include migration job execution
- E2E → Admin UI: tests · Browser tests exercise the admin UI flows
- Protocol Fixtures → Health Checks: exercises · Protocol fixtures validate executor behavior across integrations
- Fake Server → Health Checks: mocks · Mock endpoints provide test targets for gRPC and mTLS checks
