Welcome to the Deep Dive
A production-grade sentiment analysis service built with AWS serverless
- Single-table DynamoDB design with 3 GSIs
- Lambda with Function URL (not API Gateway)
- In-memory caching for warm invocations
- Circuit breakers per external service
- 1,230+ unit tests passing
- ~$2.50/mo dev environment cost
- 80-95% DynamoDB read reduction via caching
- <100ms p99 latency target
Architecture Overview
A serverless event-driven pipeline for sentiment analysis
Data Flow Pipeline
| ingestion | News fetcher (5min schedule) |
| analysis | Sentiment scorer (SNS trigger) |
| dashboard | REST API |
| notification | Alert evaluator & emailer |
| metrics | CloudWatch metrics (1min) |
Authentication
Multiple auth strategies for different user journeys
Try It: Create Anonymous Session
Configuration Management
User-defined watchlists with ticker tracking
Business Rules
- Max 2 configurations per user (free tier)
- Max 5 tickers per configuration
- Ticker symbols validated against exchange data
- Soft deletes preserve audit trail
Caching Strategy
60-second TTL in-memory cache. Invalidated on create/update/delete.
Try It: Create Configuration
{"name": "Tech Watchlist", "tickers": ["AAPL", "MSFT", "NVDA"]}
Try It: List Configurations
Sentiment Analysis
Real-time market sentiment from multiple sources
Try It: Get Sentiment for Configuration
External API Integration
Resilient adapters for third-party services
API Quota Status
Circuit Breaker
Prevent cascading failures with per-service circuit breakers
State Machine
Live Circuit Status
Traffic Generator
Generate synthetic traffic to demonstrate system behavior
Quick Start Commands
Run these commands from the interview/ directory:
Chaos Engineering
Inject failures to test resilience
Failure Injection Scenarios
These demonstrate what happens when external services fail. Watch how circuit breakers protect the system.
Simulate 500 errors from Tiingo. Circuit opens after 5 failures.
Simulate 500 errors from Finnhub. System falls back to Tiingo only.
Simulate slow responses. Shows timeout handling and fallback.
Simulate 429 from SendGrid. Emails queue for retry.
โ ๏ธ Interview Demo Note
In production, chaos experiments would be enabled via environment variables or feature flags. For this demo, we simulate the effects to show how the system would respond.
What to Observe
Caching Strategy
Multi-layer caching for performance and cost optimization
Cache Layers
| Layer | TTL | Savings | Pattern |
|---|---|---|---|
| Circuit Breaker | 60s | ~90% DynamoDB reads | Write-through |
| Quota Tracker | 60s | ~95% DynamoDB reads | Batched sync |
| User Configs | 60s | ~80% DynamoDB reads | Invalidate on mutate |
| Sentiment | 5min | ~70% CPU | Read-through |
| GSI Metrics | 60s | ~40% RCU | Read-through |
Observability
Logs, metrics, and traces for production debugging
Health Check
Testing Strategy
Comprehensive testing pyramid with oracle-based validation
Test Pyramid
- Moto for DynamoDB mocking
- responses for HTTP mocking
- pytest with coverage
- Fast feedback (<30s)
- Direct handler invocation
- Cross-component flows
- Mocked external APIs
- Contract validation
- Real AWS resources
- Synthetic data generators
- Test oracle validation
- TTL-based cleanup
Infrastructure
Terraform-managed AWS serverless stack
infrastructure/terraform/modules/
โโโ dynamodb/ # Table + GSIs + Backups
โโโ iam/ # Lambda roles
โโโ secrets/ # Secrets Manager
โโโ sns/ # Event fan-out
โโโ cognito/ # User pools
โโโ amplify/ # Frontend hosting
โโโ eventbridge/ # Schedules
- DynamoDB on-demand (pay per request)
- Lambda 128MB minimum memory
- Free tier maximization
- ~$2.50/mo dev environment
Environment Parity
| Feature | Dev | Preprod | Prod |
|---|---|---|---|
| DynamoDB | โ | โ | โ |
| Point-in-Time Recovery | โ | โ | โ |
| Daily Backups | โ | โ | โ |
| Amplify Hosting | โ | โ | โ |