Skip to content

Commit 02d8bec

Browse files
committed
refactor: ♻️ Final updates
1 parent ef3081e commit 02d8bec

25 files changed

Lines changed: 114 additions & 119 deletions

docs/.vitepress/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ function appSidebarGuide() {
155155
text: 'Extending the Platform',
156156
collapsible: true,
157157
items: [
158-
{ text: 'Platform Providers (GitLab)', link: '/dev/providers.md' },
158+
// Temporarily hidden
159+
// { text: 'Platform Providers (GitLab)', link: '/dev/providers.md' },
159160
{ text: 'REST API Reference', link: '/dev/api-reference.md' },
160161
],
161162
},

docs/dev/api-reference.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ head:
88
content: https://kalai.fairdataihub.org/api/generate?title=Codefair%20Documentation&description=REST%20API%20Reference&app=codefair&org=fairdataihub
99
---
1010

11-
# :satellite: REST API Reference
11+
# REST API Reference
1212

1313
The central API exposes its functionality over HTTP from `ui/server/api`. This page is a reference to those endpoints.
1414

1515
> [!WARNING] > **Internal and evolving.** These endpoints currently power Codefair's own web UI and are authenticated with the browser **session cookie**, not API tokens. They are documented here as the foundation of the planned **public REST API**, so paths, payloads, and the auth model may change before a stable, token-authenticated, versioned API is released. Treat this as a contributor reference, not a public contract.
1616
17-
## :gear: Conventions
17+
## Conventions
1818

1919
- **Routing.** Nuxt/Nitro encodes the HTTP method in the file name: `index.get.ts``GET`, `index.post.ts``POST`, `index.put.ts``PUT`. Path segments in brackets (`[owner]`, `[repo]`) are URL parameters.
2020
- **Authentication.** Most endpoints call `protectRoute(event)` (a valid session is required) and `repoWritePermissions(event, owner, repo)` (the signed-in user must have write access to the repository). A CSRF/origin check runs in middleware for browser requests. Exceptions: the **webhook** endpoint uses HMAC signature verification, and the **badge** endpoint is public.
2121
- **Errors.** Failures are returned as JSON with an HTTP status and a `statusMessage`, e.g. `{ "statusCode": 404, "statusMessage": "installation-not-found" }`.
2222
- **Bodies.** Write endpoints validate their JSON body with [Zod](https://zod.dev/).
2323

24-
## :file_folder: Repository compliance
24+
## Repository compliance
2525

2626
Each FAIR check exposes a consistent trio: `GET` current state, `POST` to create the file via a pull request, and `PUT` to save a draft. All are under `/api/[owner]/[repo]`.
2727

@@ -34,15 +34,15 @@ Each FAIR check exposes a consistent trio: `GET` current state, `POST` to create
3434
| GET / POST / PUT | `/code-of-conduct` | Read, create-PR, or update `CODE_OF_CONDUCT.md`. |
3535
| GET / POST / PUT | `/code-metadata` | Read, create-PR, or update `codemeta.json` + `CITATION.cff`. |
3636

37-
## :test_tube: Validation views
37+
## Validation views
3838

3939
| Method | Path | Purpose |
4040
| :----- | :------------------------------------- | :--------------------------------------------------- |
4141
| GET | `/[owner]/[repo]/cwl-validation` | CWL files and their validation results. |
4242
| GET | `/[owner]/[repo]/cwl-validation/rerun` | Re-run CWL validation. |
4343
| GET | `/[owner]/[repo]/metadata-validation` | `codemeta.json` / `CITATION.cff` validation results. |
4444

45-
## :bar_chart: Dashboard data
45+
## Dashboard data
4646

4747
| Method | Path | Purpose |
4848
| :----- | :-------------------------- | :------------------------------------------------------------------- |
@@ -74,7 +74,7 @@ the UI can show live progress.
7474
> **400 `Central API mode required for rerun`** otherwise. See
7575
> [Architecture](./architecture.md) for what that flag means.
7676
77-
## :rocket: Releases & archival
77+
## Releases & archival
7878

7979
| Method | Path | Purpose |
8080
| :----- | :----------------------------------------- | :--------------------------------------------- |
@@ -86,7 +86,7 @@ the UI can show live progress.
8686
| GET | `/zenodo/callback` | Zenodo OAuth callback. |
8787
| POST | `/zenodo/disconnect` | Disconnect the user's Zenodo account. |
8888

89-
## :bust_in_silhouette: User & session
89+
## User & session
9090

9191
| Method | Path | Purpose |
9292
| :----- | :------------- | :------------------------------------------ |
@@ -95,21 +95,21 @@ the UI can show live progress.
9595
| DELETE | `/user/tokens` | Revoke the user's tokens. |
9696
| POST | `/logout` | End the session. |
9797

98-
## :label: Badges & utilities
98+
## Badges & utilities
9999

100100
| Method | Path | Auth | Purpose |
101101
| :----- | :----------------------------- | :------ | :-------------------------------------------------------------------- |
102102
| GET | `/badge/[owner]/[repo]` | Public | Returns an SVG **DOI badge** for the repo's published Zenodo release. |
103103
| GET | `/utils/stats` | Public | Global usage statistics. |
104104
| GET | `/request/license/[licenseid]` | Session | Fetch a license template by SPDX id, proxied from spdx.org. |
105105

106-
## :inbox_tray: Webhooks
106+
## Webhooks
107107

108108
| Method | Path | Auth | Purpose |
109109
| :----- | :----------------- | :--- | :----------------------------------------------------------------- |
110110
| POST | `/webhooks/github` | HMAC | Receives GitHub App events. See [Architecture](./architecture.md). |
111111

112-
## :compass: Non-`/api` routes
112+
## Non-`/api` routes
113113

114114
Not everything is under `/api`. These live in `ui/server/routes/` and are reached directly in
115115
the browser rather than by `fetch`.
@@ -129,7 +129,7 @@ the browser rather than by `fetch`.
129129
> `/doi/[owner]/[repo]` is what it **links to**. Note the `/api` prefix on the image but not
130130
> on the redirect.
131131
132-
## :page_facing_up: Example
132+
## Example
133133

134134
Reading and updating the README for a repository:
135135

@@ -147,7 +147,7 @@ curl -X POST https://codefair.io/api/octocat/hello-world/readme \
147147
# → { "message": "README request updated successfully", "prUrl": "https://github.com/octocat/hello-world/pull/42" }
148148
```
149149

150-
## :crystal_ball: Toward a public REST API
150+
## Toward a public REST API
151151

152152
The current surface is the groundwork for a public REST API. Expected additions as it matures:
153153

docs/dev/architecture.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ head:
88
content: https://kalai.fairdataihub.org/api/generate?title=Codefair%20Documentation&description=Architecture&app=codefair&org=fairdataihub
99
---
1010

11-
# :building_construction: Architecture
11+
# Architecture
1212

1313
Codefair is a GitHub App that helps research software become FAIR. Behind the
1414
App is a **central API**: a single [Nuxt](https://nuxt.com/) application (the
@@ -21,7 +21,7 @@ This page explains how the pieces fit together so you can find your way around
2121
before [running locally](./running-locally.md) or
2222
[contributing a feature](./compliance-check.md).
2323

24-
## :eyes: The big picture
24+
## The big picture
2525

2626
```mermaid
2727
flowchart LR
@@ -62,7 +62,7 @@ flowchart LR
6262
| **Database** | n/a | PostgreSQL | Stores installations, per-check state, users, and Zenodo depositions. |
6363
| **Zenodo** | n/a | external | Archival of releases and DOI minting. |
6464

65-
## :gear: Inside the central API (`ui/server`)
65+
## Inside the central API (`ui/server`)
6666

6767
The backend lives in `ui/server` and follows Nuxt/Nitro conventions:
6868

@@ -84,7 +84,7 @@ The `services/` folder is where most feature work happens:
8484
- **`services/dashboard/`**: `manager.ts` (reads/writes the dashboard issue) and `renderer.ts` (pure markdown builder).
8585
- **`services/archival/`**: `interface.ts` (the `ArchivalProvider` contract) and `zenodo.ts` (the Zenodo implementation).
8686

87-
## :inbox_tray: How a webhook is handled
87+
## How a webhook is handled
8888

8989
Every GitHub event flows through the same path. GitHub posts to
9090
`server/api/webhooks/github.post.ts`, which verifies the
@@ -121,7 +121,7 @@ Key handlers:
121121
- **`pull_request`**: tracks the Codefair-created PRs (license, README, …) so the dashboard can show their status.
122122
- **`issues`**: reopening the dashboard issue restores it; closing updates state.
123123

124-
## :electric_plug: The provider abstraction (multi-platform support)
124+
## The provider abstraction (multi-platform support)
125125

126126
The most important design decision is that **compliance services never touch
127127
Octokit directly**. Instead they receive a `RepositoryProvider`
@@ -152,7 +152,7 @@ Archival follows the same pattern: `ArchivalProvider`
152152
(`services/archival/interface.ts`) is implemented by Zenodo today, leaving room
153153
for additional archival backends (e.g. Figshare) later.
154154

155-
## :floppy_disk: Data model
155+
## Data model
156156

157157
State is stored in PostgreSQL through Prisma (`ui/prisma/schema.prisma`). The
158158
hub of the schema is the **`Installation`** model, one row per repository
@@ -176,7 +176,7 @@ erDiagram
176176
Other models include `User` and `Session` (authentication), `ZenodoToken` and
177177
`ZenodoDeposition` (archival), and `Analytics` (usage counters).
178178

179-
## :lock: Authentication: two distinct identities
179+
## Authentication: two distinct identities
180180

181181
Codefair uses GitHub in two different ways, and it helps to keep them separate:
182182

@@ -191,7 +191,7 @@ Codefair uses GitHub in two different ways, and it helps to keep them separate:
191191
have write access to a repo before any UI-triggered action runs
192192
(`repoWritePermissions`).
193193

194-
## :test_tube: The validator microservice
194+
## The validator microservice
195195

196196
The `validator/` service is intentionally small and stateless. It exposes a few
197197
HTTP endpoints (`/validate-cwl`, `/validate-citation`, `/validate-codemeta`,
@@ -201,7 +201,7 @@ and JSON-Schema validation for CodeMeta. The central API calls it via the
201201
be deployed and scaled independently. To add a new validation type, see
202202
[Adding a Validation Endpoint](./validator.md).
203203

204-
## :arrows_counterclockwise: From Probot to the central API
204+
## From Probot to the central API
205205

206206
If you worked on Codefair before, here is what changed:
207207

docs/dev/compliance-check.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ A **compliance check** is a single FAIR rule Codefair evaluates for a repository
1414

1515
Codefair is deliberately modular: checks are small functions that receive a platform-agnostic [`RepositoryProvider`](./providers.md) and are wired into a single orchestrator, `runComplianceChecks()`. This page walks through adding a brand-new check end-to-end by building an example that verifies an `expecto_patronum.md` file exists.
1616

17-
> [!NOTE]
18-
> This page covers the **backend** check. To build the Codefair UI page where a user can create or edit the file, follow [Adding a UI Page](./ui.md) afterwards.
19-
17+
::: info
18+
This page covers the **backend** check. To build the Codefair UI page where a user can create or edit the file, follow [Adding a UI Page](./ui.md) afterwards.
19+
:::
2020
All paths below are relative to the `ui/` directory.
2121

2222
## **Step 1**: Set up your development environment

docs/dev/intro.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ head:
88
content: https://kalai.fairdataihub.org/api/generate?title=Codefair%20Documentation&description=Running%20the%20GitHub%20Repository&app=codefair&org=fairdataihub
99
---
1010

11-
# :page_with_curl: Introduction
11+
# Introduction
1212

1313
This is the documentation of Codefair for developers. You will find here everything to set up the project locally and start making your contribution! Before you continue, we invite you to first read our [contributing guidelines](https://github.com/fairdataihub/codefair-app/blob/main/CONTRIBUTING.md) and our [code of conduct](https://github.com/fairdataihub/codefair-app/blob/main/CODE_OF_CONDUCT.md).
1414

15-
## :compass: How the project is organized
15+
## How the project is organized
1616

1717
Codefair recently moved to a **central API** architecture. The [`codefair-app`](https://github.com/fairdataihub/codefair-app) repository is now organized into two active parts:
1818

@@ -24,7 +24,7 @@ Codefair recently moved to a **central API** architecture. The [`codefair-app`](
2424
2525
This central API is the foundation for two ongoing goals: releasing a public **REST API** and adding **GitLab** support alongside GitHub. The architecture was deliberately built around platform-agnostic abstractions so that new checks, new platforms, and community contributions are easier to land.
2626

27-
## :map: Where to go next
27+
## Where to go next
2828

2929
- **[Architecture](./architecture.md)**: understand how the central API, validator, database, and external platforms fit together before you write any code.
3030
- **[Running Locally](./running-locally.md)**: set up your environment and run the stack on your machine.

docs/dev/providers.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ head:
88
content: https://kalai.fairdataihub.org/api/generate?title=Codefair%20Documentation&description=Platform%20Providers&app=codefair&org=fairdataihub
99
---
1010

11-
# :electric_plug: Platform Providers (GitLab)
11+
# Platform Providers (GitLab)
1212

1313
Codefair is being built to work across git platforms, not just GitHub. The mechanism that makes this possible is the **provider abstraction**: every compliance check, dashboard render, and pull-request operation goes through a platform-agnostic interface instead of calling a platform SDK directly.
1414

1515
> [!NOTE] > **Status:** GitLab support is **planned**. The `RepositoryProvider` interface and the GitHub implementation exist today; a `GitLabRepositoryProvider` does not yet. This page documents the contract so the community can help build it.
1616
17-
## :jigsaw: The provider model
17+
## The provider model
1818

1919
The contract lives in `ui/server/services/providers/interface.ts`:
2020

@@ -45,7 +45,7 @@ flowchart TD
4545
I -. "same contract" .-> GL
4646
```
4747

48-
## :clipboard: The contract
48+
## The contract
4949

5050
`RepositoryProvider` groups its methods into four areas:
5151

@@ -58,7 +58,7 @@ flowchart TD
5858

5959
All methods take plain values (`owner`, `repo`, `path`, …) and return the neutral types defined alongside the interface: `RepoInfo`, `FileContent`, `PullRequestRef`, `IssueRef`, and so on. Nothing GitHub-specific leaks through.
6060

61-
## :white_check_mark: The GitHub implementation (reference)
61+
## The GitHub implementation (reference)
6262

6363
`ui/server/services/providers/github.ts` is the implementation to copy. It wraps an installation-scoped Octokit client and translates each contract method into a GitHub REST call:
6464

@@ -102,7 +102,7 @@ export class GitHubRepositoryProvider implements RepositoryProvider {
102102
}
103103
```
104104

105-
## :rocket: Adding GitLab step by step
105+
## Adding GitLab step by step
106106

107107
### 1. Implement the provider
108108

docs/dev/running-locally.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ head:
88
content: https://kalai.fairdataihub.org/api/generate?title=Codefair%20Documentation&description=Running%20the%20GitHub%20Repository&app=codefair&org=fairdataihub
99
---
1010

11-
# :computer: Running Locally
11+
# Running Locally
1212

1313
This section provides instructions for developers to run the Codefair GitHub repository locally. If you have not yet, read the [Architecture](./architecture.md) page first; it explains how the pieces below fit together.
1414

15-
## :file_folder: Code structure
15+
## Code structure
1616

1717
Codefair is a **central API**: a single Nuxt application that serves the web UI and the backend, plus a small validation microservice. The repository has two active parts:
1818

@@ -23,7 +23,7 @@ Codefair is a **central API**: a single Nuxt application that serves the web UI
2323
> [!NOTE]
2424
> The repository also contains a `bot/` folder: the original [Probot](https://probot.github.io/) backend, now **being retired**. You do **not** need to set it up for local development: all backend functionality you'll be working on lives in `ui/server`. It is still deployed in production for repositories that have not yet been migrated to the central API. See [Architecture](./architecture.md#use-central-api-flag).
2525
26-
## :white_check_mark: Prerequisites
26+
## Prerequisites
2727

2828
Before you can run the Codefair repository, you will need the following prerequisites:
2929

@@ -62,14 +62,14 @@ Before you can run the Codefair repository, you will need the following prerequi
6262

6363
After creating the App, generate a **private key** (`.pem`) and note the **App ID**. These become `GH_APP_PRIVATE_KEY` and `GH_APP_ID`.
6464

65-
## :arrow_down: Clone the repository
65+
## Clone the repository
6666

6767
```bash
6868
git clone https://github.com/fairdataihub/codefair-app.git
6969
cd codefair-app
7070
```
7171

72-
## :elephant: Set up the database
72+
## Set up the database
7373

7474
Start a local PostgreSQL instance using the provided Compose file at the repository root:
7575

@@ -83,7 +83,7 @@ This starts Postgres on port `5432` with database `codefair_local` (user `admin`
8383
DATABASE_URL="postgresql://admin:root@localhost:5432/codefair_local"
8484
```
8585

86-
## :key: Environment variables
86+
## Environment variables
8787

8888
Unlike the old Probot setup, there is now a **single** `.env` file, located in the `ui/` directory. The required variables are enforced at startup by `ui/server/plugins/env-check.ts`. If any are missing, the app refuses to boot and tells you which one. Create `ui/.env` with the following:
8989

@@ -121,7 +121,7 @@ ZENODO_REDIRECT_URI= # Zenodo OAuth redirect URI
121121
> [!TIP]
122122
> For local archival testing, point the Zenodo variables at the [Zenodo Sandbox](https://sandbox.zenodo.org/) rather than production so you don't mint real DOIs.
123123
124-
## :running: Running the services
124+
## Running the services
125125

126126
### 1. Central API (`ui/`)
127127

docs/dev/ui.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,9 @@ export default defineEventHandler(async (event) => {
212212
});
213213
```
214214

215-
> [!NOTE]
216-
> The example above constructs an Octokit `App` inline because that is what the existing
217-
> per-repository routes do. For new code, prefer
218-
> `getInstallationOctokit(installationId)` from `server/services/github-app/client.ts`. It
219-
> centralises the App credentials instead of repeating them in every route. Better still, if
220-
> your route only needs ordinary repository operations, take a
221-
> [`RepositoryProvider`](./providers.md) so it stays platform-agnostic.
215+
::: info
216+
The example above constructs an Octokit `App` inline because that is what the existing per-repository routes do. For new code, prefer `getInstallationOctokit(installationId)` from `server/services/github-app/client.ts`. It centralises the App credentials instead of repeating them in every route. Better still, if your route only needs ordinary repository operations, take a [`RepositoryProvider`](./providers.md) so it stays platform-agnostic.
217+
:::
222218

223219
> [!TIP]
224220
> Need a read-only results page instead (like the CWL or metadata validation reports)? Put it under `pages/dashboard/[owner]/[repo]/view/<feature>.vue` and point the dashboard badge at `.../view/<feature>`.
@@ -229,7 +225,7 @@ Run the stack locally and sign in:
229225

230226
```bash
231227
# In ui/
232-
yarn dev
228+
yarn dev:webhook
233229
```
234230

235231
Visit `http://localhost:3000/dashboard/<owner>/<repo>/edit/expecto`, edit the content, and click **Save**. Confirm that a new branch and pull request are created on the repository, and that the PR URL is stored on the `ExpectoValidation` row (`yarn prisma:studio`). You can also reach the page from the **FAIR Compliance Dashboard** issue by clicking the _Create/Edit Expecto_ badge.

0 commit comments

Comments
 (0)