Deep DivesAPI

Tech Specification

Technical specification for the RawStack API component.

Runtime

LanguageTypeScript
RuntimeNode.js 22
FrameworkNestJS v11
Port3001

Key dependencies

PackagePurpose
@nestjs/cqrsCommand/Query bus and event bus
@nestjs/jwtJWT token signing and verification
passport-jwtJWT strategy for Passport
@prisma/clientDatabase ORM
ioredisRedis client
argon2Password hashing
zodRuntime schema validation
nest-commanderCLI commands (e.g. migrations)
dayjsDate utilities

Database schema

Users

ColumnTypeNotes
idUUIDPrimary key
emailStringUnique
hashStringArgon2 hashed password
rolesEnum[]ADMIN, VERIFIED_USER
createdAtDateTime
updatedAtDateTime
deletedAtDateTimeSoft delete

Tokens

ColumnTypeNotes
idUUIDPrimary key
tokenHashStringUnique hashed token value
userIdUUIDForeign key → Users
typeEnumLOGIN, PASSWORD_RESET, EMAIL_VERIFICATION
expiresAtDateTime

Environment variables

# Database
DATABASE_URL=postgresql://user:pass@localhost:5434/rawstack

# Redis
REDIS_HOST=localhost
REDIS_PORT=6379

# JWT
JWT_SECRET=your-strong-secret
ACCESS_TOKEN_TTL=900        # seconds
REFRESH_TOKEN_TTL=2592000   # seconds

# App
NODE_ENV=development
PORT=3001

Copy .env.dist to .env to get started.

Docker Compose services

ServiceImagePort
postgrespostgres:165434
redisredis:7-alpine6379
postgres-testpostgres:165433
redis-testredis:7-alpine6380