A serverless REST API for managing events, built with FastAPI and deployed on AWS using infrastructure as code. The application provides full CRUD operations with automatic scaling, high availability, and comprehensive testing.
API Endpoint: https://m4vehfzim8.execute-api.us-west-2.amazonaws.com/prod/
Try it out:
# Create an event
curl -X POST https://m4vehfzim8.execute-api.us-west-2.amazonaws.com/prod/events \
-H "Content-Type: application/json" \
-d '{
"title": "Tech Meetup",
"description": "Monthly tech meetup",
"date": "2024-12-01",
"location": "Seattle",
"capacity": 100,
"organizer": "Tech Community",
"status": "scheduled"
}'
# List all events
curl https://m4vehfzim8.execute-api.us-west-2.amazonaws.com/prod/events- β Full CRUD Operations: Create, read, update, and delete events
- β Event Filtering: Filter events by status
- β Partial Updates: Update specific fields without affecting others
- β Data Validation: Comprehensive input validation using Pydantic
- β Serverless Architecture: Auto-scaling with AWS Lambda
- β Property-Based Testing: Extensive test coverage with Hypothesis
- β Infrastructure as Code: Reproducible deployments with AWS CDK
- β RESTful Design: Follows REST conventions with proper HTTP status codes
βββββββββββββββ ββββββββββββββββ βββββββββββββββ ββββββββββββββββ
β Client βββββββΆβ API Gateway βββββββΆβ Lambda βββββββΆβ DynamoDB β
β (Browser/ β β (REST API) β β (FastAPI) β β (Events) β
β cURL) ββββββββ ββββββββ ββββββββ β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ ββββββββββββββββ
- API Gateway: Routes HTTP requests and handles CORS
- Lambda Function: Runs the FastAPI application (Python 3.11)
- DynamoDB: NoSQL database for event storage (on-demand billing)
- CloudWatch: Logs and monitoring
.
βββ backend/ # FastAPI application
β βββ main.py # Application entry point
β βββ models/ # Pydantic data models
β βββ services/ # Business logic layer
β βββ repositories/ # Data access layer
β βββ routers/ # API route definitions
β βββ tests/ # Unit, property, and integration tests
β βββ requirements.txt # Python dependencies
β
βββ infrastructure/ # AWS CDK infrastructure
β βββ app.py # CDK application entry point
β βββ stacks/ # CDK stack definitions
β β βββ main_stack.py # Main infrastructure stack
β βββ requirements.txt # CDK dependencies
β
βββ .kiro/specs/ # Feature specifications
βββ event-management-api/
βββ requirements.md # Feature requirements
βββ design.md # System design
βββ tasks.md # Implementation tasks
- Python 3.11+
- Node.js 18+ (for AWS CDK)
- AWS Account with configured credentials
- Docker (for CDK deployment)
-
Clone the repository
git clone <repository-url> cd <repository-name>
-
Set up the backend
cd backend python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
-
Run the development server
uvicorn main:app --reload
-
Access the API
- API: http://localhost:8000
- Interactive Docs: http://localhost:8000/docs
- Alternative Docs: http://localhost:8000/redoc
-
Install AWS CDK
npm install -g aws-cdk
-
Configure AWS credentials
aws configure
-
Bootstrap CDK (first time only)
cd infrastructure cdk bootstrap -
Deploy the stack
pip install -r requirements.txt cdk deploy
-
Get your API endpoint The deployment will output your API Gateway URL:
Outputs: MainStack.ApiGatewayUrl = https://xxxxxxxxxx.execute-api.us-west-2.amazonaws.com/prod/
| Method | Endpoint | Description |
|---|---|---|
| POST | /events |
Create a new event |
| GET | /events |
List all events |
| GET | /events?status={status} |
Filter events by status |
| GET | /events/{eventId} |
Get a specific event |
| PUT | /events/{eventId} |
Update an event |
| DELETE | /events/{eventId} |
Delete an event |
{
"eventId": "string (auto-generated UUID)",
"title": "string (required)",
"description": "string (required)",
"date": "string (required, YYYY-MM-DD format)",
"location": "string (required)",
"capacity": "integer (required, >= 0)",
"organizer": "string (required)",
"status": "string (required)"
}See detailed examples in:
- Backend README - Complete API documentation
- Infrastructure README - Deployment and testing
cd backend
pytest tests/ -v- Unit Tests: Test individual components
- Property-Based Tests: Verify correctness across random inputs (100 iterations each)
- Integration Tests: Test complete request/response flows
The application uses Hypothesis to verify correctness properties:
- Create-retrieve round trips
- Input validation completeness
- Partial update preservation
- Status filter correctness
- Error handling consistency
- Backend README: Detailed API documentation, usage examples, and troubleshooting
- Infrastructure README: Deployment guide, AWS resources, and monitoring
- Design Document: System architecture and design decisions
- Requirements: Feature requirements and acceptance criteria
- FastAPI (0.115.0): Modern Python web framework
- Pydantic (2.9.0): Data validation
- Boto3 (1.35.0): AWS SDK for Python
- Mangum (0.18.0): ASGI adapter for Lambda
- Hypothesis (6.115.0): Property-based testing
- AWS CDK (2.114.1): Infrastructure as code
- AWS Lambda: Serverless compute
- API Gateway: REST API management
- DynamoDB: NoSQL database
- CloudWatch: Logging and monitoring
- Pytest (8.3.0): Testing framework
- Moto (5.0.0): AWS service mocking
- HTTPX (0.27.0): HTTP client for testing
| Variable | Description | Default |
|---|---|---|
DYNAMODB_TABLE_NAME |
DynamoDB table name | events |
After deployment, the following resources are created:
- DynamoDB table with on-demand billing
- Lambda function (512 MB memory, 30s timeout)
- API Gateway REST API with CORS enabled
- IAM roles with least-privilege permissions
- CloudWatch log groups
Import Errors
# Ensure virtual environment is activated
source venv/bin/activate
pip install -r requirements.txtAWS Credentials
# Configure AWS CLI
aws configure
# Verify credentials
aws sts get-caller-identityDocker Not Running
# Start Docker Desktop and verify
docker psSee detailed troubleshooting guides in:
# View Lambda logs
aws logs tail /aws/lambda/MainStack-EventManagementApiLambda* --follow
# View recent errors
aws logs filter-log-events \
--log-group-name /aws/lambda/MainStack-EventManagementApiLambda* \
--filter-pattern "ERROR"Monitor in AWS CloudWatch:
- Lambda invocations, errors, duration
- API Gateway request count, latency, 4xx/5xx errors
- DynamoDB read/write operations, throttling
To remove all AWS resources:
cd infrastructure
cdk destroyWarning: This will delete the DynamoDB table and all event data.
See LICENSE file for details.
- Review the requirements and design
- Add tests for new features (unit and property-based)
- Follow the layered architecture pattern
- Update documentation
- Ensure all tests pass
For issues or questions:
- Check the troubleshooting sections in the READMEs
- Review CloudWatch logs for error details
- Consult the design and requirements documents
- Local Development: Make changes and test locally with
uvicorn - Run Tests: Verify with
pytest tests/ -v - Preview Changes: Use
cdk diffto see infrastructure changes - Deploy: Run
cdk deployto update AWS resources - Monitor: Check CloudWatch logs and metrics
- Iterate: Repeat as needed
Built with β€οΈ using FastAPI, AWS CDK, and modern serverless architecture.