Skip to content
TrackLinesPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Tracklines backend

The Tracklines HTTP API: projects, boards, columns, tickets, backlog, sprints, roadmaps, comments, attachments, billing, invitations and the public roadmap/intake endpoints. It also serves the MCP endpoint and the webhooks for Clerk, Stripe and the Git integrations.

Go HTTP service backed by PostgreSQL 18 and Valkey. Clerk for auth, Stripe for subscriptions, Bugfixes for error reporting, Flags.gg for feature flags.

Organization onboarding (TL-705)

Human members use GET /api/onboarding for their guide and permitted chapters. Org admins use POST /api/onboarding/setup to atomically create a project/board or adopt an imported board, and POST /api/onboarding/finish after optional invitations. Existing organizations skip setup. Project creation shares the plan limit lock with normal creation and imports, and retries return the same saved board.

POST /api/onboarding/guide/complete separately records user, organization, guide ID/version and completion time. Publish a new GuideVersion in internal/onboarding/onboarding.go only with matching frontend guide content for new features. Routine releases never reset completion. Migration 106 adds the two tables; user removal and organization purge clean up these records. POST /api/onboarding/guide/reset with the matching org_id resets only the caller's guide in that organization. It never resets organization setup or someone else's progress. Chapters follow actual action permissions: members can create projects within their plan, add tickets, and use their personal TUI/MCP keys; only admins get the GitHub connection chapter.

Run it

go run ./cmd/server        # serve the API
go test ./...              # full suite (uses testcontainers; needs Docker)
go vet ./...

Or bring up the whole stack (API, frontend, Postgres, Valkey) from the repo root with docker compose up --build. The API listens on 8080 locally (HTTP_PORT, or Railway's injected PORT). Migrations run automatically before it serves, so a fresh database is fine.

Layout

  • cmd/server/main.go — wires dependencies and starts the service; also runs the Railway cron jobs (purge, sweep-files).
  • internal/service.go — every route is declared here via Handler(), with its auth layer (optional / required / signedIn / sessionRequired / public).
  • internal/<pkg>/ — one package per domain (boards, tickets, roadmaps, billing, embed, intake, mcp, …). HTTP helpers in httpx, auth in auth, config in config.
  • internal/migrations/NNNNNN_name.{up,down}.sql — schema migrations, applied in order.

Config

Read via keloran/go-config from the environment — never hand-rolled parsing. Key vars:

Var Purpose
RDS_URL PostgreSQL connection
VALKEY_URL Valkey (live views + caching; API still runs without it)
CLERK_*, CLERK_WEBHOOK_SECRET, CLERK_AUTHORIZED_PARTIES authentication
STRIPE_*, STRIPE_WEBHOOK_SECRET billing
TRACKLINES_SECRET_KEY sealing integration secrets
FLAGS_* Flags.gg project/agent/environment IDs
PUBLIC_API_URL, PORTAL_URL public base URLs
GITHUB_*, BITBUCKET_* Git integration apps
BUGFIXES_* error reporting

Providers can be left unset for local scaffolding; the SDKs no-op and feature flags return false.

Tests

Every feature is tested, including org/admin scoping. Integration tests spin up Postgres and Valkey via testcontainers (internal/testdb, TEST_DATABASE_URL), so Docker must be running. go test ./... runs the whole suite — don't ship with it red.

MCP

The API serves MCP at /mcp (Streamable HTTP, stateless). Auth is the same as REST: Authorization: Bearer tl_… (an API key) or a Clerk session token. Each tool calls a REST route in-process, so permissions, validation and errors match REST exactly (internal/mcp).

On connecting, a client is told the global pre-prompt (staff publish versions; GET /api/mcp/prompts), then, under a heading, the additional instructions of the organization it authenticated as, if its admins saved any (GET/PUT /api/org/mcp-instructions: signed-in admins, never API keys, up to 4,000 characters; TL-899, TL-900). The organization is always the key's or the session's active one, never one the client names. An organization with none gets exactly the global pre-prompt, as does a session whose additions can't be read. They add to the workflow only: permissions and validation are still the REST handlers'. They are read on each connection and not cached, so a save or clear applies to the next one; a client that keeps the instructions from its first initialize needs to reconnect to pick up a change. /mcp is the only MCP server: there is no stdio one in this repository.

Incoming flags.gg webhooks (TL-789)

After connecting flags.gg, create a company webhook there for flag.created, flag.state_changed, and flag.archived. Use the API's public base URL plus the webhook_path returned by GET /api/integrations/flags as its destination. An organization admin saves the once-shown signing secret with PUT /api/integrations/flags/webhook and JSON {"secret":"whsec_…"}. The secret is encrypted, bound to that organization, and never returned. An empty secret disables the receiver; disconnecting flags.gg removes it.

The receiver verifies the HMAC and a five-minute timestamp window. Event IDs, per-environment state, and ticket activity are committed together. Duplicate and older events are acknowledged without applying them again. Unknown tickets and agents outside the connected organization are ignored. Optional project_name, agent_name, and environment_name are saved with the activity; history uses the environment name when supplied and falls back to its ID for older events. Ticket flag panels still read flags.gg for current environment details and targeting rules. Configure the webhook after deploying the backend migration.

API docs

The full HTTP API is in openapi.yaml.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages