You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Design system: [USWDS](https://designsystem.digital.gov/), with design tokens specified for each state
29
+
30
+
**Infrastructure**
31
+
32
+
- Infrastructure as Code using OpenTofu (Terraform) - see [tofu](./tofu/)
33
+
- Docker with [docker-compose](https://docs.docker.com/compose/) for local development
34
+
15
35
## Local Environment Set Up 🧰
16
36
17
37
> **Note:** The following steps assume you are working on macOS. Steps may differ if you are working on a different operating system.
@@ -25,64 +45,70 @@ of children eligible for [Summer EBT](https://www.fns.usda.gov/summer/sunbucks)
25
45
26
46
### 2. Clone repositories
27
47
28
-
Clone this repository on your local machine, alongside the [state connector repository](https://github.com/codeforamerica/sebt-self-service-portal-state-connector/) and any revelant state backend connector(s) - for example[DC](https://github.com/codeforamerica/sebt-self-service-portal-dc-connector) or [Colorado](https://github.com/codeforamerica/sebt-self-service-portal-co-connector) - as siblings (within the same parent folder)
48
+
Clone this repository on your local machine, alongside the [state connector repository](https://github.com/codeforamerica/sebt-self-service-portal-state-connector/) and any revelant state backend connector(s) - for example, [Colorado](https://github.com/codeforamerica/sebt-self-service-portal-co-connector) - as siblings (within the same parent folder). Note that you will need to build and set up all repos as part of your local env setup.
`.env` files are used in this project to set environment variables (eg, database configs). This is a preferred pattern for [12-factor Apps](https://www.12factor.net/config). You'll want to create '.env' files in your local environment, based on the example file.
62
+
`.env` files are used in this project to set environment variables (eg, database configs). This is a preferred pattern for [12-factor Apps](https://www.12factor.net/config). They are also set to fallback to a generic default. You'll need to create `.env` files for your local environment, based on the example file.
45
63
46
-
From the root of this repository, run:
64
+
To create your local .env file with configurations for the database and API, run this command in the root of the repo:
47
65
48
66
```bash
49
67
cp .env.example .env
50
68
```
51
69
52
-
You'll also want do the same from within /src/SEBT.Portal.Web:
70
+
You'll want do the same from within `/src/SEBT.Portal.Web`:
53
71
54
72
```bash
55
73
cp .env.example .env.local
56
74
```
57
75
58
-
### 4. Install dependencies
76
+
You'll also need an API `appsettings` file for your local machine with certain values set (see [state specific configuration](#state-specific-configuration) below):
- To install all javascript package dependencies, run `pnpm install` from the root of this repository.
88
+
- You can learn more about the front end in the [SEBT.Portal.Web README](./src/SEBT.Portal.Web/README.md)
89
+
90
+
Back end
59
91
60
-
- To install all javascript package dependencies, run `pnpm install` from the root of this repository
61
-
- dotnet tool install --global dotnet-ef
62
92
- .NET tools are CLI utilities installed and managed using [NuGet](https://www.nuget.org/). Currently, we are using the
63
-
[`nuget-license`](https://www.nuget.org/packages/nuget-license) tool for auditing backend dependency license. Needed tools are defined in the tools
64
-
manifest in `.config/dotnet-tools.json`. To install .NET tools, run `dotnet tool restore` from each solution root (ie, each top-level directory containing a `.sln` or `.slnx` file):
93
+
[`nuget-license`](https://www.nuget.org/packages/nuget-license) tool for auditing backend dependency license. Needed tools are defined in the tools manifest in `.config/dotnet-tools.json`. To install .NET tools, run `dotnet tool restore` from each solution root (ie, each top-level directory containing a `.sln` or `.slnx` file):
65
94
- /src/SEBT.Portal.Infrastructure
66
95
- /src/SEBT.Portal.Api
67
96
68
-
-The first time you start up the application, you'll also want to run `dotnet build` from within the root of each repository
97
+
-You'll also want to run `dotnet build` from within the root of each repository before starting up the app for the first time.
69
98
70
99
### 5. Start Services 💻
71
100
72
-
Make sure the docker daemon is runningand you are logged in via your dockerhub account.
101
+
Make sure Docker is installed and the docker daemon is running. When the database spins up locally, all migrations will be run and db seeded automatically (see [database setup](#database-setup) section below).
73
102
74
103
```bash
75
-
docker compose up -d # Start MSSQL Database and Mailpit
104
+
docker compose up -d # Start all docker containers, including MSSQL Database and Mailpit for testing
76
105
```
77
106
78
-
79
107
```bash
80
-
pnpm dev #Start both API and frontend
108
+
pnpm dev #Script to start both API (ie, `dotnet watch`) and frontend (ie, `next dev`)
81
109
```
82
110
83
-
84
-
To open the app, navigate to https://localhost:3000
85
-
111
+
To open the app, navigate to <https://localhost:3000>
86
112
87
113
## Development
88
114
@@ -104,7 +130,7 @@ docker compose down -v
104
130
105
131
### Mailpit (Local Email Testing)
106
132
107
-
Mailpit captures all outgoing emails in development. Access the web UI at http://localhost:8025
133
+
[Mailpit](https://mailpit.axllent.org/) captures all outgoing emails in local development. Once the Mailpit docker container is running on your machine, you can access its UI in your browser at <http://localhost:8025>
108
134
109
135
### Local Build & Test (Debug mode)
110
136
@@ -182,11 +208,27 @@ Only include sections you want to override; other settings fall back to `appsett
182
208
183
209
### OIDC support
184
210
185
-
States can use an external OpenID Connect (OIDC) provider for sign-in. Code exchange and id_token validation run in the Next.js server; the .NET API performs "complete-login" (validates a short-lived callback token and returns a portal JWT that includes IdP claims such as phone and name).
211
+
States can use an external [OpenID Connect (OIDC)](https://openid.net/developers/how-connect-works/) provider for sign-in. Code exchange and id_token validation run in the Next.js server; the .NET API performs "complete-login" (validates a short-lived callback token and returns a portal JWT that includes IdP claims such as phone and name).
212
+
213
+
For a deployment that uses OIDC, in `.env.local` under `SEBT.Portal.Web`, set:
186
214
187
-
For a deployment that uses OIDC, set in **Next.js**`.env.local`: `OIDC_DISCOVERY_ENDPOINT`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET`, `OIDC_REDIRECT_URI`, `OIDC_COMPLETE_LOGIN_SIGNING_KEY` (at least 32 characters). Set the **same** value for `OIDC_COMPLETE_LOGIN_SIGNING_KEY` in the API as `Oidc:CompleteLoginSigningKey`. In the API, set `Oidc:DiscoveryEndpoint`, `Oidc:ClientId`, `Oidc:CallbackRedirectUri`, and optionally `Oidc:LanguageParam`. The API serves public config via `GET /api/auth/oidc/{stateCode}/config`.
215
+
-`OIDC_DISCOVERY_ENDPOINT`
216
+
-`OIDC_CLIENT_ID`
217
+
-`OIDC_CLIENT_SECRET`
218
+
-`OIDC_REDIRECT_URI`
219
+
-`OIDC_COMPLETE_LOGIN_SIGNING_KEY` (at least 32 characters)
188
220
189
-
See `src/SEBT.Portal.Api/appsettings.Development.example.json` and [ADR-0008](docs/adr/0008-oidc-mycolorado-authentication-and-state-auth-context.md) for the design.
221
+
In `appsettings` under `SEBT.Portal.Api`, set:
222
+
223
+
-`Oidc:CompleteLoginSigningKey` (same value as `OIDC_COMPLETE_LOGIN_SIGNING_KEY`)
224
+
-`Oidc:DiscoveryEndpoint`
225
+
-`Oidc:ClientId`
226
+
-`Oidc:CallbackRedirectUri`
227
+
-`Oidc:LanguageParam` (optional)
228
+
229
+
The API serves public config via `GET /api/auth/oidc/{stateCode}/config`.
230
+
231
+
See `appsettings.Development.example.json` and [ADR-0008](docs/adr/0008-oidc-mycolorado-authentication-and-state-auth-context.md).
190
232
191
233
### ID Proofing Requirements
192
234
@@ -212,14 +254,9 @@ The application uses Microsoft SQL Server as its database. This is propped up v
212
254
213
255
#### Configuration
214
256
215
-
Database configuration is managed through environment variables. Copy `.env.example` to `.env` and customize as needed (this is a preferred pattern for [12-factor Apps](https://www.12factor.net/config)). They are also set to fallback to a generic default.
216
-
217
-
```bash
218
-
cp .env.example .env
219
-
```
220
-
221
-
Available environment variables:
257
+
Configuration is managed through environment variables.
222
258
259
+
Available environment variables for `.env` in the respository root:
223
260
**Database (for Docker Compose):**
224
261
225
262
-`MSSQL_SA_PASSWORD` - SQL Server SA password
@@ -233,20 +270,17 @@ Available environment variables:
233
270
-`JWTSETTINGS__SECRETKEY` - Secret key for JWT token signing. Must be at least 32 characters.
234
271
-`IDENTIFIERHASHER__SECRETKEY` - Secret key for HMAC-SHA256 hashing of Household Identifiers as needed. Must be at least 32 characters.
235
272
236
-
**OIDC (state IdP sign-in)**
237
-
Set `OIDC_DISCOVERY_ENDPOINT`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET`, `OIDC_REDIRECT_URI`, and `OIDC_COMPLETE_LOGIN_SIGNING_KEY` in Next.js `.env.local`. In the API, set `Oidc:CompleteLoginSigningKey` (same value), `Oidc:DiscoveryEndpoint`, `Oidc:ClientId`, and `Oidc:CallbackRedirectUri`. See `appsettings.Development.example.json` and [ADR-0008](docs/adr/0008-oidc-mycolorado-authentication-and-state-auth-context.md).
238
-
239
273
### Database Migrations
240
274
241
-
The application uses [Entity Framework Core migrations](https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli) to manage database schema changes.
275
+
The application uses [EF, or Entity Framework Core migrations](https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli) to manage database schema changes.
242
276
243
277
#### Automatic Migrations
244
278
245
279
**Migrations run automatically on application startup.** When the API starts, it checks for pending migrations and applies them automatically. This ensures the database schema is always up-to-date.
246
280
247
281
#### Manual Migration Commands
248
282
249
-
While migrations run automatically, you can also manage them manually:
283
+
While migrations run automatically, you can also manage them manually by installing `ef` on your local machine:
250
284
251
285
**List all migrations:**
252
286
@@ -298,7 +332,7 @@ The database is automatically seeded with test users when running in the **Devel
298
332
- Application startup (when migrations are applied)
299
333
-`DbContext.EnsureCreated()` calls
300
334
301
-
The automatic seeding uses EF Core's `UseSeeding` mechanism under the hood. See https://learn.microsoft.com/en-us/ef/core/modeling/data-seeding
335
+
The automatic seeding uses EF Core's `UseSeeding` mechanism under the hood. See <https://learn.microsoft.com/en-us/ef/core/modeling/data-seeding>
302
336
303
337
To help test different workflows and users in different states, the seeder will create the following users unless instructed otherwise:
304
338
@@ -334,6 +368,11 @@ Alternatively, I'd highly recommend a tool like [LINQPad](https://www.linqpad.ne
334
368
335
369
More documentation can be found in the [docs](./docs) folder.
336
370
371
+
See also:
372
+
373
+
-[README for SEBT.Portal.Web (front end)](./src/SEBT.Portal.Web/README.md)
374
+
-[README for Figma design token scripts](./src/SEBT.Portal.Web/design/scripts/README.md)
375
+
337
376
We use [Lightweight Architecture Decision Records](https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions)
338
377
for tracking architectural decisions, using [adr tools](https://github.com/npryce/adr-tools) to
339
378
store them in source control. These can be found in the [docs/adr](./docs/adr) folder.
0 commit comments