|
1 | | -# Serverless Lambda Project |
| 1 | +# Serverless Newsletter Subscription System |
2 | 2 |
|
3 | | -This project is a serverless application designed to handle user subscriptions efficiently. It leverages several AWS services including Lambda, CloudFront, S3, DynamoDB, and SES. |
| 3 | +A serverless web application that handles newsletter subscriptions automatically using AWS services. When users subscribe, they receive a confirmation email, the admin is notified, and the subscription data is stored in a database - all without managing any servers! |
4 | 4 |
|
5 | | -## Functionality |
6 | | -- **User Subscription:** Users can subscribe to the website. Upon subscription, an email notification is sent to both the user and the site administrator. |
7 | | -- **Data Storage:** User subscription data is securely stored in DynamoDB, ensuring easy access and management. |
| 5 | +> **Note**: This is a demo project built to learn AWS serverless architecture. The website template is for demonstration purposes only. |
8 | 6 |
|
9 | | -## Live Demo |
10 | | -You can check out the live project here: [Live Link](https://jhgalkj.xyz/) |
| 7 | +--- |
11 | 8 |
|
12 | | -## Problem Solved |
13 | | -This application simplifies the subscription process for websites, automating email notifications and data management, which enhances user experience and reduces manual efforts for site administrators. |
| 9 | +## π Live Demo |
| 10 | + |
| 11 | +**Check it out**: [https://jhgalkj.xyz/](https://jhgalkj.xyz/) |
| 12 | + |
| 13 | +Try subscribing with your email to see the serverless workflow in action! |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## π― What Does This Project Do? |
| 18 | + |
| 19 | +This application handles the complete newsletter subscription workflow: |
| 20 | + |
| 21 | +1. **User subscribes** on the website with their email |
| 22 | +2. **Lambda function** processes the subscription |
| 23 | +3. **Email sent to user** confirming their subscription (via SES) |
| 24 | +4. **Email sent to admin** notifying them of the new subscriber (via SES) |
| 25 | +5. **Data stored** in DynamoDB for future reference |
| 26 | + |
| 27 | +All of this happens automatically, without any server management! |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## ποΈ AWS Services Used |
| 32 | + |
| 33 | +### **Amazon S3** |
| 34 | +- **What it does**: Stores the static website files (HTML, CSS, JavaScript, images) |
| 35 | +- **Why I used it**: S3 is perfect for hosting static websites - it's cheap, reliable, and scales automatically |
| 36 | + |
| 37 | +### **Amazon CloudFront** |
| 38 | +- **What it does**: Content Delivery Network (CDN) that delivers the website to users worldwide |
| 39 | +- **Why I used it**: Makes the website load super fast by caching content in edge locations close to users, plus provides HTTPS |
| 40 | + |
| 41 | +### **AWS Lambda** |
| 42 | +- **What it does**: Runs the subscription processing code without needing to manage servers |
| 43 | +- **Why I used it**: I only pay when someone subscribes (pay-per-use), and it scales automatically from 0 to thousands of requests |
| 44 | + |
| 45 | +### **Amazon DynamoDB** |
| 46 | +- **What it does**: NoSQL database that stores subscriber information |
| 47 | +- **Why I used it**: Serverless database that scales automatically and has millisecond response times |
| 48 | + |
| 49 | +### **Amazon SES (Simple Email Service)** |
| 50 | +- **What it does**: Sends confirmation emails to subscribers and notification emails to admin |
| 51 | +- **Why I used it**: Reliable, cost-effective email service that integrates seamlessly with Lambda |
| 52 | + |
| 53 | +### **Amazon API Gateway** |
| 54 | +- **What it does**: Creates the API endpoint that the website calls when users subscribe |
| 55 | +- **Why I used it**: Acts as the "front door" for the Lambda function, handling HTTP requests from the website |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +## π How It Works - Complete Workflow |
| 60 | + |
| 61 | +Here's exactly what happens when someone subscribes: |
| 62 | + |
| 63 | +### **Step-by-Step Process:** |
| 64 | + |
| 65 | +``` |
| 66 | +1. User visits website (CloudFront β S3) |
| 67 | + β |
| 68 | +2. User enters email and clicks "Subscribe" |
| 69 | + β |
| 70 | +3. Website sends request to API Gateway |
| 71 | + β |
| 72 | +4. API Gateway triggers Lambda function |
| 73 | + β |
| 74 | +5. Lambda function processes the subscription: |
| 75 | + - Validates the email |
| 76 | + - Stores data in DynamoDB |
| 77 | + - Sends confirmation email to user (SES) |
| 78 | + - Sends notification email to admin (SES) |
| 79 | + β |
| 80 | +6. User sees "Successfully subscribed!" message |
| 81 | + β |
| 82 | +7. User receives confirmation email |
| 83 | + β |
| 84 | +8. Admin receives notification email |
| 85 | +``` |
| 86 | + |
| 87 | +### **Visual Flow:** |
| 88 | + |
| 89 | +``` |
| 90 | +βββββββββββββββ |
| 91 | +β User β |
| 92 | +ββββββββ¬βββββββ |
| 93 | + β |
| 94 | + βΌ |
| 95 | +βββββββββββββββββββ ββββββββββββ |
| 96 | +β CloudFront ββββββββ€ S3 β |
| 97 | +β (CDN) β β (Website)β |
| 98 | +ββββββββββ¬βββββββββ ββββββββββββ |
| 99 | + β |
| 100 | + βΌ |
| 101 | +βββββββββββββββββββ |
| 102 | +β API Gateway β |
| 103 | +ββββββββββ¬βββββββββ |
| 104 | + β |
| 105 | + βΌ |
| 106 | +βββββββββββββββββββ ββββββββββββββββ ββββββββββββ |
| 107 | +β Lambda βββββββΊβ DynamoDB β β SES β |
| 108 | +β (Function) β β (Database) β β (Email) β |
| 109 | +βββββββββββββββββββ ββββββββββββββββ ββββββ¬ββββββ |
| 110 | + β |
| 111 | + βΌ |
| 112 | + ββββββββββββββββββββββ |
| 113 | + β User & Admin β |
| 114 | + β Receive Emails β |
| 115 | + ββββββββββββββββββββββ |
| 116 | +``` |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## π― Real-World Problem Solved |
| 121 | + |
| 122 | +### **The Traditional Approach (Without Serverless):** |
| 123 | + |
| 124 | +To build a subscription system the old way, you would need: |
| 125 | +- β A server running 24/7 (costs money even when no one is subscribing) |
| 126 | +- β Manual server maintenance, security patches, and updates |
| 127 | +- β Setting up and managing an email server or third-party integration |
| 128 | +- β Database server setup and maintenance |
| 129 | +- β Load balancer if you expect high traffic |
| 130 | +- β Manual scaling during traffic spikes |
| 131 | + |
| 132 | +**Monthly Cost**: $20-$100+ for a server running 24/7 |
| 133 | + |
| 134 | +### **The Serverless Approach (This Project):** |
| 135 | + |
| 136 | +With serverless architecture: |
| 137 | +- β
No servers to manage - AWS handles everything |
| 138 | +- β
Pay only when someone subscribes (could be $0-$5/month for moderate traffic) |
| 139 | +- β
Automatically scales from 0 to thousands of subscriptions |
| 140 | +- β
Built-in email service (SES) |
| 141 | +- β
Serverless database (DynamoDB) |
| 142 | +- β
No maintenance required |
| 143 | + |
| 144 | +**Monthly Cost**: ~$1-$5 for hundreds of subscribers (mostly under AWS free tier!) |
| 145 | + |
| 146 | +### **Benefits:** |
| 147 | +- **Cost-Effective**: Only pay for what you use |
| 148 | +- **Scalable**: Handles 1 subscriber or 10,000 subscribers automatically |
| 149 | +- **Reliable**: 99.99% uptime guaranteed by AWS |
| 150 | +- **Fast**: Global content delivery via CloudFront |
| 151 | +- **Secure**: HTTPS, encryption, and AWS security built-in |
| 152 | +- **No Maintenance**: No servers to patch or update |
| 153 | + |
| 154 | +--- |
| 155 | + |
| 156 | +## π Project Structure |
| 157 | + |
| 158 | +``` |
| 159 | +serverless-lambda-project/ |
| 160 | +βββ index.html # Main website page with subscription form |
| 161 | +βββ css/ # Website styling |
| 162 | +βββ js/ # Frontend JavaScript (handles form submission) |
| 163 | +βββ img/ # Website images |
| 164 | +βββ README.md # This file |
| 165 | +``` |
| 166 | + |
| 167 | +--- |
| 168 | + |
| 169 | +## π‘ What I Learned |
| 170 | + |
| 171 | +This project taught me: |
| 172 | +- β
How to build serverless applications on AWS |
| 173 | +- β
Integrating multiple AWS services together |
| 174 | +- β
Creating Lambda functions to process data |
| 175 | +- β
Using API Gateway to expose Lambda functions |
| 176 | +- β
Sending automated emails with SES |
| 177 | +- β
Storing data in DynamoDB |
| 178 | +- β
Hosting static websites with S3 and CloudFront |
| 179 | +- β
Cost optimization with serverless architecture |
| 180 | + |
| 181 | +--- |
| 182 | + |
| 183 | +## π Course Reference |
| 184 | + |
| 185 | +This project was built following Section 2 of: |
| 186 | +**AWS Mastery: Hands-On Cloud Projects for Engineers** on Udemy |
| 187 | + |
| 188 | +Course Link: [Udemy Course](https://www.udemy.com/course/aws-mastery-hands-on-cloud-projects-for-engineers/) |
| 189 | + |
| 190 | +--- |
| 191 | + |
| 192 | +## π° Estimated Cost |
| 193 | + |
| 194 | +**AWS Free Tier includes:** |
| 195 | +- Lambda: 1M free requests/month |
| 196 | +- DynamoDB: 25GB storage + 25 write/read capacity units |
| 197 | +- S3: 5GB storage + 20,000 GET requests |
| 198 | +- CloudFront: 50GB data transfer + 2M requests |
| 199 | +- SES: 62,000 emails/month (when called from Lambda) |
| 200 | + |
| 201 | +**For moderate usage (100-500 subscribers/month):** |
| 202 | +- Lambda: $0 (within free tier) |
| 203 | +- DynamoDB: $0 (within free tier) |
| 204 | +- S3: $0.50 |
| 205 | +- CloudFront: $1-2 |
| 206 | +- SES: $0 (within free tier) |
| 207 | + |
| 208 | +**Total: ~$1-3/month** π |
| 209 | + |
| 210 | +--- |
| 211 | + |
| 212 | +## π Key Features |
| 213 | + |
| 214 | +β
Serverless architecture (no server management) |
| 215 | +β
Automatic email confirmation to subscribers |
| 216 | +β
Admin notification emails |
| 217 | +β
Data storage in DynamoDB |
| 218 | +β
Fast global content delivery |
| 219 | +β
HTTPS enabled |
| 220 | +β
Auto-scaling from 0 to thousands of requests |
| 221 | +β
Cost-effective (pay-per-use model) |
| 222 | + |
| 223 | +--- |
| 224 | + |
| 225 | +## π§ Contact |
| 226 | + |
| 227 | +For questions or feedback about this project, feel free to open an issue or reach out! |
| 228 | + |
| 229 | +--- |
| 230 | + |
| 231 | +**Built with βοΈ AWS Serverless Services |
0 commit comments