How arda1228/untitled-arda-dogan-project works
Project type and purpose
• This is a serverless, microservice-style backend project built and deployed with AWS CDK.
• It provides four distinct API endpoints:
1. trip price by car
2. trip price by public transport
3. CO₂ emissions by car
4. CO₂ emissions by public transport
• Its goal is to reduce car dependency by making cost and emissions data available.
File structure
• Top level:
• cdk-api-stack/ – AWS CDK application defining the cloud infrastructure
• driving/driving-price/ – Python modules for driving cost calculations
• public-transport/public-transport-price/ – Python modules for public-transport cost calculations
• Inside cdk-api-stack/:
• app.py, cdk.json – CDK entrypoint & config
• cdk_api_stack/ – CDK stack definition, includes a HitCounter construct
• lambda/ – all Lambda handler code (co2_driving, co2_pt, co2, hitcount, etc.)
• tests/ – unit tests for stack
README
• Clarifies the four main components (price & CO₂, for car & public transport)
• States the project’s aims (reduce carbon footprint, encourage public transport)
Main components
a. AWS Cloud Boundary
• API Gateway – exposes four REST endpoints
• HitCounter layer – sits between API Gateway and each Lambda to record invocation counts (records to DynamoDB)
• Lambda functions (4 business-logic Lambdas + hitcount helper)
• DynamoDB table for hit counts
b. External services & data sources
• Vehicle Enquiry Service API (vehicle lookup)
• Citymapper API (public transport routing)
• Transport-API (public transport data)
• vehicles.csv – local dataset for fuel consumption calculations
c. Relationships & data flow
1. Client → API Gateway (4 endpoints)
2. API Gateway → HitCounter → specific Lambda (e.g., co2_driving)
3. Lambda executes:
– May query vehicles.csv for fuel efficiency
– Calls Vehicle Enquiry API or Transport APIs or Citymapper
4. Lambda returns JSON response → API Gateway → Client
5. HitCounter writes invocation record → DynamoDB
Architectural patterns & principles
• Serverless microservices: each endpoint = one Lambda
• Infrastructure as Code: AWS CDK for reproducible deployment
• Single Responsibility: separate modules for pricing vs. CO₂ logic; driving vs. public transport
• Observability: HitCounter + DynamoDB for basic usage metrics
Detail level
• Be explicit: each Lambda, each data store, each external API.
• Technology choices: AWS CDK (Python), Python 3.x Lambdas, DynamoDB, external REST APIs, CSV data file.
• Don’t overcomplicate: keep to components that exist in your file tree and CDK definitions.
– How clients access each of the four services
– How your CDK stack lays out API Gateway, HitCounter, Lambdas, and DynamoDB
– How each Lambda interacts with external APIs or local data sources
– How usage metrics flow back into DynamoDB