Skip to content

feat: introduce BetterGov.ph Project Registry with schema validation, GET API, and test suite#635

Merged
jasontorres merged 10 commits into
bettergovph:mainfrom
zelkim:main
May 10, 2026
Merged

feat: introduce BetterGov.ph Project Registry with schema validation, GET API, and test suite#635
jasontorres merged 10 commits into
bettergovph:mainfrom
zelkim:main

Conversation

@zelkim
Copy link
Copy Markdown
Contributor

@zelkim zelkim commented May 8, 2026

Note

The original version of this PR included a full Cloudflare Worker API (GET /api/projects) with filtering, pagination, search, and a 53-test suite. Per maintainer feedback, this has been simplified to a static JSON file served as a public asset. The full API implementation is archived in #637 and will be revisited when the broader project has been revealed and is ready.

Summary

Introduces a centralized, JSON-based Project Registry (public/api/projects.json) as the single source of truth for all officially recognized BetterGov.ph projects, with pre-commit schema validation to guard data integrity.


Motivation

As BetterGov.ph grows into an ecosystem of projects — not all of which live within the bettergovph GitHub organization — there was no single source of truth for which projects are officially recognized. This registry solves that by:

  • Giving maintainers a PR-based recognition workflow (submit a PR → get reviewed → get listed)
  • Providing a stable data source for contributor tracking and Member Card tier progression in the volunteer portal
  • Enabling all BetterGov.ph platforms to consume the same project list (served as a static asset at /api/projects.json)

Changes

1. Project Registry — public/api/projects.json

A new JSON file seeded with all 16 currently recognized BetterGov.ph projects, sourced from the existing ourProjects list in navigation.ts and enriched with descriptions and repository URLs fetched from the bettergovph GitHub org.

Each entry contains:

Field Description
slug Unique kebab-case identifier
title Display name
description Short description of the project
repositoryUrls Array of GitHub URLs (supports multi-repo projects; empty if repo is private)
projectUrl Live URL of the project
status active | development | archived

2. JSON Schema — src/data/schema/projects.schema.json

A JSON Schema Draft-07 file enforcing the registry structure:

  • All six fields required with additionalProperties: false
  • slug validated as kebab-case via regex (^[a-z0-9]+(?:-[a-z0-9]+)*$)
  • projectUrl and each repositoryUrl validated as HTTPS URLs
  • status validated as an enum

3. Pre-commit Validation — .lintstagedrc.js

Schema validation is wired into the existing husky → lint-staged pre-commit pipeline. Whenever public/api/projects.json is staged, the commit is blocked if any entry violates the schema.

git commit  →  husky pre-commit  →  lint-staged  →  validate-json-schema.js

This also fixes a pre-existing bug in validate-json-schema.js where Ajv v8's strict mode caused any schema using format keywords (including the existing services.schema.json and population-2020.schema.json) to fail to compile. Fixed by passing strict: false to the Ajv instance.


Files changed

File Change
public/api/projects.json New — project registry (16 entries)
src/data/schema/projects.schema.json New — JSON Schema Draft-07
.lintstagedrc.js Modified — added pre-commit schema validation for projects.json
scripts/validate-json-schema.js Bug fixstrict: false on Ajv to support format keywords in existing schemas

Archived work

The full API implementation (Cloudflare Worker endpoint, 53-test suite, vitest setup, wrangler.test.jsonc) is preserved in #637 for future reference.

@DaijobuDes DaijobuDes added the low priority This project can take it easy, no to long deadline. label May 8, 2026
@zelkim
Copy link
Copy Markdown
Contributor Author

zelkim commented May 8, 2026

In relation to #634

@DaijobuDes DaijobuDes linked an issue May 8, 2026 that may be closed by this pull request
jasontorres
jasontorres previously approved these changes May 9, 2026
Copy link
Copy Markdown
Collaborator

@jasontorres jasontorres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with this approach so far. Although I didn't really want an API because it just creates an overhead. A static file served in public/api/projects.json would have been easier?

@zelkim
Copy link
Copy Markdown
Contributor Author

zelkim commented May 9, 2026

Yeah I might have over-engineered this. I was thinking that, in sites that had the Our Projects dropdowns, they could call an API, and if ever we have a longer list of projects it would be easier to work with.

Just had a stroke of productivity when making this, we can let the callers handle API-fication on their end.

Will revise to a static projects.json

@jasontorres
Copy link
Copy Markdown
Collaborator

No thank you. I appreciate it. Please keep this branch somewhere as we might need it in the future. Then update this existing with the simplified.

We'll come back to the proper /api routes/workers as there's some big changes I'm planning for BetterGov. I hope for your participation when that time comes!

@zelkim
Copy link
Copy Markdown
Contributor Author

zelkim commented May 9, 2026

Got this! Will create a separate pull request

@zelkim
Copy link
Copy Markdown
Contributor Author

zelkim commented May 9, 2026

Archived API implementation into #637.

This now contains a static projects.json file with schema validation for any changes in pre-commit.

@zelkim zelkim requested a review from jasontorres May 9, 2026 17:31
@DaijobuDes DaijobuDes added the enhancement New feature or request label May 10, 2026
@jasontorres jasontorres merged commit 1b6a0f5 into bettergovph:main May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request low priority This project can take it easy, no to long deadline.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Suggestion: BetterGov.ph Project Registry (projects.json)

3 participants