Radar Backend Structure
Purpose: Scheduled AI-powered financial insights delivered to users automatically. Current Environment: Deploy todev using RadarStack-dev
Architecture Flow
Components
Lambda Functions (aws/radar/lambdas/):
orchestrator/handler.py- Daily schedule query and SQS publishingprocessor/handler.py- Consumes SQS, calls internal API, stores resultsapi/handler.py- REST endpoints for CRUD operations
aws/radar/stack.py):
- DynamoDB:
schedules(with GSI on nextRunDate),results - SQS: FIFO queue with dead-letter queue (DLQ)
- API Gateway: REST API with CORS enabled
- Secrets Manager: Internal API token storage
How to Contribute
Deploy to Dev
Adding New Features
1. New Schedule Type:- Update
stack.pyif infrastructure changes needed - Modify
processor/handler.pyto handle new radar type - Add prompt template to schedules table
- Edit
api/handler.pyto add route logic - Update
stack.pyAPI Gateway resource definitions - Deploy with
cdk deploy RadarStack-dev
- Edit
processor/handler.py - Update
requirements.txtif new dependencies needed - Test locally, then deploy
Key Files and What They Do
stack.py - CDK infrastructure definition
- Creates DynamoDB tables (schedules, results)
- Sets up Lambda functions with Docker images
- Configures SQS FIFO queue and DLQ
- Creates API Gateway with REST endpoints
- Sets up EventBridge daily trigger at 6am UTC
- Manages IAM permissions between services
lambdas/orchestrator/handler.py - Schedule discovery
- Triggered by EventBridge daily at 6am UTC
- Queries schedules table using GSI where
nextRunDate = today - Batches matching schedules (10 per batch)
- Sends to SQS FIFO queue grouped by user_id
- Returns count of queued schedules
lambdas/processor/handler.py - AI execution engine
- Triggered by SQS queue messages (batch of 10)
- Retrieves API token from Secrets Manager
- Calls internal chat API at
/api/chat/internal - Stores AI response in results table
- Calculates and updates next run timestamp
- Handles errors and updates status
lambdas/api/handler.py - REST API endpoints
- GET
/schedules- List user’s schedules - POST
/schedules- Create new schedule - GET/PUT/DELETE
/schedules/{id}- Manage individual schedule - GET
/results- List user’s results - GET
/results/{scheduleId}- Get results for specific schedule - POST
/trigger- Manually trigger a radar run
Data Models
Seedocs/radar-backend-architecture.md for detailed schemas.