Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ AWS_BEDROCK_REGION=us-west-2
# Leaving both unset defaults to ALLOWED_USERS=danielnaab.
ALLOWED_USERS=danielnaab
ALLOWED_EMAIL_DOMAINS=flexion.us
# Outbound email to users (e.g. "your access was approved"), sent via
# Amazon SES using the default AWS credential chain and AWS_REGION.
# Leave unset in dev: emails are then logged (recipient + subject only),
# not sent, and the admin page reports "email not configured".
# Only the main deployment sets this on the server.
# EMAIL_FROM="Forms Lab <noreply@forms.labs.flexion.us>"
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ Follows [meta-knowledge-base](https://github.com/danielnaab/meta-knowledge-base)
- `src/services/auth/` — Authentication, sessions, user store (GitHub OAuth)
- `src/services/deployment/` — Deploy orchestration and metadata
- `src/services/notifications/` — Notification types and client
- `src/services/email/` — Outbound email to users (SES sender, logging fallback, templates)
- `src/services/content/` — Content rendering (markdown, github-permalink, catalog types)
- `src/services/storage/` — Persistence layer (SQLite project + cache stores)
- `src/services/variant-preferences/` — Per-user variant selection
Expand Down
13 changes: 13 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 33 additions & 2 deletions catalog/architecture/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ A single EC2 instance hosts all branch deployments. GitHub push webhooks trigger

| Component | Location | Role |
|-----------|----------|------|
| Pulumi project | `infrastructure/pulumi/` | Provisions EC2, EIP, security group |
| Pulumi project | `infrastructure/pulumi/` | Provisions EC2, EIP, security group, DNS, SES email identity |
| NixOS config | `infrastructure/nixos/` | Declares entire server state |
| Webhook listener | `src/webhook/` | Receives GitHub push events |
| Deploy script | `infrastructure/nixos/modules/deploy.nix` | Builds and deploys branches |
Expand All @@ -52,11 +52,42 @@ bun run cli nixos status # Check running services
bun run cli webhook setup # GitHub webhook configuration
```

## Outbound email

The `main` deployment emails users when an admin approves their access
request (`src/services/email/`, Amazon SES). Branch deployments never send
mail: `deploy.nix` writes `EMAIL_FROM` into `.env` only for `main`, and
without it the app logs instead of sending.

Pulumi provisions, when `domain` is configured: an SES domain identity,
the three Easy DKIM CNAME records in the hosted zone, and an instance-role
policy allowing `ses:SendEmail` on that identity only.

Manual steps (not automated):

1. **Check DKIM verification.** After `bun run cli infra up`, confirm the
records resolve and SES sees them:
```bash
dig +short CNAME <token>._domainkey.<domain> # tokens: aws sesv2 get-email-identity --email-identity <domain>
aws sesv2 get-email-identity --email-identity <domain> \
--query '{dkim: DkimAttributes.Status, sending: VerifiedForSendingStatus}'
```
Expect `dkim: SUCCESS` and `sending: true`. This can take up to 72 hours
after the records first resolve, and requires the domain's NS
delegation to point at the Pulumi hosted zone (`nameServers` output).
2. **Leave the SES sandbox.** New AWS accounts start in the SES sandbox,
where mail is delivered only to verified addresses and sends from the
app to anyone else fail (the admin page shows the error). Request
production access in the SES console (Account dashboard → Request
production access) for the region in `AWS_REGION`. Until AWS grants it,
treat approval emails as best-effort; check the account status with
`aws sesv2 get-account --query ProductionAccessEnabled`.

## Sources

- [EC2 with Pulumi](../decisions/infrastructure/ec2-with-pulumi.md)
- [Caddy reverse proxy](../decisions/infrastructure/caddy-reverse-proxy.md)
- [GitHub webhook deploys](../decisions/infrastructure/github-webhook-deploys.md)
- [Subpath routing](../decisions/infrastructure/subpath-routing.md)
- [Nix-built processes](../decisions/infrastructure/nix-built-processes.md)
- Canonical code: `infrastructure/pulumi/`, `infrastructure/nixos/`, `src/webhook/`
- Canonical code: `src/services/email/`, `infrastructure/pulumi/`, `infrastructure/nixos/`, `src/webhook/`
3 changes: 2 additions & 1 deletion catalog/architecture/software-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Core domain services. Each service directory has a `types.ts` (P3) and one or mo
- **`deployment/`** — GitHub API client and deployment metadata (branch state, commit info, PR status).
- **`forms/`** — Form resolution, validation, navigation, sessions, and submission. Internally contains sub-modules (`comparison/`, `filling-agent/`, `filling/`, `review/`, `shaping/`) that are implementation details; external callers see only the public interface at `services/forms/index.ts`. Shaping uses LLM-assisted commands with an atomic batch executor; each accepted batch produces one git commit plus a structured entry in the shaping log. See the [command-based shaping decision](../decisions/architecture/command-based-shaping.md).
- **`form-documents/`** — PDF → structured spec extraction pipeline. Uses Bedrock (Claude) to parse PDFs into `DataCollectionSpec`s, plus AcroForm field mapping and filling.
- **`email/`** — Outbound email to users (e.g. "your access was approved"). `EmailSender` interface with an Amazon SES implementation and a logging stand-in used when `EMAIL_FROM` is unset. Separate from `notifications/`, which alerts operators via Slack.
- **`evaluation/`** — Evaluation harness and LLM-as-judge kinds for scoring extraction and shaping output against fixtures.
- **`extraction/`** — Pluggable PDF extractor registry, enabling variant selection for evaluation and deployment.
- **`notifications/`** — Notification event types and Slack client used by the deploy pipeline.
Expand Down Expand Up @@ -139,7 +140,7 @@ Neither choice is wrong. What matters is that the choice is explicit. Drifting i

**Current state:**

- **Isolated:** USWDS (design-system only), Bedrock (`services/form-documents/`, `services/forms/shaping/`, `services/forms/filling-agent/`, `services/evaluation/` only), AI SDK tool-use (`services/form-documents/` and `services/forms/shaping/` only), `bun:sqlite` (`services/storage/`, `services/auth/user-store.ts` only), git CLI (`services/projects/form-project-repo.ts` only), `markdown-it` (`services/content/markdown.ts` only)
- **Isolated:** USWDS (design-system only), Bedrock (`services/form-documents/`, `services/forms/shaping/`, `services/forms/filling-agent/`, `services/evaluation/` only), AI SDK tool-use (`services/form-documents/` and `services/forms/shaping/` only), `bun:sqlite` (`services/storage/`, `services/auth/user-store.ts` only), git CLI (`services/projects/form-project-repo.ts` only), `markdown-it` (`services/content/markdown.ts` only), AWS SES SDK `@aws-sdk/client-sesv2` (`services/email/ses-sender.ts` only)
- **Embraced:** `hono/jsx` (design-system components), Hono routing (entrypoints), Bun (runtime)

When adding a new dependency, note the choice in the commit or ADR that introduces it. Future axes of change are cheaper to plan for when they're visible.
Expand Down
Loading
Loading