# nicklashn/open-golf-tracer architecture

> Architecture diagram of the GitHub repository nicklashn/open-golf-tracer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nicklashn/open-golf-tracer
- Repository: https://github.com/nicklashn/open-golf-tracer

## Overview

Open Golf Tracer is a local-first golf-video editor: users upload footage, the app prepares and analyzes it into editable shot data, then users refine a project and export finished social-video formats. The graph keeps analysis, editing, AI-assisted composition, and rendering/export distinct. Some API and worker relationships are documented in the README or SOURCE INDEX; unsampled implementation details are not expanded into additional call edges.

Main entry points: [`apps/api/golf_api/routes/projects.py`](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/api/golf_api/routes/projects.py) (Projects and uploads API), [`apps/web/src/editor/Editor.tsx`](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/web/src/editor/Editor.tsx) (Video editor), [`apps/worker/golf_worker/tasks.py`](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/worker/golf_worker/tasks.py) (Media preparation), [`shottracer/pipeline.py`](https://github.com/nicklashn/open-golf-tracer/blob/main/shottracer/pipeline.py) (Shot detection and analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web editor"]
  node_web["Web application<br/>[AppRoot.tsx]"]
  node_editor["Video editor<br/>[Editor.tsx]"]
  node_project_schema["Project and timeline model<br/>[project.ts]"]
end

subgraph group_api["API and data"]
  node_project_api["Projects and uploads API<br/>[projects.py]"]
  node_api_app["API application<br/>[main.py]"]
  node_job_queue["Job queue<br/>[jobs.py]"]
  node_database[("Project database<br/>[models.py]")]
  node_media_storage[("Local media storage<br/>[storage.py]")]
  node_map_lookup["Course map lookup<br/>[geo.py]"]
end

subgraph group_analysis["Media analysis"]
  node_worker["Background worker<br/>[main.py]"]
  node_media_ingest["Media preparation<br/>[tasks.py]"]
  node_video_io["Video decoding<br/>[video.py]"]
  node_shot_analysis["Shot detection and analysis<br/>[pipeline.py]"]
  node_ball_detection["Ball detection<br/>[detect.py]"]
  node_physics_fit["Flight physics fitting<br/>[fit.ts]"]
end

subgraph group_compose["Composition"]
  node_ai_compose["AI-assisted composition<br/>[ai.ts]"]
  node_composition_rules["Composition rules and planning<br/>[rules.ts]"]
end

subgraph group_output["Rendering and export"]
  node_render_layers["Graphics and overlays<br/>[layers.ts]"]
  node_export_worker["Export and compose worker<br/>[main.ts]"]
  node_export_api["Export API client<br/>[api.ts]"]
end

node_user(("Local user"))
node_ffmpeg["FFmpeg"]
node_ai_provider["Optional AI provider"]
node_osm["OpenStreetMap services"]

node_user -->|"opens and edits"| node_web
node_web -->|"uploads and manages"| node_project_api
node_project_api -.->|"queues work"| node_job_queue
node_project_api -->|"reads and writes"| node_database
node_project_api -->|"stores media"| node_media_storage
node_api_app -->|"registers routes"| node_project_api
node_worker -->|"claims jobs"| node_job_queue
node_worker -->|"dispatches handlers"| node_media_ingest
node_media_ingest -->|"reads media"| node_media_storage
node_media_ingest -->|"prepares previews"| node_ffmpeg
node_media_ingest -->|"runs analysis"| node_shot_analysis
node_shot_analysis -->|"reads frames"| node_video_io
node_shot_analysis -->|"detects shots"| node_ball_detection
node_worker -->|"records job results"| node_database
node_shot_analysis -->|"produces project data"| node_project_schema
node_project_api -->|"returns project data"| node_editor
node_editor -->|"edits timeline"| node_project_schema
node_editor -.->|"refits flight"| node_physics_fit
node_editor -.->|"requests course features"| node_map_lookup
node_map_lookup -->|"queries course data"| node_osm
node_editor -->|"requests video plan"| node_ai_compose
node_ai_compose -->|"sends round summary"| node_ai_provider
node_ai_compose -->|"uses planning rules"| node_composition_rules
node_export_worker -->|"claims and reports jobs"| node_export_api
node_export_worker -.->|"renders overlays"| node_render_layers
node_export_worker -.->|"encodes video"| node_ffmpeg
node_user -.->|"requests export"| node_export_worker

click node_web "https://github.com/nicklashn/open-golf-tracer/blob/main/apps/web/src/components/app/AppRoot.tsx"
click node_editor "https://github.com/nicklashn/open-golf-tracer/blob/main/apps/web/src/editor/Editor.tsx"
click node_project_api "https://github.com/nicklashn/open-golf-tracer/blob/main/apps/api/golf_api/routes/projects.py"
click node_api_app "https://github.com/nicklashn/open-golf-tracer/blob/main/apps/api/golf_api/main.py"
click node_job_queue "https://github.com/nicklashn/open-golf-tracer/blob/main/apps/api/golf_api/jobs.py"
click node_database "https://github.com/nicklashn/open-golf-tracer/blob/main/apps/api/golf_api/models.py"
click node_media_storage "https://github.com/nicklashn/open-golf-tracer/blob/main/apps/api/golf_api/storage.py"
click node_worker "https://github.com/nicklashn/open-golf-tracer/blob/main/apps/worker/golf_worker/main.py"
click node_media_ingest "https://github.com/nicklashn/open-golf-tracer/blob/main/apps/worker/golf_worker/tasks.py"
click node_video_io "https://github.com/nicklashn/open-golf-tracer/blob/main/shottracer/video.py"
click node_shot_analysis "https://github.com/nicklashn/open-golf-tracer/blob/main/shottracer/pipeline.py"
click node_ball_detection "https://github.com/nicklashn/open-golf-tracer/blob/main/shottracer/detect.py"
click node_physics_fit "https://github.com/nicklashn/open-golf-tracer/blob/main/packages/physics/src/fit.ts"
click node_project_schema "https://github.com/nicklashn/open-golf-tracer/blob/main/packages/schema/src/project.ts"
click node_ai_compose "https://github.com/nicklashn/open-golf-tracer/blob/main/packages/compose/src/ai.ts"
click node_composition_rules "https://github.com/nicklashn/open-golf-tracer/blob/main/packages/compose/src/rules.ts"
click node_map_lookup "https://github.com/nicklashn/open-golf-tracer/blob/main/apps/api/golf_api/routes/geo.py"
click node_render_layers "https://github.com/nicklashn/open-golf-tracer/blob/main/packages/render/src/layers.ts"
click node_export_worker "https://github.com/nicklashn/open-golf-tracer/blob/main/apps/exporter/src/main.ts"
click node_export_api "https://github.com/nicklashn/open-golf-tracer/blob/main/apps/exporter/src/api.ts"

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_web,node_editor,node_project_schema,node_user toneBlue
class node_project_api,node_api_app,node_job_queue,node_database,node_media_storage,node_map_lookup toneAmber
class node_worker,node_media_ingest,node_video_io,node_shot_analysis,node_ball_detection,node_physics_fit toneMint
class node_ai_compose,node_composition_rules toneRose
class node_render_layers,node_export_worker,node_export_api,node_ffmpeg,node_ai_provider,node_osm toneIndigo
```

## Components

### Web editor

- [Web application](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/web/src/components/app/AppRoot.tsx): `apps/web/src/components/app/AppRoot.tsx`
- [Video editor](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/web/src/editor/Editor.tsx): `apps/web/src/editor/Editor.tsx`
- [Project and timeline model](https://github.com/nicklashn/open-golf-tracer/blob/main/packages/schema/src/project.ts): `packages/schema/src/project.ts`

### API and data

- [Projects and uploads API](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/api/golf_api/routes/projects.py): `apps/api/golf_api/routes/projects.py`
- [API application](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/api/golf_api/main.py): `apps/api/golf_api/main.py`
- [Job queue](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/api/golf_api/jobs.py): `apps/api/golf_api/jobs.py`
- [Project database](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/api/golf_api/models.py): `apps/api/golf_api/models.py`
- [Local media storage](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/api/golf_api/storage.py): `apps/api/golf_api/storage.py`
- [Course map lookup](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/api/golf_api/routes/geo.py): `apps/api/golf_api/routes/geo.py`

### Media analysis

- [Background worker](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/worker/golf_worker/main.py): `apps/worker/golf_worker/main.py`
- [Media preparation](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/worker/golf_worker/tasks.py): `apps/worker/golf_worker/tasks.py`
- [Video decoding](https://github.com/nicklashn/open-golf-tracer/blob/main/shottracer/video.py): `shottracer/video.py`
- [Shot detection and analysis](https://github.com/nicklashn/open-golf-tracer/blob/main/shottracer/pipeline.py): `shottracer/pipeline.py`
- [Ball detection](https://github.com/nicklashn/open-golf-tracer/blob/main/shottracer/detect.py): `shottracer/detect.py`
- [Flight physics fitting](https://github.com/nicklashn/open-golf-tracer/blob/main/packages/physics/src/fit.ts): `packages/physics/src/fit.ts`

### Composition

- [AI-assisted composition](https://github.com/nicklashn/open-golf-tracer/blob/main/packages/compose/src/ai.ts): `packages/compose/src/ai.ts`
- [Composition rules and planning](https://github.com/nicklashn/open-golf-tracer/blob/main/packages/compose/src/rules.ts): `packages/compose/src/rules.ts`

### Rendering and export

- [Graphics and overlays](https://github.com/nicklashn/open-golf-tracer/blob/main/packages/render/src/layers.ts): `packages/render/src/layers.ts`
- [Export and compose worker](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/exporter/src/main.ts): `apps/exporter/src/main.ts`
- [Export API client](https://github.com/nicklashn/open-golf-tracer/blob/main/apps/exporter/src/api.ts): `apps/exporter/src/api.ts`

### Other components

- **Local user**
- **FFmpeg**
- **Optional AI provider**
- **OpenStreetMap services**

## Connections

- Local user → Web application: opens and edits
- Web application → Projects and uploads API: uploads and manages
- Projects and uploads API → Job queue: queues work (evidence: `apps/api/golf_api/routes/projects.py`)
- Projects and uploads API → Project database: reads and writes (evidence: `apps/api/golf_api/routes/projects.py`)
- Projects and uploads API → Local media storage: stores media (evidence: `apps/api/golf_api/routes/projects.py`)
- API application → Projects and uploads API: registers routes (evidence: `apps/api/golf_api/main.py`)
- Background worker → Job queue: claims jobs (evidence: `apps/worker/golf_worker/main.py`)
- Background worker → Media preparation: dispatches handlers (evidence: `apps/worker/golf_worker/main.py`)
- Media preparation → Local media storage: reads media (evidence: `apps/worker/golf_worker/tasks.py`)
- Media preparation → FFmpeg: prepares previews (evidence: `apps/worker/golf_worker/tasks.py`)
- Media preparation → Shot detection and analysis: runs analysis (evidence: `apps/worker/golf_worker/tasks.py`)
- Shot detection and analysis → Video decoding: reads frames (evidence: `shottracer/pipeline.py`)
- Shot detection and analysis → Ball detection: detects shots (evidence: `shottracer/pipeline.py`)
- Background worker → Project database: records job results (evidence: `apps/worker/golf_worker/main.py`)
- Shot detection and analysis → Project and timeline model: produces project data
- Projects and uploads API → Video editor: returns project data
- Video editor → Project and timeline model: edits timeline
- Video editor → Flight physics fitting: refits flight
- Video editor → Course map lookup: requests course features
- Course map lookup → OpenStreetMap services: queries course data (evidence: `apps/api/golf_api/routes/geo.py`)
- Video editor → AI-assisted composition: requests video plan
- AI-assisted composition → Optional AI provider: sends round summary
- AI-assisted composition → Composition rules and planning: uses planning rules (evidence: `packages/compose/src/ai.ts`)
- Export and compose worker → Export API client: claims and reports jobs (evidence: `apps/exporter/src/main.ts`)
- Export and compose worker → Graphics and overlays: renders overlays
- Export and compose worker → FFmpeg: encodes video
- Local user → Export and compose worker: requests export
