This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
OCAP2-Web is a Go-based web server for the Operation Capture And Playback system. It archives and replays Arma 3 military simulation missions, rendering unit positions, movements, and combat events on interactive Leaflet maps.
# Build (Linux)
go build -o ocap-webserver ./cmd/ocap-webserver
# Build (Windows)
go build -o ocap-webserver.exe ./cmd/ocap-webserver
# Run tests
go test ./...
# Run single test
go test -run TestName ./internal/server
# Regenerate protobuf schemas
go generate ./pkg/schemas/...
# Docker build
docker build -t ocap-webserver .Entry point: cmd/ocap-webserver/main.go initializes repositories and starts the Echo server.
Core packages in internal/:
server/- HTTP endpoints, repositories (operation, marker, ammo), configurationstorage/- Storage engines (JSON, Protobuf)conversion/- Background format conversion worker
Public packages in pkg/schemas/:
protobuf/- Protocol Buffers schema (ocap.proto) and generated Go code
Each schema package has a generate.go with //go:generate directives. Run go generate ./pkg/schemas/... after modifying .proto files.
API Endpoints (all under configurable prefixURL, default /):
GET /api/healthcheck- Health check (used by Docker HEALTHCHECK)GET /api/v1/operations- Query missions with filtersPOST /api/v1/operations/add- Upload mission (requiressecret)GET /api/v1/customize- UI customization settingsGET /api/version- Build infoGET /data/:name- Stream mission data (gzipped JSON)GET /file/:name- Download mission as attachmentGET /images/markers/:name/:color- Generate colored markerGET /images/markers/magicons/:name- Equipment iconsGET /images/maps/*- Map tiles
Static SPA in static/ using Leaflet for map rendering. No build step required.
Key files in static/scripts/:
ocap.js- Main app, map init, playback engineocap.ui.js- UI panels (unit list, events, timeline)ocap.event.js- Mission event handlingocap.marker.js- Unit/vehicle marker renderingocap.entity.js- Base entity classlocalizable.js- i18n support
- SQLite database - Mission metadata (default
data.db, configure viaOCAP_DB) - Mission files - Gzipped JSON (default
data/, configure viaOCAP_DATA) - Map tiles - Downloaded separately (default
maps/, configure viaOCAP_MAPS) - Assets -
assets/markers/andassets/ammo/contain mod-specific icons
Settings loaded via Viper with priority: environment variables → config files → defaults.
Config file: setting.json
{
"listen": "127.0.0.1:5000",
"prefixURL": "/",
"secret": "same-secret",
"logger": true
}Environment variables (prefix OCAP_):
OCAP_LISTEN,OCAP_SECRET,OCAP_PREFIXURLOCAP_DB,OCAP_DATA,OCAP_MAPS,OCAP_MARKERS,OCAP_AMMO,OCAP_STATICOCAP_CUSTOMIZE_WEBSITEURL,OCAP_CUSTOMIZE_WEBSITELOGO
A Pelican egg (egg-ocap2-web.json) is provided for deploying in Pelican Panel. The Docker image includes a dual-mode entrypoint (docker/entrypoint.sh) that detects Pelican/Wings via the STARTUP env var and processes variable substitution, falling back to direct execution for standalone Docker.
- Path traversal protection via
paramPath()usingfilepath.Clean()validation - Marker colors: predefined names (blufor, opfor, ind, civ, dead, hit) or hex codes
- Cache control: 7 days for assets, no-cache for HTML
- Build metadata injected via ldflags:
BuildCommit,BuildDate