source-code-portal

module
v0.0.0-...-0c72368 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: Apache-2.0

README

Source Code Portal

CI Release Licence

Source Code Portal (SCP) is an organisational dashboard for GitHub. It groups an organisation's repositories into the products and systems they make up and shows, for every product and every repository, how healthy it is: when it last changed, whether it has a release and a licence, how many issues are open, what it is built with and what it depends on. Commit logs, rendered READMEs and documentation, status badges and a Markdown surface for LLM agents come from the same catalogue.

It is one static Go binary that serves the API and runs the server-rendered web UI (Next.js), kept current by GitHub webhooks and a scheduled sync, and built for organisations from a handful to thousands of repositories.

A product (group) A repository

Features

Products and groups

  • Repositories grouped into products by exact name, prefix, glob, regular expression, topic or a catch-all (catalog.groups), each with a default repository.
  • One card per product with all its repositories, an activity strip and health badges per repository; large products span the width.
  • A group page with every repository, sortable and filterable, and the merged commit log of the whole product.

Organisation

  • Telemetry for the whole catalogue: repositories, active ones, the share with a release and with a licence, open issues, sync state.
  • Activity by the newest commit: active (30 days), recent (6 months), quiet (2 years), dormant and archived.
  • The commit log of the entire organisation, filterable by group and repository, with live updates.

Repositories

  • README and up to 50 Markdown documents under docs/, rendered with syntax highlighting, GitHub alerts and an outline, sanitised once.
  • Images in documents served through the portal's image proxy, so pages stay within a strict Content Security Policy.
  • Technology and dependencies from go.mod, package.json and pom.xml, with links between repositories that use each other.
  • An optional scp.yaml descriptor in the repository: title, owners, lifecycle, tags and links (repository guide).

Badges and integrations

  • SVG badges: /badges/repos/{owner}/{name}/{last-commit,release,license,issues}.svg and /badges/groups/{group}/repos.svg.
  • The JSON API under /api/v1, described by api/openapi.yaml and served at /api/v1/openapi.yaml.
  • /llms.txt, /llms-full.txt and Markdown answers for every page (Accept: text/markdown), for LLM agents and scripts.
  • /knowledge.yaml, the catalogue as a KCP manifest (discovered at /.well-known/kcp.json): a map of groups, repositories and documents with intents and reading order.
  • Server-sent events at /api/v1/events: open pages update when the catalogue changes.
  • Every page is complete HTML with its own title, description and canonical URL, plus /sitemap.xml and /robots.txt.

Operations

  • GitHub App or token authentication; webhooks (signed, with secret rotation) for updates within seconds.
  • Private repositories for viewers an authenticating proxy names, kept out of every public answer.
  • Several instances on a Hazelcast cluster: one leader syncs, the others apply its results.
  • Survives GitHub outages and rate limits: the last good data is kept in SQLite and served with its age.
  • Prometheus metrics, liveness and readiness probes and a status page on a separate admin port.

Quick start

You need a GitHub App or a token that can read the organisation's repositories (operator guide, section 1). A minimal scp.yaml:

github:
  sources:
    - id: github
      orgs: [Cantara]
      token_file: /run/secrets/github-token
      # app: { id: 123456, private_key_file: /run/secrets/scp-app.pem }
catalog:
  groups:
    - id: whydah
      name: Whydah
      description: Identity and access management
      default_repo: Whydah-OAuth2Service
      match:
        - prefix: Whydah-
    - id: other
      name: Other
      default_repo: source-code-portal
      match:
        - catch_all: true

Run the image:

docker run --rm -p 9090:9090 -p 9091:9091 -v scp-data:/data \
  -v "$PWD/scp.yaml:/etc/scp/scp.yaml:ro" -v "$PWD/secrets:/run/secrets:ro" \
  ghcr.io/cantara/source-code-portal:2.0.0 serve --config /etc/scp/scp.yaml

Open http://localhost:9090. The first sync of a large organisation takes a few minutes; the pages show what is loaded so far.

Without containers, take the binary for Linux (amd64, arm64) or macOS (arm64) and the web UI bundle scp-web_<version>.tar.gz from the releases page, unpack the bundle and run it with Node.js 26:

SCP_WEB_DIR=./scp-web scp serve --config scp.yaml

Releases are signed: the checksums with cosign, the image by digest.

Configuration

Configuration is one YAML file (--config); every key can also be set as SCP_<KEY> with dots as underscores, for example SCP_SERVER_PUBLIC_ADDR. deploy/config.example.yaml shows every key and scp config check --config scp.yaml prints the effective settings. The main ones:

Key Purpose
github.sources[] organisations and user accounts to read, with a GitHub App or a token file; forks, archived and private repositories on or off
catalog.groups[] the products: id, name, description, default repository and matchers
catalog.reconcile_interval how often each organisation is listed (default 5 minutes)
webhook.secret_file turns on POST /webhooks/github; previous_secret_file for rotation
server.public_url the portal's public address, for absolute links and HSTS
access.* identity headers and groups that may see private repositories
cluster.addresses Hazelcast members for several instances
store.path the SQLite cache (rebuildable)
web.dir, web.node the web UI bundle and the Node.js binary; the image sets both

Webhooks. Point the App's webhook, or an organisation webhook with content type application/json, at https://<portal>/webhooks/github with the secret from webhook.secret_file and the events Push, Release and Repository. For a portal on your own machine, a tunnel such as ngrok http 9090 gives GitHub an https address to deliver to. Without a webhook the portal still refreshes on its schedule.

Endpoints

Listener Path What
public :9090 /, /groups/{id}, /repos/{owner}/{name}, /commits the web UI
/api/v1/... the JSON API (API guide)
/badges/... SVG badges
/llms.txt, /llms-full.txt the catalogue for LLM agents
/webhooks/github GitHub deliveries
admin :9091 /livez, /readyz probes
/metrics Prometheus
/api/v1/status sync, rate limits, webhooks and cluster at a glance

Architecture

GitHub ──webhooks──┐
   │               ▼
   └──REST──▶ sync engine ──▶ SQLite (last good) ──▶ immutable snapshot ──▶ API, badges, llms, events
                                                                           │
                                         browser ◀── Go (CSP, proxy) ◀── Next.js server (renders from the API)
  • Sync. GitHub feeds a job engine with priorities, a rate budget, backoff and per-source pauses. Webhooks and the organisation listing tell it what changed; ETags keep unchanged data free.
  • Snapshot. Jobs write SQLite and publish an immutable snapshot behind an atomic pointer. Request handlers read only the snapshot, so a page never waits for GitHub.
  • Features. Each part users see is a package under internal/feature/ (catalog, commits, docs, pulls, search, ...), standing on internal/platform/ (snapshot, sync engine, store, GitHub client, HTTP) and internal/lib/ (pure helpers). Features never import each other and the platform imports no feature (a test enforces it); cmd/scp wires them together.
  • Untrusted input. Everything from repositories passes bounded parsers and one HTML sanitiser.
  • Web UI. A Next.js App Router application, rendered on the server for every request and hydrated in the browser. Go starts and supervises it on loopback and proxies every page through itself, adding a per-request nonce Content Security Policy.

Stack: Go 1.27 with go-github, goldmark, bluemonday, modernc SQLite, Cobra and Viper, and the Hazelcast Go client; Next.js 16, React 19, TypeScript 7, Tailwind CSS 4, TanStack Query and openapi-fetch typed from the contract; Vitest, MSW and Playwright with axe.

Develop

Requirements: Go 1.27, Node.js 26, pnpm 12 and golangci-lint 2.15.

make check        # the gate: generated code, tidy modules, lint, Go and web tests, Playwright
make dev          # the Go server (scp.yaml) on :9090 and the web UI with hot reload on :3000
make build web    # bin/scp and the web UI bundle in web/bundle
make image        # the container image scp:dev
make gen          # regenerate the API code from api/openapi.yaml
go test -race -run TestName ./internal/feature/catalog/

Tests never touch the network: GitHub is a fake in internal/platform/github/githubtest. The Playwright tests need pnpm -C web exec playwright install chromium.

Documentation

  • Operator guide: connect GitHub, configure, run, several instances, monitor, troubleshoot.
  • Repository guide: what the portal reads from a repository and the scp.yaml descriptor.
  • Security model: the guarantees for private repositories and the operator's part.
  • API guide: the JSON API, badges and Markdown for agents.
  • Changelog and security policy.
  • The portal's own Guide page (/guide): how to read the signals, and the short path to a portal of your own.

Claude Code plugin. The scp plugin's run-scp skill configures, deploys, upgrades and troubleshoots a released portal with you, reading the documents of the release you run and proving the configuration with scp config check:

/plugin install scp --marketplace Cantara/source-code-portal

On Claude Code before 2.1.275: /plugin marketplace add Cantara/source-code-portal, then /plugin install scp@source-code-portal.

Contributing

Issues and pull requests are welcome. Keep changes small, follow Conventional Commits and run make check before you push. AGENTS.md describes the layout and the rules the code follows.

Roadmap

  1. The next release: the header's theme menu and account menu, every kind of work counted by default, and commits of any length read without failing (a repository's commit list is read as a stream in bounded memory).
  2. Embedding the portal in other sites (design): the portal's signals as versioned HTML fragments that a host site composes on its server, on any stack. Each fragment keeps its own styles in a shadow root, takes the host's look through --scp-* custom properties, and updates live through one small module of custom elements. Outbound webhooks tell a host when the data changed, and a typed client serves hosts that draw their own. The portal's dashboard is built from the same fragments, so the two never drift apart.

Licence

Apache License 2.0, see LICENSE. Source Code Portal is a Cantara project.

Directories

Path Synopsis
Package api embeds the /api/v1 contract so the binary can serve it.
Package api embeds the /api/v1 contract so the binary can serve it.
cmd
scp command
Command scp runs Source Code Portal.
Command scp runs Source Code Portal.
internal
feature/announce
Package announce keeps the portal's announcements (design/announcements.md): the configuration's `announcements[]` is the base, and the admins' changes are the store's overrides (the document `announcements`, design/config-baseline.md): an announcement by id replaces the file's or is added, and `removed` names the file's ones taken away.
Package announce keeps the portal's announcements (design/announcements.md): the configuration's `announcements[]` is the base, and the admins' changes are the store's overrides (the document `announcements`, design/config-baseline.md): an announcement by id replaces the file's or is added, and `removed` names the file's ones taken away.
feature/assistant
Package assistant is the feature that answers questions about the catalogue (design/assistant.md): a streaming chat with a language model that calls read-only tools over the viewer's view of the snapshot.
Package assistant is the feature that answers questions about the catalogue (design/assistant.md): a streaming chat with a language model that calls read-only tools over the viewer's view of the snapshot.
feature/badges
Package badges serves local SVG badges for repositories and groups.
Package badges serves local SVG badges for repositories and groups.
feature/catalog
Package catalog discovers the public repositories of the configured organisations, tracks their identity and old addresses, assigns them to the configured groups and contributes repositories, groups and aliases to the snapshot.
Package catalog discovers the public repositories of the configured organisations, tracks their identity and old addresses, assigns them to the configured groups and contributes repositories, groups and aliases to the snapshot.
feature/commits
Package commits keeps the latest default-branch commits of every catalogued repository and serves the merged commit feeds.
Package commits keeps the latest default-branch commits of every catalogued repository and serves the merged commit feeds.
feature/docs
Package docs keeps every catalogued repository's README and the Markdown files under docs/, rendered to SafeHTML with a table of contents, and serves them.
Package docs keeps every catalogued repository's README and the Markdown files under docs/, rendered to SafeHTML with a table of contents, and serves them.
feature/docs/chromacss command
Command chromacss writes the CSS for the token classes the docs pipeline puts on highlighted code, light and dark.
Command chromacss writes the CSS for the token classes the docs pipeline puts on highlighted code, light and dark.
feature/insights
Package insights answers what the data the portal holds says about the fleet (design/insights.md, P-83): how often it ships, what it is built on, what it leans on, where knowledge sits with one person and what has gone quiet.
Package insights answers what the data the portal holds says about the fleet (design/insights.md, P-83): how often it ships, what it is built on, what it leans on, where knowledge sits with one person and what has gone quiet.
feature/issues
Package issues keeps every repository's open issues and says for each where it stands (design/issues.md, P-69).
Package issues keeps every repository's open issues and says for each where it stands (design/issues.md, P-69).
feature/layout
Package layout keeps the composition of the portal's pages (design/layout.md): which elements a page shows, in which order and with which options, as data an admin edits in the design mode.
Package layout keeps the composition of the portal's pages (design/layout.md): which elements a page shows, in which order and with which options, as data an admin edits in the design mode.
feature/llms
Package llms serves the Markdown surface for LLM agents and scripts: /llms.txt (an llmstxt.org index), /llms-full.txt (every README in one file), raw Markdown of documents and READMEs, and Markdown answers to pages when the client asks for text/markdown.
Package llms serves the Markdown surface for LLM agents and scripts: /llms.txt (an llmstxt.org index), /llms-full.txt (every README in one file), raw Markdown of documents and READMEs, and Markdown answers to pages when the client asks for text/markdown.
feature/manifests
Package manifests reads the package manifests of every catalogued repository (go.mod, package.json, pom.xml) as untrusted input and keeps the technology and the dependencies they declare.
Package manifests reads the package manifests of every catalogued repository (go.mod, package.json, pom.xml) as untrusted input and keeps the technology and the dependencies they declare.
feature/packages
Package packages finds what a repository publishes to package registries and the newest release there (design/packages.md): one Provider per package manager reads the coordinates from the build files, and asks the registries the build file names, the configured ones and the public one.
Package packages finds what a repository publishes to package registries and the newest release there (design/packages.md): one Provider per package manager reads the coordinates from the build files, and asks the registries the build file names, the configured ones and the public one.
feature/pulls
Package pulls keeps every repository's open pull requests and says for each whose turn it is (design/pulls.md, P-68).
Package pulls keeps every repository's open pull requests and says for each whose turn it is (design/pulls.md, P-68).
feature/releases
Package releases keeps every repository's recent releases (design/releases.md, P-82): the 20 newest published ones as a conditional REST listing, read when a release is published and every 6 hours as the net.
Package releases keeps every repository's recent releases (design/releases.md, P-82): the 20 newest published ones as a conditional REST listing, read when a release is published and every 6 hours as the net.
feature/search
Package search is the portal's search (design/search.md): an inverted index in memory of what the portal holds, one segment per repository built from its facets through Options.Read and reused while the repository's content digest is unchanged.
Package search is the portal's search (design/search.md): an inverted index in memory of what the portal holds, one segment per repository built from its facets through Options.Read and reused while the repository's content digest is unchanged.
feature/visibility
Package visibility is who sees what (design/visibility.md, VS1): every product and repository has an audience, everyone, only signed-in viewers (those who see private repositories) or no one, and an item everyone sees may be kept from search engines.
Package visibility is who sees what (design/visibility.md, VS1): every product and repository has an audience, everyone, only signed-in viewers (those who see private repositories) or no one, and an item everyone sees may be kept from search engines.
feature/webhook
Package webhook receives GitHub deliveries on POST /webhooks/github: it verifies the signature over the raw body, drops repeated deliveries and hands each event, normalised to a sync event and a repository or owner, to a Sink.
Package webhook receives GitHub deliveries on POST /webhooks/github: it verifies the signature over the raw body, drops repeated deliveries and hands each event, normalised to a sync event and a repository or owner, to a Sink.
lib/actor
Package actor tells automation from people by the names GitHub shows: one test for the commits and the pull requests.
Package actor tells automation from people by the names GitHub shows: one test for the commits and the pull requests.
lib/egress
Package egress is the way out to addresses that untrusted content names: https to public unicast addresses only, checked on the address dialled, so neither a redirect nor a DNS answer reaches the portal's own network.
Package egress is the way out to addresses that untrusted content names: https to public unicast addresses only, checked on the address dialled, so neither a redirect nor a DNS answer reaches the portal's own network.
lib/jsonstream
Package jsonstream reads JSON as a stream in bounded memory: a value not asked for is skipped as it is read, never held, and a string keeps at most the bytes asked for, its start and its end.
Package jsonstream reads JSON as a stream in bounded memory: a value not asked for is skipped as it is read, never held, and a string keeps at most the bytes asked for, its start and its end.
lib/lru
Package lru is a least-recently-used cache bounded by the total weight of what it holds.
Package lru is a least-recently-used cache bounded by the total weight of what it holds.
lib/safehtml
Package safehtml holds SafeHTML, HTML that passed the portal's one sanitiser policy, and that policy.
Package safehtml holds SafeHTML, HTML that passed the portal's one sanitiser policy, and that policy.
lib/untrusted
Package untrusted cleans repository-authored text for display: one line, no control, bidirectional-formatting or zero-width characters, bounded length.
Package untrusted cleans repository-authored text for display: one line, no control, bidirectional-formatting or zero-width characters, bounded length.
platform/analytics
Package analytics is the optional Plausible Analytics of the pages (design/analytics.md, P-113).
Package analytics is the optional Plausible Analytics of the pages (design/analytics.md, P-113).
platform/auth
Package auth signs people in (design/auth.md): sessions are cookies sealed with AES-256-GCM, so no instance keeps state; OpenID Connect with PKCE identifies people at their provider; bearer tokens identify machines.
Package auth signs people in (design/auth.md): sessions are cookies sealed with AES-256-GCM, so no instance keeps state; OpenID Connect with PKCE identifies people at their provider; bearer tokens identify machines.
platform/auth/oidctest
Package oidctest is a fake OpenID Connect provider for tests, on a loopback listener: discovery, JWKS, an authorization endpoint that approves at once as the configured user, the token endpoint with PKCE, userinfo and end session.
Package oidctest is a fake OpenID Connect provider for tests, on a loopback listener: discovery, JWKS, an authorization endpoint that approves at once as the configured user, the token endpoint with PKCE, userinfo and end session.
platform/cluster
Package cluster lets several instances serve one portal.
Package cluster lets several instances serve one portal.
platform/cluster/clustertest
Package clustertest is an in-memory cluster backend for tests: a Hub is the cluster, each Dial a member with its own connection.
Package clustertest is an in-memory cluster backend for tests: a Hub is the cluster, each Dial a member with its own connection.
platform/config
Package config loads and validates the configuration of SCP: built-in defaults, then a YAML file, then SCP_* environment variables, then command-line flags.
Package config loads and validates the configuration of SCP: built-in defaults, then a YAML file, then SCP_* environment variables, then command-line flags.
platform/docstore
Package docstore keeps what an admin edits in the portal's pages (core): the layouts, the announcements.
Package docstore keeps what an admin edits in the portal's pages (core): the layouts, the announcements.
platform/ghlogin
Package ghlogin signs a person in to a GitHub host for the personal edition (design/personal.md): the host's forms (github.com, a GitHub Enterprise Server, a GHE.com tenant), the device flow, and the two read-only calls that say who the token is and which organisations it reaches.
Package ghlogin signs a person in to a GitHub host for the personal edition (design/personal.md): the host's forms (github.com, a GitHub Enterprise Server, a GHE.com tenant), the device flow, and the two read-only calls that say who the token is and which organisations it reaches.
platform/github
Package github reads repositories from GitHub for the sync jobs: GitHub App or token authentication, REST calls through go-github, conditional requests with ETags, rate-limit observation and error classification.
Package github reads repositories from GitHub for the sync jobs: GitHub App or token authentication, REST calls through go-github, conditional requests with ETags, rate-limit observation and error classification.
platform/github/githubtest
Package githubtest is a fake GitHub REST server for tests: App and token authentication, organisation and user account listings with pagination, single repositories, rate-limit headers, ETags and 304s, fault injection and a request ledger.
Package githubtest is a fake GitHub REST server for tests: App and token authentication, organisation and user account listings with pagination, single repositories, rate-limit headers, ETags and 304s, fault injection and a request ledger.
platform/health
Package health scores repositories and weighs them into products, so an owner sees what needs attention.
Package health scores repositories and weighs them into products, so an owner sees what needs attention.
platform/httpapi
Package httpapi builds the HTTP handlers of the two listeners: the public port (web UI, API, badges, LLM surface, webhook) and the admin port (probes, metrics, profiling, status).
Package httpapi builds the HTTP handlers of the two listeners: the public port (web UI, API, badges, LLM surface, webhook) and the admin port (probes, metrics, profiling, status).
platform/httpapi/oapi
Package oapi is generated from api/openapi.yaml: the API types and the strict server interface.
Package oapi is generated from api/openapi.yaml: the API types and the strict server interface.
platform/llm
Package llm streams tool-using chat from a language-model provider: two wire formats (Anthropic Messages and the OpenAI-compatible Chat Completions) over net/http, one adapter each, for five providers.
Package llm streams tool-using chat from a language-model provider: two wire formats (Anthropic Messages and the OpenAI-compatible Chat Completions) over net/http, one adapter each, for five providers.
platform/mcpserver
Package mcpserver serves the tool catalogue over the Model Context Protocol (design/agents.md, W2): /mcp in Streamable HTTP, stateless, with JSON answers.
Package mcpserver serves the tool catalogue over the Model Context Protocol (design/agents.md, W2): /mcp in Streamable HTTP, stateless, with JSON answers.
platform/prereq
Package prereq is what each feature needs from GitHub (read permissions, webhook events) and the check of it against what a source's credential is granted (design/prerequisites.md, P-71).
Package prereq is what each feature needs from GitHub (read permissions, webhook events) and the check of it against what a source's credential is granted (design/prerequisites.md, P-71).
platform/scope
Package scope is what the listings of one feature's items (commits, pull requests, issues) share: which repositories a request's group and repository parameters name, the numbered page asked for and the freshness of the scope.
Package scope is what the listings of one feature's items (commits, pull requests, issues) share: which repositories a request's group and repository parameters name, the numbered page asked for and the freshness of the scope.
platform/setup
Package setup is the personal edition's first-run page (design/personal.md): in the browser the person signs in to GitHub, chooses the accounts, and sorts their repositories into products.
Package setup is the personal edition's first-run page (design/personal.md): in the browser the person signs in to GitHub, chooses the accounts, and sorts their repositories into products.
platform/snapshot
Package snapshot holds the immutable serving state of SCP: the catalogue, the facets features hang on its repositories and the indexes they derive.
Package snapshot holds the immutable serving state of SCP: the catalogue, the facets features hang on its repositories and the indexes they derive.
platform/store
Package store keeps everything the portal holds on to in SQLite, so a restart (or a crash) serves it before the first GitHub call: the catalogue, the documents administrators save, sealed credentials, parked webhook events.
Package store keeps everything the portal holds on to in SQLite, so a restart (or a crash) serves it before the first GitHub call: the catalogue, the documents administrators save, sealed credentials, parked webhook events.
platform/sync
Package sync runs the jobs that read GitHub.
Package sync runs the jobs that read GitHub.
platform/theme
Package theme is what makes a deployment look like its owner's without rebuilding the portal (design/theme.md, P-108): a directory of files the portal serves under /theme/ (a stylesheet that sets the colour tokens, a logo, a favicon) and a product name, both read at the start.
Package theme is what makes a deployment look like its owner's without rebuilding the portal (design/theme.md, P-108): a directory of files the portal serves under /theme/ (a stylesheet that sets the colour tokens, a logo, a favicon) and a product name, both read at the start.
platform/tools
Package tools is the catalogue of the read-only tools agents call (design/agents.md): the assistant in process, MCP clients at /mcp and browser agents through WebMCP.
Package tools is the catalogue of the read-only tools agents call (design/agents.md): the assistant in process, MCP clients at /mcp and browser agents through WebMCP.
platform/vault
Package vault seals the credentials the portal reads GitHub with (design/personal.md): AES-256-GCM under a key that lives in the operating system's keychain, else in a 0600 file beside the store, never in the store.
Package vault seals the credentials the portal reads GitHub with (design/personal.md): AES-256-GCM under a key that lives in the operating system's keychain, else in a 0600 file beside the store, never in the store.
platform/webui
Package webui runs the web UI's server, the Next.js standalone build in web.dir, as a child process on a loopback port: started with the portal, restarted when it exits or its bundle is replaced, stopped at shutdown.
Package webui runs the web UI's server, the Next.js standalone build in web.dir, as a child process on a loopback port: started with the portal, restarted when it exits or its bundle is replaced, stopped at shutdown.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL