INTRODUCTION
When I started this project, my goal was simple to build something real on the cloud, I spent two weeks building a production ready web application with one simple goal to prove that you don't need expensive servers to ship real applications.
The result? A fully functional school management system that:
- Scales from 1 to 1 million requests automatically
- Costs less than $2/month to run
- Handles real-world problems (CORS, data integrity, query optimization)
This isn't a "Hello World" serverless app. This is a real project with real challenges, real solutions, and real learnings let me show you exactly how I built it.
What We're Building
Before diving into code, here's what the final system does:
User Perspective:
- View all school classes in a beautiful card-based interface
- Click on a class to see all enrolled students
- View detailed student information
- Add new students with a form
- Everything loads in under 200ms
Behind the Scenes:
- Serverless backend with zero servers to manage
- Auto-scaling to handle any traffic
- NoSQL database optimized for the access patterns
Database Design : Create DynamoDB Tables
First, I went to AWS DynamoDB and created two tables
Why this structure?
- ClassID as partition key for direct lookups
- GSI on ClassID for querying students by class
- Simple, flat structure (no complex joins)
Lambda Functions
I Created Four Lambda Functions
Each function handles one specific operation. I created them in Python 3.12 runtime.
Create REST API
Went to API Gateway console Created new REST API named SchoolManagementAPI
Created resources:
- /classes
- /classes/{classId}
- /classes/{classId}/students
- /students
- /students/{studentId}
For each resource, created the appropriate HTTP method:
Critical Setting: Enable "Use Lambda Proxy integration" for each method.
Enable CORS
This is where I spent 2 hours debugging! For each resource:
Click "Actions" → "Enable CORS"
Set:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET,POST,OPTIONS
Access-Control-Allow-Headers: Content-Type,X-Amz-Date,Authorization
Important: This creates an OPTIONS method automatically for preflight requests.
Deploy API
Click "Actions" → "Deploy API"
Select "[New Stage]"
Name it: dev
Copy the Invoke URL
curl https://school-management-app-saheed-ipaye.s3-website.eu-west-2.amazonaws.com/
/dev/classes
Frontend Deployment
Create S3 Bucket
- Went to S3 console
- Created bucket: school-management-app-saheed-ipaye
- Disabled "Block all public access"
Upload Frontend
- Saved React app as index.html
- Uploaded to bucket root
Configure Static Website Hosting
- Properties tab → Static website hosting
- Enable it
- Index document: index.html
Setup CloudFront
- Create CloudFront distribution
- Origin: Your S3 bucket
- Redirect HTTP to HTTPS
- Default root object: index.html
- Deploy (takes 5-15 minutes)
Challenges I Faced
Challenge 1: CORS Errors
Problem: Frontend couldn't call API - "Access-Control-Allow-Origin missing"
Root Cause: CORS needed configuration at BOTH Lambda AND API Gateway
Solution:
- Added headers in Lambda responses
- Enabled CORS on all API Gateway resources
- Created OPTIONS methods
- Deployed changes
Challenge 2: Slow Database Queries
Problem: Students not showing up quickly
Root Cause: Using scan() instead of query() on DynamoDB
Solution:
- Created Global Secondary Index (GSI) on ClassID
- Changed from scan to query operation
- Result: 500ms → 50ms (90% improvement!)
# Before (Slow)
response = table.scan(
FilterExpression='ClassID = :classid',
ExpressionAttributeValues={':classid': class_id}
)
# After (Fast)
response = table.query(
IndexName='ClassID-index',
KeyConditionExpression='ClassID = :classid',
ExpressionAttributeValues={':classid': class_id}
)
Conclusion
Building this serverless application taught me that:
You don't need expensive infrastructure to ship real apps
✅ Cloud services require thinking differently about architecture
✅ The best learning happens when debugging production issues
✅ Documentation and clean code matter
✅ Shipping something imperfect beats perfecting in isolation
If you're thinking about serverless but haven't started yet Start today. Build something simple, break it, fix it, and learn.
The cloud is the future. Might as well get familiar with it now.
AUTHOR: SAHEED IPAYE
Top comments (0)