Cdk_location_project
This project implements a web application to manage NGO locations, allowing visualization, creation, updating, and deletion of locations on an interactive map. Stack: AWS CDK, Dynamo, Lambda, API Gateway, S3, CloudFront, CloudFormation, Python, Boto, React 18, TypesScript, Vite, Tailwind, Leaflet
NGO Locations Project
This project implements a web application to manage NGO locations, allowing visualization, creation, updating, and deletion of locations on an interactive map.
AWS Architecture
AWS Services Used
- Amazon DynamoDB: NoSQL database for storing location information
- AWS Lambda: Serverless functions for handling CRUD operations
- Amazon API Gateway: REST API to expose the endpoints
- Amazon S3: Frontend application storage
- Amazon CloudFront: CDN for efficient and secure frontend delivery
Infrastructure as Code
- AWS CDK: Infrastructure definition and deployment using TypeScript/Python
- CloudFormation: Automatically generated by CDK for resource provisioning
Technology Stack
Backend
- Python 3.9
- AWS Lambda Functions
- DynamoDB
- API Gateway with CORS support
- boto3 (AWS SDK for Python)
Frontend
- React 18
- TypeScript
- Vite as build tool
- Tailwind CSS for styling
- Leaflet for map handling
- React-Leaflet for React integration
Project Structure
.
├── README.md
├── app.py # CDK entry point
├── lambda/ # Lambda Functions
│ ├── common.py # Shared code between functions
│ ├── create_location.py # Create location
│ ├── delete_location.py # Delete location
│ ├── get_locations.py # Get locations
│ └── update_location.py # Update location
├── frontend/ # React Application
│ ├── src/
│ │ ├── components/ # React components
│ │ └── App.tsx # Main component
│ └── package.json
├── scripts/ # Utility scripts
│ └── deploy_frontend.py # Frontend deployment script
└── cdk.json # CDK configuration
Features
- Complete CRUD for locations
- Interactive map visualization
- Responsive and user-friendly interface
- Automated deployment
- Serverless architecture
- CDN for optimized frontend delivery
- CORS handling
Deployment
Install dependencies:
npm install -g aws-cdk
python -m pip install -r requirements.txt
Build the frontend:
cd frontend
npm install
npm run build
cd ..
Deploy infrastructure:
cdk deploy
API Endpoints
- GET
/locations
- Retrieve all locations
- POST
/locations
- Create new location
- PUT
/locations/{id}
- Update existing location
- DELETE
/locations/{id}
- Delete location
Environment Variables
VITE_APP_API_URL
: API Gateway URL for frontend calls
Security
- S3 bucket configured with private access
- CloudFront with OAI for secure S3 bucket access
- API Gateway with configured CORS
- DynamoDB with restricted access through IAM roles
Monitoring
- CloudWatch Logs for Lambda functions
- CloudWatch Metrics for API Gateway
- S3 Access Logs (optional)
- CloudFront Access Logs (optional)