A comprehensive insurance calculation application built with FastAPI, AWS services, and modern Python practices.
- Python 3.9+
- Docker and Docker Compose
- Git
- Clone and setup the project:
git clone <your-repo-url>
cd cpp
chmod +x scripts/*.sh
./scripts/setup-local.sh- Start the application:
./scripts/start-app.sh- Run tests:
./scripts/test-local.sh- Test API endpoints:
./scripts/test-api.shThe application includes comprehensive testing at multiple levels:
# Run all unit tests
pytest tests/ -v
# Run with coverage
pytest tests/ -v --cov=app --cov=insurecalc --cov-report=html# Test API endpoints
./scripts/test-api.sh
# Test with Docker
docker-compose run test-runner# Linting
flake8 app/ insurecalc/ tests/
# Formatting
black --check app/ insurecalc/ tests/
# Type checking
mypy app/ insurecalc/
# Security scanning
bandit -r app/ insurecalc/
safety check- Health Check:
GET /health - API Docs:
GET /docs(Swagger UI) - Coverage Types:
GET /api/v1/public/coverage-types - Quote Request:
POST /api/v1/public/quote
{
"coverage_type": "auto",
"age": 30,
"location": "New York",
"coverage_amount": 50000,
"details": {}
}- Health Check:
{"status": "healthy"} - Quote: Returns quote with premium calculation
- Coverage Types: List of available insurance types
/app/ # FastAPI application
/routers/ # API endpoints
/models/ # Pydantic schemas
/data/ # DynamoDB DAO
/services/ # Business logic
/workflows/ # Step Functions
/insurecalc/ # Insurance calculation library
/infra/ # CDK infrastructure
/tests/ # Test suite
/scripts/ # Development scripts
- FastAPI: REST API framework
- DynamoDB: NoSQL database
- S3: Document storage
- Cognito: Authentication
- SES: Email notifications
- Step Functions: Workflow orchestration
- DynamoDB Local: Port 8000
- LocalStack: Port 4566 (S3, Cognito, SES)
- FastAPI: Port 8000
AWS_ENDPOINT_URL=http://localhost:4566
DYNAMODB_ENDPOINT_URL=http://localhost:8000
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
AWS_DEFAULT_REGION=us-east-1policies: Insurance policiesclaims: Insurance claimsusers: User information
- Application logs:
docker-compose logs app - Test logs:
docker-compose logs test-runner
- Coverage report:
htmlcov/index.html - Security reports:
bandit-report.json,safety-report.json
# Start all services
docker-compose up -d
# Create tables
python scripts/create-tables.py
# Start application
uvicorn app.main:app --reload# Deploy infrastructure
cd infra
cdk deploy
# Deploy application
# (Handled by CI/CD pipeline)- Port conflicts: Ensure ports 8000, 8001, 4566 are available
- Docker issues: Run
docker-compose downand restart - Table creation: Run
python scripts/create-tables.py - Dependencies: Run
pip install -r app/requirements.txt
export DEBUG=true
export LOG_LEVEL=DEBUGOnce the application is running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- All endpoints use HTTPS in production
- JWT tokens for authentication
- Input validation with Pydantic
- Security scanning with Bandit
- Dependency vulnerability checking with Safety