Skip to content

Latest commit

 

History

History
290 lines (229 loc) · 6.33 KB

File metadata and controls

290 lines (229 loc) · 6.33 KB

Rates API Deployment Checklist

Pre-Deployment Verification

1. Code Review

  • Implementation complete in src/api/rates.rs
  • Integration complete in src/main.rs
  • Module exported in src/api/mod.rs
  • No compilation errors
  • All tests passing

2. Configuration

  • Database connection configured (DATABASE_URL)
  • Redis cache configured (REDIS_URL) - Optional but recommended
  • Environment variables set:
    DATABASE_URL=postgresql://user:pass@localhost/aframp
    REDIS_URL=redis://localhost:6379
    HOST=0.0.0.0
    PORT=8000

3. Database Setup

  • Exchange rate tables exist
  • Seed data loaded (NGN/cNGN rates)
  • Database migrations applied

4. Testing

Unit Tests

cargo test --lib api::rates

Integration Tests

cargo test --test api_rates_test

Manual Testing

# Start the server
cargo run

# In another terminal, run tests
./test_rates_api.ps1  # Windows
# or
./test_rates_api.sh   # Linux/Mac

Expected Results

  • Single pair queries return 200 OK
  • Multiple pairs queries return 200 OK
  • All pairs query returns 200 OK
  • Invalid currency returns 400 Bad Request
  • Invalid pair returns 400 Bad Request
  • Cache headers present
  • CORS headers present
  • ETag support working

5. Performance Testing

Response Time

# Test cached response time
for i in {1..10}; do
  curl -w "@curl-format.txt" -o /dev/null -s \
    "http://localhost:8000/api/rates?from=NGN&to=cNGN"
done

Create curl-format.txt:

time_total: %{time_total}s\n

Expected:

  • First request: < 50ms
  • Cached requests: < 5ms
  • 95th percentile: < 100ms

Load Testing

# Using Apache Bench
ab -n 1000 -c 10 "http://localhost:8000/api/rates?from=NGN&to=cNGN"

Expected:

  • No errors
  • Consistent response times
  • Cache hit rate > 90%

6. Security Review

  • No authentication required (public endpoint)
  • CORS properly configured
  • Input validation implemented
  • SQL injection protection (using parameterized queries)
  • Rate limiting consideration documented
  • Consider adding rate limiting in production

7. Monitoring Setup

Metrics to Track

  • Request rate (requests per minute)
  • Response time (P50, P95, P99)
  • Cache hit rate
  • Error rate by type
  • Bandwidth usage

Logging

  • Request logging enabled
  • Error logging enabled
  • Cache hit/miss logging enabled

Alerts

  • Response time P95 > 100ms
  • Error rate > 1%
  • Cache hit rate < 85%
  • Service unavailable > 2 minutes

8. Documentation

  • API specification (docs/RATES_API.md)
  • Integration guide (docs/RATES_API_INTEGRATION.md)
  • Quick start guide (RATES_API_QUICK_START.md)
  • Implementation summary (RATES_API_IMPLEMENTATION.md)
  • Example code (examples/rates_api_demo.rs)
  • Test scripts (test_rates_api.ps1, test_rates_api.sh)

Deployment Steps

1. Build for Production

cargo build --release

2. Run Database Migrations

sqlx migrate run

3. Verify Configuration

# Check environment variables
echo $DATABASE_URL
echo $REDIS_URL
echo $HOST
echo $PORT

4. Start the Service

./target/release/aframp-backend

5. Verify Deployment

# Health check
curl http://localhost:8000/health

# Rates endpoint
curl http://localhost:8000/api/rates?from=NGN&to=cNGN

6. Monitor Initial Traffic

  • Check logs for errors
  • Monitor response times
  • Verify cache is working
  • Check database connections

Post-Deployment

1. Smoke Tests

Run the test suite against production:

# Update BASE_URL in test script
$BaseUrl = "https://api.aframp.com"
./test_rates_api.ps1

2. Frontend Integration

  • Update frontend to use production URL
  • Test rate display in UI
  • Verify caching works in browser
  • Test error handling

3. Performance Monitoring

  • Set up dashboards
  • Configure alerts
  • Monitor for 24 hours
  • Review metrics

4. Documentation Updates

  • Update API base URL in docs
  • Add production examples
  • Update integration guides
  • Notify frontend team

Rollback Plan

If issues occur:

1. Immediate Actions

# Stop the service
systemctl stop aframp-backend

# Revert to previous version
git checkout <previous-tag>
cargo build --release

# Restart service
systemctl start aframp-backend

2. Verify Rollback

curl http://localhost:8000/health

3. Investigate Issues

  • Check logs
  • Review error messages
  • Identify root cause
  • Plan fix

Success Criteria

Functional

  • All endpoints return correct responses
  • Error handling works properly
  • CORS headers present
  • Cache headers present

Performance

  • Response time < 5ms (cached)
  • Response time < 50ms (uncached)
  • Cache hit rate > 90%
  • No errors under normal load

Operational

  • Monitoring in place
  • Alerts configured
  • Logs accessible
  • Documentation complete

Known Limitations

  1. Rate Limiting: Not currently enforced at API level

    • Recommendation: Add rate limiting (100 req/min per IP)
    • Can be added via middleware in future update
  2. Historical Data: Not available yet

    • Future enhancement: /api/rates/history endpoint
    • Requires additional database schema
  3. WebSocket Support: Not implemented

    • Future enhancement for real-time updates
    • Current polling with 30s cache is sufficient
  4. Currency Pairs: Limited to NGN/cNGN

    • Easy to extend by adding to SUPPORTED_PAIRS
    • Requires external rate sources for non-pegged pairs

Support Contacts

Additional Resources

  • API Documentation: docs/RATES_API.md
  • Quick Start: RATES_API_QUICK_START.md
  • Integration Guide: docs/RATES_API_INTEGRATION.md
  • Example Code: examples/rates_api_demo.rs

Sign-Off

  • Backend Developer: _______________
  • QA Engineer: _______________
  • DevOps Engineer: _______________
  • Product Manager: _______________

Date: _______________


Deployment Status: Ready for Production ✅

All acceptance criteria met. The rates API is fully implemented, tested, and ready for deployment.