- CSS 75.8%
- TypeScript 12%
- Astro 11%
- JavaScript 0.5%
- Just 0.3%
- Other 0.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .agents/skills | ||
| .claude | ||
| .github | ||
| .idea | ||
| client | ||
| doc | ||
| openspec | ||
| paseto | ||
| seed | ||
| .dockerignore | ||
| .gitignore | ||
| .node-version | ||
| AGENTS.md | ||
| CODE_OF_CONDUCT.md | ||
| compose.yml | ||
| Dockerfile | ||
| justfile | ||
| LICENSE | ||
| mise.toml | ||
| package.json | ||
| pnpm-lock.yaml | ||
| pnpm-workspace.yaml | ||
| publiccode.yml | ||
| README.md | ||
| SECURITY.md | ||
| start-api | ||
| start-client | ||
| start-crawler | ||
Open Source Software Catalog
The Open Source Software Catalogue provides an overview of free and open-source software developed by or for the Swiss Confederation. It is based on the Public Code standard, which describes software in a machine-readable way, making it discoverable and understandable for both developers and non-technical users.
Context
flowchart TB
subgraph OSS_CATALOG[OSS Catalog]
direction LR
db[(PostgreSQL)]
api[Developers Italia API]
crawler[Publiccode Crawler]
web[OSS Catalog Client]
api --> db
crawler -- "Read publishers<br>Create softwares<br>(REST)" --> api
web <-- Static build<br>(REST) --> api
end
user((User))
github[GitHub, GitLab, others]
action[Scheduled Github Action]
swissindex[https://github.com/swiss/index/blob/main/README.md]
user -- "(HTTP)" --> web
crawler -- "Scan repositories<br>Parse publiccode.yml" --> github
swissindex -- Reads publishers --> action
action -- creates publishers (REST) --> api
action -- triggers--> crawler
Usage
Overview
What you will do:
- Clone this repo
- Generate PASETO key & create GitHub API token
- Start API service (and DB)
- Add publisher(s) using curl
- Run crawler
- Build and run the client
Preparation
Clone this repository:
git clone git@github.com:swiss/oss-catalog.git
cd oss-catalog/
Install the required tools (Node.js, pnpm, Go, ...) with mise (see installation docs):
mise trust
mise install
The Node.js version is defined in .node-version and the pnpm version in the packageManager field of package.json.
The API uses a paseto key for authentication. Generate it with:
./paseto/generate-paseto-key.sh
Create GitHub API Token with the public_repo Permission under https://github.com/settings/tokens and add it to the .env file.
The crawler needs this token to access GitHub repositories.
echo "GITHUB_TOKEN=<your access token>" >> .env
API Service
Start API with database:
./start-api
Use API via Curl (optional)
The API uses PASETO for authentication. Generate a PASETO token (valid for 24h):
source .env
cd paseto/go
PASETO_TOKEN="$(go run paseto-generate.go $PASETO_KEY)"
or, using just:
export PASETO_TOKEN="$(just pt)"
List publishers (no authentication needed):
curl http://localhost:3000/v1/publishers
Create some publishers:
curl -X POST -H "Authorization: Bearer $PASETO_TOKEN" -H "Content-Type: application/json" -d '{"codeHosting": [{"url": "https://github.com/swiss/", "group": true}], "description": "Swiss Government"}' http://localhost:3000/v1/publishers
curl -X POST -H "Authorization: Bearer $PASETO_TOKEN" -H "Content-Type: application/json" -d '{"codeHosting": [{"url": "https://github.com/DCC-BS", "group": true}], "description": "Basel-Stadt"}' http://localhost:3000/v1/publishers
curl -X POST -H "Authorization: Bearer $PASETO_TOKEN" -H "Content-Type: application/json" -d '{"codeHosting": [{"url": "https://github.com/agridata-ch", "group": true}], "description": "agridata-ch"}' http://localhost:3000/v1/publishers
Sample data (instead of publishers and crawler)
For local development you can skip adding publishers and running the crawler: this adds sample publishers (Confederation, cantons, municipalities), their software and crawler-like logs through the API in a few seconds:
./start-api
just seed
The fixtures are in seed/ (fixtures.json and one publiccode.yml per software). Publishers that already exist are
skipped. The database has no volume, so just stop-api && just start-api resets it.
Crawler
Run crawler - this will crawl all repositories in the API, checks for publiccode.yml and add them to the database if available and valid.
./start-crawler
Catalog Client Application
Start the catalog client application at http://localhost:8080:
./start-client
Or for development mode:
pnpm install
pnpm scope:client dev
Then visit http://localhost:4321
Embedded publiccode Editor
The page /<locale>/editor loads the publiccode editor from PUBLIC_EDITOR_URL (default: https://swiss.github.io/publiccode-editor).
To test it with a local editor:
-
In the publiccode-editor repository, build and serve
dist/:npm run build npx http-server dist -p 8080 --cors -c-1 -
In this repository, start the client and point it to the editor:
PUBLIC_EDITOR_URL=http://localhost:8080 pnpm scope:client dev
Known Issues
- The actual deletion of a publisher or software in the database takes a while (as if it is done asynchronously in the API).
Resources
- publiccode.yml Standard
- publiccode.yml crawler for the software catalog of Developers Italia
- Fetches registered publishers from the Developers Italia API, crawles all their repositories & feeds the publiccode.yml results into the Developers Italia API.
- publiccode.yml parser for Go by Developers Italia – Used by the publiccode.yml crawler
- Developers Italia API – Stores the results of the publiccode.yml crawler in a PostgreSQL db, runs at https://api.developers.italia.it/v1/software
- publiccode yml Editor by Developers Italia – Web UI to conveniently edit publiccode.yml files
- Developers Italia website – Italy's OSS catalog (Jekyll site)
- Downloads crawled softwares from Developers Italia API: https://github.com/italia/developers.italia.it/blob/main/scripts/get-software.js
- More publicode.yml components by Developers Italia
- List of the organisations of the Swiss Confederation