Skip to content

Tarunchintakunta/cpp-sriraj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Insurance Calculation Application

A comprehensive insurance calculation application built with FastAPI, AWS services, and modern Python practices.

🚀 Quick Start

Prerequisites

  • Python 3.9+
  • Docker and Docker Compose
  • Git

Local Development Setup

  1. Clone and setup the project:
git clone <your-repo-url>
cd cpp
chmod +x scripts/*.sh
./scripts/setup-local.sh
  1. Start the application:
./scripts/start-app.sh
  1. Run tests:
./scripts/test-local.sh
  1. Test API endpoints:
./scripts/test-api.sh

🧪 Testing Guide

Automated Testing

The application includes comprehensive testing at multiple levels:

1. Unit Tests

# Run all unit tests
pytest tests/ -v

# Run with coverage
pytest tests/ -v --cov=app --cov=insurecalc --cov-report=html

2. Integration Tests

# Test API endpoints
./scripts/test-api.sh

# Test with Docker
docker-compose run test-runner

3. Code Quality Tests

# Linting
flake8 app/ insurecalc/ tests/

# Formatting
black --check app/ insurecalc/ tests/

# Type checking
mypy app/ insurecalc/

# Security scanning
bandit -r app/ insurecalc/
safety check

Manual Testing

1. API Endpoints

  • 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

2. Test Data

{
  "coverage_type": "auto",
  "age": 30,
  "location": "New York",
  "coverage_amount": 50000,
  "details": {}
}

3. Expected Responses

  • Health Check: {"status": "healthy"}
  • Quote: Returns quote with premium calculation
  • Coverage Types: List of available insurance types

🏗️ Architecture

Application Structure

/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

Services

  • FastAPI: REST API framework
  • DynamoDB: NoSQL database
  • S3: Document storage
  • Cognito: Authentication
  • SES: Email notifications
  • Step Functions: Workflow orchestration

🔧 Development

Local Services

  • DynamoDB Local: Port 8000
  • LocalStack: Port 4566 (S3, Cognito, SES)
  • FastAPI: Port 8000

Environment Variables

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-1

Database Tables

  • policies: Insurance policies
  • claims: Insurance claims
  • users: User information

📊 Monitoring

Logs

  • Application logs: docker-compose logs app
  • Test logs: docker-compose logs test-runner

Metrics

  • Coverage report: htmlcov/index.html
  • Security reports: bandit-report.json, safety-report.json

🚀 Deployment

Local Deployment

# Start all services
docker-compose up -d

# Create tables
python scripts/create-tables.py

# Start application
uvicorn app.main:app --reload

Production Deployment

# Deploy infrastructure
cd infra
cdk deploy

# Deploy application
# (Handled by CI/CD pipeline)

🐛 Troubleshooting

Common Issues

  1. Port conflicts: Ensure ports 8000, 8001, 4566 are available
  2. Docker issues: Run docker-compose down and restart
  3. Table creation: Run python scripts/create-tables.py
  4. Dependencies: Run pip install -r app/requirements.txt

Debug Mode

export DEBUG=true
export LOG_LEVEL=DEBUG

📚 API Documentation

Once the application is running, visit:

🔒 Security

  • All endpoints use HTTPS in production
  • JWT tokens for authentication
  • Input validation with Pydantic
  • Security scanning with Bandit
  • Dependency vulnerability checking with Safety

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published