Skip to content

Commit 8063821

Browse files
authored
Merge pull request #402 from CodeForPhilly/docs-dev-section
restore developer-facing docs files, create folders for user-facing docs and dev-facing docs
2 parents df09cae + f137ad3 commit 8063821

File tree

7 files changed

+364
-55
lines changed

7 files changed

+364
-55
lines changed

docs/README.md

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,19 @@
1-
# Starlight Starter Kit: Basics
1+
# BDT Docs
22

3-
[![Built with Starlight](https://astro.badg.es/v2/built-with-starlight/tiny.svg)](https://starlight.astro.build)
3+
How to contribute to the docs
44

5-
```
6-
npm create astro@latest -- --template starlight
7-
```
5+
## Setup
86

9-
> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
7+
`cd docs/`
108

11-
## 🚀 Project Structure
9+
`npm install`
1210

13-
Inside of your Astro + Starlight project, you'll see the following folders and files:
11+
`npm run dev`
1412

15-
```
16-
.
17-
├── public/
18-
├── src/
19-
│ ├── assets/
20-
│ ├── content/
21-
│ │ └── docs/
22-
│ └── content.config.ts
23-
├── astro.config.mjs
24-
├── package.json
25-
└── tsconfig.json
26-
```
13+
## Docs Pages
2714

28-
Starlight looks for `.md` or `.mdx` files in the `src/content/docs/` directory. Each file is exposed as a route based on its file name.
15+
Each page in the docs is a markdown file located at content/docs/...
2916

30-
Images can be added to `src/assets/` and embedded in Markdown with a relative link.
17+
To edit a docs page, simply edit the markdown file.
3118

32-
Static assets, like favicons, can be placed in the `public/` directory.
33-
34-
## 🧞 Commands
35-
36-
All commands are run from the root of the project, from a terminal:
37-
38-
| Command | Action |
39-
| :------------------------ | :----------------------------------------------- |
40-
| `npm install` | Installs dependencies |
41-
| `npm run dev` | Starts local dev server at `localhost:4321` |
42-
| `npm run build` | Build your production site to `./dist/` |
43-
| `npm run preview` | Preview your build locally, before deploying |
44-
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
45-
| `npm run astro -- --help` | Get help using the Astro CLI |
46-
47-
## 👀 Want to learn more?
48-
49-
Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build), or jump into the [Astro Discord server](https://astro.build/chat).
19+
To add a docs page, add a markdown file in the appropriate directory (`user/` for user-facing pages or `dev/` for developer-facing pages). The file must include [frontmatter](https://www.markdownlang.com/advanced/frontmatter.html) with `title` and `description` fields. In `astro.config.mjs`, add an item to the sidebar in the appropriate location to add your page to the sidebar.

docs/astro.config.mjs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,27 @@ export default defineConfig({
1010
description:
1111
"User guide for the Benefit Decision Toolkit screener builder app",
1212
sidebar: [
13-
{ label: "Introduction", slug: "intro" },
14-
{ label: "User Guide", slug: "user-guide" },
15-
{ label: "Custom Checks", slug: "custom-checks" },
13+
{
14+
label: "User",
15+
items: [
16+
{ label: "Introduction", slug: "user/intro" },
17+
{ label: "User Guide", slug: "user/user-guide" },
18+
{ label: "Custom Checks", slug: "user/custom-checks" },
19+
],
20+
},
21+
{
22+
label: "Developer",
23+
items: [
24+
{
25+
label: "Testing PRs with Codespaces",
26+
slug: "dev/testing-prs-with-codespaces",
27+
},
28+
{
29+
label: "Input Definition Transformation",
30+
slug: "dev/input-definition-transformation",
31+
},
32+
],
33+
},
1634
],
1735
}),
1836
],
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
title: Input Definition Transformation
3+
description: Input Definition Transformation
4+
---
5+
6+
## EligibilityCheck InputDefinitions
7+
8+
Each EligibilityCheck defines a JSON Schema for that data it takes as inputs. This JSON Schema is located at `EligibilityCheck.inputDefinition`, and when a Check is added to a Benefit this JSON Schema is copied to `CheckConfig.inputDefinition`.
9+
10+
Example `EligibilityCheck.inputDefinition` JSON Schema for `Person-min-age` (as of 2026-02-25):
11+
12+
```
13+
{
14+
"type": "object",
15+
"properties": {
16+
"people": {
17+
"type": "array",
18+
"items": {
19+
"type": "object",
20+
"properties": {
21+
"dateOfBirth": {
22+
"type": "string",
23+
"format": "date"
24+
},
25+
"id": {
26+
"type": "string"
27+
}
28+
}
29+
}
30+
}
31+
}
32+
}
33+
```
34+
35+
Example Data that would be accepted by `EligibilityCheck.inputDefinition` JSON Schema (as of 2026-02-25):
36+
37+
```
38+
{
39+
"people": [
40+
{
41+
"id": "client",
42+
"dateOfBirth": "1960-01-01"
43+
},
44+
{
45+
"id": "spouse",
46+
"dateOfBirth": "1984-01-01"
47+
}
48+
]
49+
}
50+
```
51+
52+
## The reason for a transformation layer
53+
54+
This JSON Schema existing makes it easy to validate the data being sent to an EligibilityCheck (library or custom). However, forcing the Screener Form to produce data that conforms to this Schema leads to a poor user experience.
55+
56+
After some deliberation, the Tech team of BDT decided that the following format would be more suited to the user experience of building a form:
57+
58+
```
59+
{
60+
"people": {
61+
"client": {
62+
"dateOfBirth": "1960-01-01"
63+
},
64+
"spouse": {
65+
"dateOfBirth": "1984-01-01"
66+
}
67+
}
68+
}
69+
```
70+
71+
If this was the data the Screener Form was expected to produce, then we could have the user choose between the following options when building their form: `["people.client.dateOfBirth", "people.spouse.dateOfBirth"]`
72+
73+
## The transformation Layer
74+
75+
As of 2026-02-25, the Data Transformation Layer has two parts.
76+
77+
- The endpoint `/screener/{screenerId}/form-paths` was made.
78+
- This endpoint loops over each Benefit in the selected Screener, then loops over each Check selected in those benefits, and transforms the InputDefinitions of those checks into JSON Schemas that match the desired data (`transformInputDefinitionSchema`).
79+
- Then once the JSON Schema has been created for a check, the "FormPaths" are extracted from that new JSON Schema (`extractJsonSchemaPaths`).
80+
- These "FormPath" objects are returned to the Frontend.
81+
- A step was added to Decision Endpoints to transform the Form Data into a state that matched what the EligibilityChecks expect (`FormDataTransformer.transformFormData`).
82+
83+
## Potential weaknesses of this approach
84+
85+
- `InputSchemaService` and `FormDataTransformer` are two different classes in the backend. They are related, but because one of these operates on JSON Schema definitions and the other operates on actual Form Data it is difficult to determine the boundaries of these services.
86+
- The preferred schema of the Form Data for user experience is known only by the devs and/or by looking at what the transformations do. Some definition of what this "preferred schema" actually is could be added to the codebase.
87+
- The old method of having the form output match what the EligibilityCheck expected made it simple for devs to know what the output of the form needed to be in order to satisfy the checks. This may also be solved by documenting this preferred form-data schema.

0 commit comments

Comments
 (0)