This directory contains the serverless backend services for ZipCase, built using AWS Lambda, API Gateway, and the Serverless Framework.
The backend is organized into multiple services:
- API Service: Public API for third-party integrations (
/api) - App Service: Application backend for the web application (
/app) - Infrastructure: Shared cloud resources (
/infra)
/serverless/
├── api/ # Public API service
│ ├── handlers/ # API Lambda function handlers
│ └── serverless.yml # API service configuration
├── app/ # Application backend service
│ ├── handlers/ # App Lambda function handlers
│ └── serverless.yml # App service configuration
├── infra/ # Shared infrastructure
│ └── serverless.yml # Infrastructure resources
├── lib/ # Shared code libraries
│ ├── CaseProcessor.ts # Case processing logic
│ ├── QueueClient.ts # SQS queue client
│ └── StorageClient.ts # DynamoDB storage client
└── serverless-compose.yml # Service composition
The backend implements a two-stage processing workflow:
-
Case Search Stage:
- Requests are queued in the CaseSearchQueue
- The
processCaseSearchLambda finds case IDs in court portals - Cases are updated with a 'found' status once IDs are located
- Found cases are queued for data retrieval
-
Case Data Stage:
- Found cases are processed by the CaseDataQueue
- The
processCaseDataLambda retrieves full case details - Cases are updated with a 'complete' status
- Processing can happen in parallel for multiple cases
Each service can be deployed individually or as a group:
# Deploy all services
serverless deploy
# Deploy a specific service
cd app
serverless deploy
# Deploy to a specific stage
serverless deploy --stage prodKey environment variables used by the services:
CASE_SEARCH_QUEUE_URL: SQS queue for case search requestsCASE_DATA_QUEUE_URL: SQS queue for case data retrievalZIPCASE_DATA_TABLE: DynamoDB table for case dataPORTAL_URL: URL for the court portal
# Start local development server
serverless offline
# Run tests
npm test
# Run integration tests
npm run test:integrationRun ESLint to check for code style and potential issues:
npm run lintVerify TypeScript types with the TypeScript compiler:
npx tsc --noEmitRun tests for the backend services:
# Run all unit tests
npm test
# Run a specific test file
npm test -- path/to/test-file.test.ts
# Run tests with coverage report
npm test -- --coverage
# Run integration tests (these are typically skipped in CI)
npm run test:integrationTest files are located in:
/lib/__tests__/- Unit tests for shared libraries/app/handlers/__tests__/- Unit tests for app handlers/api/handlers/__tests__/- Unit tests for api handlers/__integration_tests__/- Integration tests
For thorough checking before committing, run the following sequence:
npm run lint && npx tsc --noEmit && npm testPOST /search- Submit case numbers for searchingGET /case/{caseNumber}- Retrieve case informationGET /portal-credentials- Get portal credentialsPOST /portal-credentials- Set portal credentialsGET /api-key- Get API keyPOST /api-key- Create API keyGET /webhook- Get webhook configurationPOST /webhook- Set webhook configuration
POST /search- Submit search (requires API key)GET /case/{caseNumber}- Get case (requires API key)
For more information, see the API handlers and serverless.yml configurations.