Serverless Feedback Collection with AWS & MongoDB
Anwer Sadath Abdul Muttaliff | buildcloudwithanwer.co.uk
Businesses struggle with efficiently collecting and analyzing customer feedback. Data is often scattered, making meaningful insights difficult to extract.
We created a serverless feedback management system enabling businesses to:
Architecture diagram showing the serverless feedback collection flow
Exposes REST API endpoints for feedback submission
AWSProcesses requests & interacts with MongoDB
AWSStores customer feedback securely
MongoDBUser-friendly feedback submission form
ReactStage | Resource Used | Purpose |
---|---|---|
API Definition | API Gateway | Create REST endpoints (POST/GET /feedback) |
Data Processing | AWS Lambda | Handle requests and database operations |
Data Storage | MongoDB Atlas | Persist feedback documents |
User Interface | React (Vite) | Web form for feedback submission |
const { MongoClient } = require('mongodb');
const uri = process.env.MONGODB_URI;
exports.handler = async (event) => {
const client = new MongoClient(uri);
try {
await client.connect();
const collection = client.db("feedbackDB").collection("feedback");
if (event.httpMethod === 'POST') {
const feedback = JSON.parse(event.body);
await collection.insertOne(feedback);
return { statusCode: 201, body: 'Feedback saved' };
}
if (event.httpMethod === 'GET') {
const feedback = await collection.find().toArray();
return { statusCode: 200, body: JSON.stringify(feedback) };
}
} finally {
await client.close();
}
};
Lambda function configuration
API Gateway resource setup
POST method configuration
Deployed API endpoint
Feedback stored in MongoDB
React feedback submission form
No infrastructure to manage, scales automatically
HTTPS encryption, IAM permissions, MongoDB network restrictions
Pay-per-use pricing with free tiers available
NoSQL database accommodates varied feedback structures
Issue | Solution |
---|---|
"Missing Authentication Token" error | Ensure API is properly deployed and endpoint is correct |
Lambda KeyError for 'httpMethod' | Enable Proxy Integration or add Mapping Template |
Feedback not storing in MongoDB | Verify connection string and network access rules |
React frontend fails to start | Use Node.js 18+, reinstall dependencies if needed |