# openslides/openslides-vote-service architecture

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

- Interactive diagram: https://gitdiagram.com/openslides/openslides-vote-service
- Repository: https://github.com/openslides/openslides-vote-service

## Overview

OpenSlides Vote Service accepts authenticated and internal HTTP requests to manage polls, accept and validate ballots, and report voting status and counts. The main runtime wires the HTTP server, vote domain service, datastore flow, and fast/long vote backends. The README documents poll start, vote, stop, clear, clear-all, “Have I Voted,” and streaming vote counts; these are represented as capabilities of the HTTP and vote-service components. Source excerpts are partial, so uncertain datastore and messaging internals are not expanded.

Main entry points: [`vote/vote.go`](https://github.com/openslides/openslides-vote-service/blob/main/vote/vote.go) (Vote service), [`vote/http/http.go`](https://github.com/openslides/openslides-vote-service/blob/main/vote/http/http.go) (HTTP server and routes), [`main.go`](https://github.com/openslides/openslides-vote-service/blob/main/main.go) (Service runtime), [`backend/backend.go`](https://github.com/openslides/openslides-vote-service/blob/main/backend/backend.go) (Backend selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_http["HTTP server and routes<br/>[http.go]"]
  node_http_errors["HTTP error mapping<br/>[error.go]"]
end

subgraph group_domain["Vote Domain"]
  node_vote_service["Vote service<br/>[vote.go]"]
  node_ballots["Ballot validation<br/>[vote.go]"]
  node_poll_lifecycle["Poll lifecycle<br/>[vote.go]"]
  node_vote_status["Voted status<br/>[vote.go]"]
  node_vote_counts["Vote count stream<br/>[http.go]"]
end

subgraph group_storage["Vote Storage"]
  node_backend_builder["Backend selection<br/>[backend.go]"]
  node_fast_backend["Fast vote backend<br/>[redis.go]"]
  node_memory_backend["Memory backend<br/>[memory.go]"]
  node_long_backend["Long vote backend<br/>[postgres.go]"]
end

subgraph group_integration["Platform Integration"]
  node_main["Service runtime<br/>[main.go]"]
  node_auth["Token authentication"]
  node_datastore_flow["Datastore flow and cache<br/>[flow.go]"]
  node_message_bus["Redis message bus"]
end

node_client(("OpenSlides clients"))
node_platform_datastore["OpenSlides datastore"]
node_redis_store[("Redis vote state")]
node_postgres_store[("PostgreSQL vote data")]

node_client -->|"sends requests"| node_http
node_main -->|"starts server"| node_http
node_main -->|"initializes flow"| node_datastore_flow
node_main -->|"builds backends"| node_backend_builder
node_main -->|"starts service"| node_vote_service
node_main -->|"creates bus"| node_message_bus
node_http -->|"maps errors"| node_http_errors
node_http -->|"authenticates"| node_auth
node_http -->|"dispatches operations"| node_vote_service
node_vote_service -->|"validates ballots"| node_ballots
node_vote_service -->|"manages polls"| node_poll_lifecycle
node_vote_service -->|"checks voter status"| node_vote_status
node_http -->|"streams counts"| node_vote_counts
node_vote_counts -->|"reads live votes"| node_vote_service
node_vote_service -->|"fetches poll and user data"| node_datastore_flow
node_vote_service -->|"stores fast votes"| node_fast_backend
node_vote_service -->|"stores long votes"| node_long_backend
node_backend_builder -->|"selects default"| node_fast_backend
node_backend_builder -.->|"selects single-instance"| node_memory_backend
node_backend_builder -->|"creates backend"| node_long_backend
node_fast_backend -->|"reads and writes"| node_redis_store
node_memory_backend -.->|"holds in memory"| node_vote_service
node_long_backend -->|"reads and writes"| node_postgres_store
node_datastore_flow -->|"fetches datastore data"| node_platform_datastore
node_datastore_flow -->|"uses updates"| node_message_bus

click node_main "https://github.com/openslides/openslides-vote-service/blob/main/main.go"
click node_http "https://github.com/openslides/openslides-vote-service/blob/main/vote/http/http.go"
click node_http_errors "https://github.com/openslides/openslides-vote-service/blob/main/vote/http/error.go"
click node_vote_service "https://github.com/openslides/openslides-vote-service/blob/main/vote/vote.go"
click node_ballots "https://github.com/openslides/openslides-vote-service/blob/main/vote/vote.go"
click node_poll_lifecycle "https://github.com/openslides/openslides-vote-service/blob/main/vote/vote.go"
click node_vote_status "https://github.com/openslides/openslides-vote-service/blob/main/vote/vote.go"
click node_vote_counts "https://github.com/openslides/openslides-vote-service/blob/main/vote/http/http.go"
click node_backend_builder "https://github.com/openslides/openslides-vote-service/blob/main/backend/backend.go"
click node_fast_backend "https://github.com/openslides/openslides-vote-service/blob/main/backend/redis/redis.go"
click node_memory_backend "https://github.com/openslides/openslides-vote-service/blob/main/backend/memory/memory.go"
click node_long_backend "https://github.com/openslides/openslides-vote-service/blob/main/backend/postgres/postgres.go"
click node_datastore_flow "https://github.com/openslides/openslides-vote-service/blob/main/vote/flow.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_http_errors,node_client toneBlue
class node_vote_service,node_ballots,node_poll_lifecycle,node_vote_status,node_vote_counts,node_redis_store,node_postgres_store toneAmber
class node_backend_builder,node_fast_backend,node_memory_backend,node_long_backend toneMint
class node_main,node_auth,node_datastore_flow,node_message_bus toneRose
class node_platform_datastore toneIndigo
```

## Components

### HTTP API

- [HTTP server and routes](https://github.com/openslides/openslides-vote-service/blob/main/vote/http/http.go): `vote/http/http.go`
- [HTTP error mapping](https://github.com/openslides/openslides-vote-service/blob/main/vote/http/error.go): `vote/http/error.go`

### Vote Domain

- [Vote service](https://github.com/openslides/openslides-vote-service/blob/main/vote/vote.go): `vote/vote.go`
- [Ballot validation](https://github.com/openslides/openslides-vote-service/blob/main/vote/vote.go): `vote/vote.go`
- [Poll lifecycle](https://github.com/openslides/openslides-vote-service/blob/main/vote/vote.go): `vote/vote.go`
- [Voted status](https://github.com/openslides/openslides-vote-service/blob/main/vote/vote.go): `vote/vote.go`
- [Vote count stream](https://github.com/openslides/openslides-vote-service/blob/main/vote/http/http.go): `vote/http/http.go`

### Vote Storage

- [Backend selection](https://github.com/openslides/openslides-vote-service/blob/main/backend/backend.go): `backend/backend.go`
- [Fast vote backend](https://github.com/openslides/openslides-vote-service/blob/main/backend/redis/redis.go): `backend/redis/redis.go`
- [Memory backend](https://github.com/openslides/openslides-vote-service/blob/main/backend/memory/memory.go): `backend/memory/memory.go`
- [Long vote backend](https://github.com/openslides/openslides-vote-service/blob/main/backend/postgres/postgres.go): `backend/postgres/postgres.go`

### Platform Integration

- [Service runtime](https://github.com/openslides/openslides-vote-service/blob/main/main.go): `main.go`
- **Token authentication**
- [Datastore flow and cache](https://github.com/openslides/openslides-vote-service/blob/main/vote/flow.go): `vote/flow.go`
- **Redis message bus**

### Other components

- **OpenSlides clients**
- **OpenSlides datastore**
- **Redis vote state**
- **PostgreSQL vote data**

## Connections

- OpenSlides clients → HTTP server and routes: sends requests
- Service runtime → HTTP server and routes: starts server
- Service runtime → Datastore flow and cache: initializes flow
- Service runtime → Backend selection: builds backends
- Service runtime → Vote service: starts service
- Service runtime → Redis message bus: creates bus
- HTTP server and routes → HTTP error mapping: maps errors
- HTTP server and routes → Token authentication: authenticates
- HTTP server and routes → Vote service: dispatches operations
- Vote service → Ballot validation: validates ballots
- Vote service → Poll lifecycle: manages polls
- Vote service → Voted status: checks voter status
- HTTP server and routes → Vote count stream: streams counts
- Vote count stream → Vote service: reads live votes
- Vote service → Datastore flow and cache: fetches poll and user data
- Vote service → Fast vote backend: stores fast votes
- Vote service → Long vote backend: stores long votes
- Backend selection → Fast vote backend: selects default
- Backend selection → Memory backend: selects single-instance
- Backend selection → Long vote backend: creates backend
- Fast vote backend → Redis vote state: reads and writes
- Memory backend → Vote service: holds in memory
- Long vote backend → PostgreSQL vote data: reads and writes
- Datastore flow and cache → OpenSlides datastore: fetches datastore data
- Datastore flow and cache → Redis message bus: uses updates
