A secure, scalable backend API for the VugaSafe GBV Case Management Platform in Rwanda. Built with Node.js, TypeScript, Express, and PostgreSQL.
- Case Reporting: Anonymous case submission with encrypted contact information
- Case Tracking: Public tracking using unique tracking codes
- Support Services Directory: Access to legal, medical, psychosocial, and shelter services
- Case Management: View, filter, and update case status
- Case Assignment: SuperAdmin can assign cases to specific admins
- Dashboard Statistics: Real-time analytics and reporting
- User Management: CRUD operations for admin users
- Service Management: Manage support services directory
- Audit Logs: Complete system activity tracking
- Data Export: CSV export functionality for cases
- System Analytics: Comprehensive dashboard statistics
- AES-256-GCM Encryption: For sensitive contact information
- JWT Authentication: Secure token-based authentication
- Role-Based Access Control (RBAC): Admin and SuperAdmin roles
- Rate Limiting: Configurable request throttling
- Input Validation: Zod schema validation
- Audit Logging: Complete action tracking
- Runtime: Node.js 18+
- Language: TypeScript
- Framework: Express.js
- Database: PostgreSQL with Sequelize ORM
- Authentication: JWT + bcrypt
- Validation: Zod
- Logging: Pino
- Testing: Jest + Supertest
- Documentation: Swagger/OpenAPI
- Containerization: Docker + Docker Compose
- Node.js 18+
- PostgreSQL 15+
- Redis 7+ (optional, for rate limiting)
- Docker & Docker Compose (for containerized deployment)
git clone <repository-url>
cd vugasafe-backend# Copy environment template
cp env.example .env
# Edit .env with your configuration
nano .envnpm install# Run migrations
npm run migrate
# Seed initial data
npm run seednpm run devThe API will be available at http://localhost:5000
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f api
# Stop services
docker-compose down# Build image
docker build -t vugasafe-backend .
# Run container
docker run -p 5000:5000 --env-file .env vugasafe-backendOnce the server is running, visit:
- Swagger UI:
http://localhost:5000/docs - Health Check:
http://localhost:5000/health - Readiness Check:
http://localhost:5000/ready
- Email:
admin@vugasafe.rw - Password:
admin123456
# Login to get token
curl -X POST http://localhost:5000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "admin@vugasafe.rw", "password": "admin123456"}'
# Use token in subsequent requests
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:5000/api/casesPOST /api/cases/report- Report a new caseGET /api/cases/track/:trackingCode- Track case statusGET /api/services- Get support servicesGET /api/services/:id- Get specific service
GET /api/cases- Get cases (with filters)GET /api/cases/:id- Get specific casePUT /api/cases/:id/status- Update case statusGET /api/auth/profile- Get user profile
GET /api/admin/users- Get all usersPOST /api/admin/users- Create userPUT /api/admin/users/:id- Update userDELETE /api/admin/users/:id- Delete userGET /api/admin/audit-logs- Get audit logsGET /api/admin/export/cases- Export cases to CSVGET /api/admin/dashboard- Get dashboard statisticsPUT /api/cases/:id/assign- Assign case to admin
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watch# Lint code
npm run lint
# Fix linting issues
npm run lint:fix
# Format code
npm run format
# Type checking
npm run type-check# Run migrations
npm run migrate
# Undo last migration
npm run migrate:undo
# Run seeders
npm run seed
# Undo seeders
npm run seed:undo| Variable | Description | Default |
|---|---|---|
DB_HOST |
PostgreSQL host | localhost |
DB_PORT |
PostgreSQL port | 5432 |
DB_NAME |
Database name | vugasafe_db |
DB_USER |
Database user | vugasafe_user |
DB_PASSWORD |
Database password | Required |
JWT_SECRET |
JWT signing secret | Required (32+ chars) |
ENCRYPTION_KEY_32B |
AES encryption key | Required (32 bytes) |
REDIS_HOST |
Redis host | Optional |
REDIS_PORT |
Redis port | 6379 |
NODE_ENV |
Environment | development |
PORT |
Server port | 5000 |
- Change Default Credentials: Update the default SuperAdmin password
- Strong Secrets: Use cryptographically strong JWT and encryption keys
- Environment Variables: Never commit
.envfiles to version control - HTTPS: Use HTTPS in production with proper SSL certificates
- Rate Limiting: Configure appropriate rate limits for your use case
fatal- System is unusableerror- Error conditionswarn- Warning conditionsinfo- General informationdebug- Debug informationtrace- Trace information
/health- Basic health check/ready- Readiness check (includes database connectivity)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue in the repository
- Contact the development team
- Check the API documentation at
/docs
- Initial release
- Complete API implementation
- Docker support
- Comprehensive testing
- Security features
- Documentation