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
+
35
+
## Local Environment Set Up 🧰
36
+
14
37
> **Note:** The following steps assume you are working on macOS. Steps may differ if you are working on a different operating system.
15
38
16
-
### Prerequisites 👷
17
-
- The application backend is built with the .NET 10 SDK, which can be downloaded [here](https://dotnet.microsoft.com/en-us/download).
18
-
- Frontend packages and local development scripts are managed with [pnpm](https://pnpm.io/).
19
-
-[Docker](https://www.docker.com/) is required for packaging and running containers.
39
+
### 1. Make sure you have downloaded and installed prequisite software 👷
40
+
41
+
-[.NET 10 SDK](https://dotnet.microsoft.com/en-us/download) for running the back end
42
+
- The latest version of [nodeJS](https://nodejs.org/en)
43
+
-[pnpm](https://pnpm.io/installation/) for managing front end packages and development scripts
44
+
-[Docker](https://www.docker.com/) Desktop for running and managing containers (includes MSSQL database)
45
+
46
+
### 2. Clone repositories
47
+
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). 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.
20
63
21
-
### .NET Tools 🛠️
22
-
.NET tools are CLI utilities installed and managed using NuGet. Currently, we are using
23
-
the `nuget-license` tool for auditing backend dependency license. To install .NET tools,
24
-
run `dotnet tool restore` from the solution root. Needed tools are defined in the tools
25
-
manifest in `.config/dotnet-tools.json`.
64
+
To create your local .env file with configurations for the database and API, run this command in the root of the repo:
26
65
27
-
### Development 💻
28
66
```bash
29
-
pnpm install # Install dependencies
67
+
cp .env.example .env
30
68
```
31
-
***
69
+
70
+
You'll want do the same from within `/src/SEBT.Portal.Web`:
71
+
32
72
```bash
33
-
pnpm dev # Start both API and frontend
73
+
cp .env.example .env.local
34
74
```
35
75
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
91
+
92
+
- .NET tools are CLI utilities installed and managed using [NuGet](https://www.nuget.org/). Currently, we are using the
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):
94
+
- /src/SEBT.Portal.Infrastructure
95
+
- /src/SEBT.Portal.Api
96
+
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.
98
+
99
+
### 5. Start Services 💻
100
+
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).
102
+
103
+
```bash
104
+
docker compose up -d # Start all docker containers, including MSSQL Database and Mailpit for testing
38
105
```
39
106
40
-
### Docker Compose
41
107
```bash
42
-
# Start all services (MSSQL, Mailpit)
43
-
docker compose up -d
108
+
pnpm dev # Script to start both API (ie, `dotnet watch`) and frontend (ie, `next dev`)
109
+
```
110
+
111
+
To open the app, navigate to <https://localhost:3000>
112
+
113
+
## Development
114
+
115
+
### Other helpful commands
116
+
117
+
```bash
118
+
# Start frontend only
119
+
pnpm web:dev
44
120
45
121
# View logs
46
122
docker compose logs -f
@@ -52,16 +128,19 @@ docker compose down
52
128
docker compose down -v
53
129
```
54
130
55
-
#### Mailpit (Local Email Testing)
56
-
Mailpit captures all outgoing emails in development. Access the web UI at http://localhost:8025
131
+
### Mailpit (Local Email Testing)
132
+
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>
deploy/dc-*# DC-only changes (only DC builds in CI)
93
174
deploy/co-*# CO-only changes (only CO builds in CI)
94
175
```
95
176
96
177
**Shared Development:**
178
+
97
179
```bash
98
180
feature/*# Changes for all states (all states build in CI)
99
181
main # Production source for all states
@@ -121,21 +203,39 @@ STATE=dc dotnet run --project src/SEBT.Portal.Api
121
203
# Docker Compose uses STATE from .env
122
204
docker compose up
123
205
```
206
+
124
207
Only include sections you want to override; other settings fall back to `appsettings.json`!
125
208
126
209
### OIDC support
127
210
128
-
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:
214
+
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)
220
+
221
+
In `appsettings` under `SEBT.Portal.Api`, set:
129
222
130
-
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`.
223
+
-`Oidc:CompleteLoginSigningKey` (same value as `OIDC_COMPLETE_LOGIN_SIGNING_KEY`)
224
+
-`Oidc:DiscoveryEndpoint`
225
+
-`Oidc:ClientId`
226
+
-`Oidc:CallbackRedirectUri`
227
+
-`Oidc:LanguageParam` (optional)
131
228
132
-
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.
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).
133
232
134
233
### ID Proofing Requirements
135
234
136
235
PII data is only shown and editable to users who meet the ID proofing requirements configured within "IdProofingRequirements" and their current IAL status (for example, `address+view`, `email+view`, `phone+view`). Configure in `appsettings.json` or override with `appsettings.{state}.json`.
137
236
138
237
Example (`appsettings.json`):
238
+
139
239
```json
140
240
{
141
241
"IdProofingRequirements": {
@@ -154,62 +254,60 @@ The application uses Microsoft SQL Server as its database. This is propped up v
154
254
155
255
#### Configuration
156
256
157
-
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.
158
-
159
-
```bash
160
-
cp .env.example .env
161
-
```
162
-
163
-
Available environment variables:
257
+
Configuration is managed through environment variables.
164
258
259
+
Available environment variables for `.env` in the respository root:
165
260
**Database (for Docker Compose):**
261
+
166
262
-`MSSQL_SA_PASSWORD` - SQL Server SA password
167
263
-`MSSQL_DATABASE` - Database name
168
264
-`MSSQL_USER` - Database user
169
265
-`MSSQL_SERVER` - Server hostname (for local)
170
266
-`MSSQL_PORT` - Server port
171
267
172
268
**API**
269
+
173
270
-`JWTSETTINGS__SECRETKEY` - Secret key for JWT token signing. Must be at least 32 characters.
174
271
-`IDENTIFIERHASHER__SECRETKEY` - Secret key for HMAC-SHA256 hashing of Household Identifiers as needed. Must be at least 32 characters.
175
272
176
-
**OIDC (state IdP sign-in)**
177
-
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).
178
-
179
273
### Database Migrations
180
274
181
-
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.
182
276
183
277
#### Automatic Migrations
184
278
185
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.
186
280
187
281
#### Manual Migration Commands
188
282
189
-
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:
0 commit comments