A data collection and monitoring system for tracking county jail populations in North Carolina. This system collects day-over-day changes to identify how long people are in the system and proactively support bail assistance and prevent failures-to-appear charges.
This project aims to:
- Track length of stay for individuals in county detention facilities
- Identify candidates for bail assistance programs
- Prevent failures-to-appear charges when someone has charges in one county while detained in another
- Provide data-driven insights for criminal justice reform
In this project, Serverless Framework handles most infrastructure (DynamoDB, SNS, Lambda) while Terraform manages only the foundational elements.
- Bootstrap: IAM setup for GitHub Actions CI/CD
- Main: Alert email parameter and S3 buckets
- Dev/Prod: Environment-specific configurations
- Serverless Framework: AWS Lambda functions, API Gateway, DynamoDB tables, and SNS alerts
- DynamoDB: Primary data store with global secondary indexes (GSIs) for efficient querying
- Scheduled Collection: Daily data collection from county sources
- REST API: Authenticated endpoints for data access
The primary DynamoDB table uses a single-table design:
- Primary Key:
detaineeId(partition) +timestamp(sort) - GSI 1:
status+createdDate- for active/inactive queries - GSI 2:
createdDate+timestamp- for time-based analysis
- AWS CLI configured
- Node.js 20.x
- Terraform
- Domain name for API endpoints
cd infra/terraform/bootstrap
terraform init
terraform plan
terraform applycd ../dev # or ../prod
terraform init
terraform plan
terraform applycd ../../serverless
npm install
cd api
npx serverless deploy --stage devTo add a new county data collection schedule, edit serverless/api/serverless.yml:
functions:
dataCollection:
events:
- schedule:
rate: cron(30 10 * * ? *)
input: '{"countyId": "new-county", "source": "new-county-portal"}'The system uses AWS Systems Manager Parameter Store for configuration:
/jaildata/alert-email- Email address for system alerts (set manually)/jaildata/alert-topic-arn- SNS topic ARN for system alerts (set by Serverless Framework)
cd serverless
npm testcd serverless
npm run lint
cd api
npx serverless offline- Add schedule configuration in
serverless.yml - Implement county-specific data collection logic in
handlers/data-collection.ts - Test with manual API calls before deploying scheduled version
This project is designed with privacy and justice reform in mind:
- No personal identifying information beyond what's publicly available
- Data used solely for advocacy and bail assistance
- Secure API access with authentication
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request