Local Development Flow
How to set up and reset your local development environment.
flowchart TB
subgraph Docker["Docker Desktop"]
DDB["DynamoDB Local\n(port 8000)"]
COGNITO["Cognito Local\n(port 9229)"]
ADMIN["DynamoDB Admin\n(port 8001)"]
MINIO["MinIO S3\n(port 9000)"]
REDIS["Redis\n(port 6379)"]
end
subgraph Scripts["NPM Scripts"]
INIT["npm run db:init\nCreate table schema"]
SEED["npm run db:seed\nPopulate test data"]
RESET["npm run db:reset\nInit + Seed"]
CLEAN["npm run db:clean\nClear all data"]
end
subgraph Server["Backend Server"]
API["npm run server\n(port 3000)"]
end
Docker --> Scripts
INIT --> DDB
SEED --> DDB
API --> DDB
API --> MINIO
API --> REDIS
Database Reset Flow
What happens when you reset the database.
sequenceDiagram
participant Dev as Developer
participant NPM as npm run db:reset
participant Init as init-dynamodb.ts
participant Seed as seed-database.ts
participant DDB as DynamoDB Local
Dev->>NPM: Run reset command
NPM->>Init: Step 1: Initialize
Init->>DDB: Check if table exists
alt Table exists
DDB-->>Init: Table found
Init-->>NPM: Skip creation
else Table missing
Init->>DDB: Create table
DDB-->>Init: Table created
end
NPM->>Seed: Step 2: Seed data
Seed->>DDB: Insert 40 test items
Note over DDB: 6 users, 3 families,
posts, pets, etc. DDB-->>Seed: Data inserted Seed-->>Dev: Ready for testing!
posts, pets, etc. DDB-->>Seed: Data inserted Seed-->>Dev: Ready for testing!
Quick Start Commands
1. Start Docker Services
# From project root
cd src/IaaC/local && docker compose up -d
# Verify services are running
docker ps --format "table {{.Names}}\t{{.Status}}"
cd src/IaaC/local && docker compose up -d
# Verify services are running
docker ps --format "table {{.Names}}\t{{.Status}}"
2. Initialize & Seed Database + Cognito
# From backend directory
cd backend
# Full local reset (DynamoDB + Cognito users)
npm run local:reset
# Or run separately:
npm run db:init # Create DynamoDB table
npm run db:seed # Add test data
npm run cognito:seed # Create Cognito users
cd backend
# Full local reset (DynamoDB + Cognito users)
npm run local:reset
# Or run separately:
npm run db:init # Create DynamoDB table
npm run db:seed # Add test data
npm run cognito:seed # Create Cognito users
3. Start Backend Server
npm run server
Server running at http://localhost:3000
Server running at http://localhost:3000
4. Verify Everything Works
# Get Alice's profile
curl http://localhost:3000/users/me \
-H "X-User-Id: 11111111-1111-1111-1111-111111111111"
# Get Smith family posts
curl http://localhost:3000/families/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/posts \
-H "X-User-Id: 11111111-1111-1111-1111-111111111111"
curl http://localhost:3000/users/me \
-H "X-User-Id: 11111111-1111-1111-1111-111111111111"
# Get Smith family posts
curl http://localhost:3000/families/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/posts \
-H "X-User-Id: 11111111-1111-1111-1111-111111111111"
Cognito Authentication
For full authentication flow through the mobile app:
| Setting | Value |
|---|---|
| Cognito Endpoint | http://localhost:9229 |
| User Pool ID | local_5pYwgf9y |
| Client ID | 8rzc0746ffi4dl0zhkwxjjde1 |
| Test Password | TestPassword123! |
All test users use the same password: TestPassword123!
Test Users
| User ID | Role | Notes | |
|---|---|---|---|
alice@test.com |
11111111-1111-1111-1111-111111111111 |
Adult | Smith admin, guardian of David |
bob@test.com |
22222222-2222-2222-2222-222222222222 |
Adult | Smith member, guardian of David |
carol@test.com |
33333333-3333-3333-3333-333333333333 |
Adult | Member of Smith + Jones |
david@test.com |
44444444-4444-4444-4444-444444444444 |
Minor (14) | Requires guardian approval |
eve@test.com |
55555555-5555-5555-5555-555555555555 |
Adult | Jones family admin |
frank@test.com |
66666666-6666-6666-6666-666666666666 |
Adult | Jones + Solo families |
Test Families
| Family | Family ID | Members | Features |
|---|---|---|---|
| Smith Family | aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa |
Alice, Bob, Carol, David | Pets, posts, guardian setup |
| Jones Family | bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb |
Eve, Carol, Frank | Cross-family example |
| Solo Family | cccccccc-cccc-cccc-cccc-cccccccccccc |
Frank | Single member family |
Seeded Data Summary
| Entity Type | Count | Description |
|---|---|---|
| USER | 6 | Test users (adults + minor) |
| FAMILY | 3 | Smith, Jones, Solo |
| FAMILY_MEMBER | 8 | Membership records |
| GUARDIAN_RELATION | 2 | Alice & Bob → David |
| PET_MEMBER | 2 | Fluffy (cat), Max (dog) |
| FAMILY_POST | 3 | Sample posts |
| POST_COMMENT | 2 | Comments on posts |
| POST_LIKE | 6 | Likes on posts |
| COMMENT_LIKE | 1 | Like on comment |
| IMPORTANT_DATE | 3 | Birthdays, anniversary |
| PHONE_SHARING | 4 | Phone sharing settings |
| TOTAL | 40 |
NPM Scripts
Database (DynamoDB)
| Script | Command | Description |
|---|---|---|
| Initialize | npm run db:init |
Create table schema (idempotent) |
| Seed | npm run db:seed |
Populate test data |
| Reset | npm run db:reset |
Init + Seed (full DB reset) |
| Clean | npm run db:clean |
Clear all data from table |
Authentication (Cognito)
| Script | Command | Description |
|---|---|---|
| Seed Cognito | npm run cognito:seed |
Create test users in Cognito Local |
| Reset Cognito | npm run cognito:reset |
Delete and recreate Cognito users |
Full Environment
| Script | Command | Description |
|---|---|---|
| Full Reset | npm run local:reset |
Reset DynamoDB + Cognito (recommended) |
Troubleshooting
flowchart TD
START["API returns error"] --> Q1{"What error?"}
Q1 -->|"Connection refused\nport 8000"| A1["DynamoDB not running"]
A1 --> S1["docker compose up -d dynamodb"]
Q1 -->|"Table not found"| A2["Table doesn't exist"]
A2 --> S2["npm run db:init"]
Q1 -->|"Empty response"| A3["No data seeded"]
A3 --> S3["npm run db:seed"]
Q1 -->|"SQLite error\nin Docker logs"| A4["Database corrupted"]
A4 --> S4["docker compose up -d dynamodb --force-recreate\nnpm run db:reset"]
Q1 -->|"Timeout / Hanging"| A5["Service unhealthy"]
A5 --> S5["docker compose restart dynamodb\nnpm run db:reset"]
S1 --> VERIFY
S2 --> VERIFY
S3 --> VERIFY
S4 --> VERIFY
S5 --> VERIFY
VERIFY["Verify with:\ncurl localhost:3000/health"]
Common Issues
| Issue | Cause | Solution |
|---|---|---|
| API requests hang | DynamoDB Local corrupted | docker compose up -d dynamodb --force-recreate |
| Table not found | In-memory DB restarted | npm run db:reset |
| Invalid UUID error | Using old test IDs | Use UUIDs from seed output |
| CORS error in browser | Origin not allowed | Run from localhost:8100 or 4200 |
| Module not found | Wrong directory | Run npm commands from backend/ |
Admin UIs
| Service | URL | Purpose |
|---|---|---|
| DynamoDB Admin | localhost:8001 | Browse tables and data |
| MinIO Console | localhost:9001 | S3 bucket management |
| Mailpit | localhost:8025 | View sent emails |
| Traefik | localhost:8080 | Reverse proxy dashboard |