events
Status: implemented (cmd/events, tests). Runs in the apps profile of docker-compose.yml on port 8086
(Google Calendar not configured there, so the fake calendar is used). Reached through the gateway thanks to the
compose GATEWAY_ROUTES entries /v1/events, /v1/public/events and /v1/public/calendar; the gateway
built-in default routes do not include them. The gateway matches whole path segments, so
/v1/public/calendar/<token>.ics is routed but /v1/public/calendar.ics is not (503 upstream_unavailable
through the gateway; reachable directly on port 8086). The gateway caches the public responses
(PUBLIC_CACHE_TTL); token feeds are private, no-store and never cached. See
Not implemented.
Role: the association calendar: events and machine/room bookings, public or private, optionally linked to a site, a project and inventory items. It serves the public planning of the main page, a public ICS feed, revocable per-user ICS feeds, and pushes public events to a Google calendar.
Limits: no approval, no conflict detection (overlaps are allowed), no registrations, attendance or capacity; invitations only control visibility (no notification, no RSVP). Items are referenced by ID only; booking a machine does not change its inventory status.
Model and rules
- Event: title, description,
starts_at,ends_at,all_day,timezone(defaultDEFAULT_TIMEZONE),site_id,location(free text),item_ids(max 50),project_id,visibility(public|private),external_guests_allowed,recurrence(RFC 5545rrule+exdates, max 500),created_by,invitees(user_ids,role_ids,project_role_ids),invite_read_private_holders,show_as_busy. Max duration of one occurrence: 92 days. Aggregateevent, current state incalendar_eventswithfirst_start/last_endbounds (null for infinite series) used to select candidates. - Validation:
site_idmust be a slug andproject_id/item_idsULIDs; their existence is not checked (authz only sees the site and project ARNs as parents).visibilitydefaults toprivate. Invitees:user_idsare Keycloak UUIDs (lower-cased, max 500),role_ids/project_role_idsULIDs (max 50 each); roles are not checked for existence. - Visibility (one rule,
event.Access.Level, mirrored by the MongoDB filter): public events are readable by anyone. A private event shows its details to its creator, to managers (events.event.updateon the event scope,events.event.manage_allin admin mode), to invited users, to members of an invited global or project role, and, wheninvite_read_private_holdersis set, to holders ofevents.event.read_privateon the event scope. Being authenticated is not enough. Others get 404, unlessshow_as_busyis set: they then see a redacted event (busy: true, title "Réservé", no description, creator, project nor invitees; slot, site, location and items kept), inGET /v1/events/:id, lists, occurrences, the public API and the ICS feeds (SUMMARY:Réservé,CLASS:CONFIDENTIAL, noDESCRIPTION). Busy readers cannot update or delete (403). Role membership comes from authzSubjectRoles(assignments, Keycloak-synced roles and the default user role; an API key only has its own roles), fetched once per request. Events stored before invitations have noinvite_read_private_holdersfield: it is read astrueand written astrueon their next update, so their previous visibility is kept. - Writes: creation needs
events.event.createon the event ARN. Update and delete are allowed to the creator, else needevents.event.update/delete, withevents.event.manage_all(elevated) as fallback. Moving an event to another site or project also needsevents.event.createthere. - Optimistic concurrency:
PATCHtakes an optionalversion(body, or theIf-Matchheader when the body has none),DELETEan optionalIf-Match(3,"3",W/"3") or?version=. When given and different from the current version the write fails with 409version_conflict(checked after the permission checks); a malformed value is 400invalid_version. Without a version the last write wins (backward compatible). A race between the check and the save still fails with 409concurrent_modification. The web client always sends the version it loaded, and on 409 reloads the event and shows a message. - Windows:
from/toare RFC 3339;fromdefaults to now andtotofrom+ 5 days. Max span 62 days for the public API, 366 days when authenticated. Occurrence pages are cursor paginated. - ICS feeds: from 31 days ago to 12 months ahead. The token feed is evaluated as its owner: the service signs a short-lived user principal (no admin mode, no step-up) so authz applies the owner's scopes and roles.
- Calendar tokens: 256 random bits (base64url, shown once), only the SHA-256 hash is stored; one token per user, issuing a new one revokes the previous one.
- Member erasure: on
members.member.erasedthe member's calendar token is revoked and the member is removed frominvitees.user_idsof every live event (anevents.event.updatewithfields: [invitees], details not re-validated so legacy data never blocks it).created_bykeeps the Keycloak ID: events store no name or email, only opaque IDs. Idempotent; failures are retried by the consumer. - Deletion: soft delete; the state is purged after
EVENT_PURGE_DELAYby a lease job (events-purge, everyEVENT_PURGE_INTERVAL, one replica), the event log is kept.
ARNs: atl:events:<site>:event/<id> (parents atl:settings:<site>:site/<site> and, when linked,
atl:projects:<site>:project/<id>), atl:events:*:calendar/* (resync), atl:events:*:calendar_token/<user> (audit).
Google Calendar
A consumer (group events-gcal) reads events.event.v1 and syncs the event: public and live → insert/update
(Google event ID derived from the event ID, last pushed version stored), otherwise → removed from Google. Failures
are retried by the consumer then sent to events.event.v1.dlq; a lease job (events-gcal-reconcile, every
GOOGLE_RECONCILE_INTERVAL) reconciles every public and every mapped event. Without GOOGLE_SA_JSON_FILE and
GOOGLE_CALENDAR_ID a fake calendar logs the calls (refused in production). Private events, including those
shown as busy, are never pushed.
Dependencies
- Services: authz (ConnectRPC
Check,LookupResources,SubjectRolesthroughauthzclient). - Infrastructure: MongoDB (replica set, transactions), Kafka, Google Calendar API (service account).
- Libraries:
authzclient,httpx,principal(verifier + signer),pagination,problem,eventstore,outbox,audit,cloudevent,kafkax,lease,mongox,telemetry,logging,config. See libraries.
Inputs and outputs
OpenAPI: API reference (services/events/openapi.yaml).
| Method | Path | Auth / permission |
|---|---|---|
| GET | /v1/public/events?from&to | anonymous; public occurrences and busy private ones (busy: true), Cache-Control: public, max-age=60 |
| GET | /v1/public/calendar.ics | anonymous; public events and busy private ones |
| GET | /v1/public/calendar/<token>.ics | token; events readable by the token owner, private, no-store |
| GET | /v1/events?site&project&mine | authenticated; filtered by visibility rules (paginated events, not occurrences) |
| POST | /v1/events | events.event.create |
| GET | /v1/events/occurrences?from&to&site&project&mine | authenticated; filtered by visibility rules |
| GET | /v1/events/:id | visibility rules |
| PATCH, DELETE | /v1/events/:id | creator, or events.event.update / delete, or events.event.manage_all |
| GET, POST, DELETE | /v1/events/me/calendar-token | a user, or a user-owned API key (403 otherwise) |
| POST | /v1/events/calendar/resync | events.calendar.manage (synchronous Google reconciliation) |
| Kind | Name | Notes |
|---|---|---|
| RPC out | authz.v1.AuthzService/Check, LookupResources, SubjectRoles | permission checks, read_private / update scopes, role membership for invitations |
| HTTP out | Google Calendar API | public events only |
| Kafka out | events.event.v1 | created (details, creator), updated (patched field names + details), deleted (visibility, purge date) |
| Kafka out | audit.records.v1 | events.event.create/update/delete/purge, events.calendar_token.issue/revoke, events.google.push/remove |
| Kafka in | events.event.v1 | own events → Google Calendar sync (group events-gcal) |
| Kafka in | members.member.v1 | members.member.erased (subject = member ID, else data.id; other fields ignored) → token revocation and invitee removal (group events-erasure) |
| Kafka out | events.event.v1.dlq | Google sync failures after 5 attempts |
The public web pages (main page planning, /events) read GET /v1/public/events; no web screen uses the
authenticated API yet (/app/events is a "coming soon" placeholder).
See CQRS and Kafka for the outbox and event envelope.
Data (MongoDB events)
| Collection | Key fields | Indexes |
|---|---|---|
calendar_events | event state, version, first_start, last_end, deleted_at, purge_at | partial purge_at; (visibility, first_start); site_id, project_id, created_by (each with first_start and with _id); show_as_busy, invitees.user_ids, invitees.role_ids, invitees.project_role_ids (each with first_start); last_end; (deleted_at, _id) |
calendar_tokens | _id = user ID, hash, created_at | unique hash |
google_events | _id = event ID, google_id, version, synced_at | — |
events | event log | eventstore indexes |
outbox, locks | pending Kafka messages, lease jobs | — |
Not implemented
item_ids,project_idandsite_idare not checked against inventory, projects or settings; booking a machine does not change its inventory status.- Soft-deleted events (awaiting purge) and the event log keep an erased member's ID in
invitees.user_idsandcreated_by(opaque IDs, no PII). events.event.readis declared in the catalogue (and gates the/app/eventsmenu in the web app) but the service never checks it: public events are readable anonymously, private ones through the visibility rule.- No compose gateway route for the public ICS feed
/v1/public/calendar.ics(see the status above). - No internal web screens (create / edit events, calendar token management).
Configuration
| Variable | Default | Description |
|---|---|---|
HTTP_ADDR | :8086 | Listen address |
METRICS_ADDR | :9186 | Prometheus listener |
PRINCIPAL_PUBLIC_KEY | required | Verifies X-Atl-Principal |
PRINCIPAL_SIGNING_KEY | required | Signs the owner principal of tokenised feeds |
AUTHZ_URL | http://localhost:8081 | authz ConnectRPC endpoint |
KAFKA_BROKERS | localhost:19092 | Outbox relay, Google sync and member erasure consumers |
MONGO_URI, MONGO_DATABASE | mongodb://localhost:27017/?directConnection=true, events | MongoDB |
EVENTS_PUBLIC_URL | http://localhost:8080 | Absolute API base URL of feed links; its host is the ICS UID domain |
DEFAULT_TIMEZONE | Europe/Paris | Default event time zone (validated) |
EVENTS_CALENDAR_NAME | Atelier | ICS calendar name ((personnel) appended for token feeds) |
EVENT_PURGE_DELAY | 720h (30 days) | Soft delete → purge delay |
EVENT_PURGE_INTERVAL | 1h | Purge job period |
GOOGLE_SA_JSON_FILE, GOOGLE_CALENDAR_ID | empty | Google service account and target calendar; required in production |
GOOGLE_RECONCILE_INTERVAL | 30m | Full reconciliation period |
Plus the common APP_ENV, LOG_LEVEL, OTEL_EXPORTER_OTLP_ENDPOINT (see
environment variables).