|
1 |
| -<!DOCTYPE html> |
2 |
| -<html lang="en"> |
3 |
| -<body> |
4 |
| - |
5 |
| -<h2>Overview 🔍</h2> |
6 |
| -<p>The <strong>Atithidev Serverless API</strong> is a powerful, lightweight solution for managing hosts and reviews efficiently. It leverages AWS Lambda for a fully serverless infrastructure, ensuring cost-effective scaling and high availability.</p> |
7 |
| - |
8 |
| -<h2>Features ✨</h2> |
9 |
| -<ul> |
10 |
| - <li><strong>Fetch hosts and reviews 📂</strong></li> |
11 |
| - <li><strong>Insert new reviews 📝</strong></li> |
12 |
| - <li><strong>Fully serverless with AWS Lambda ⚡</strong></li> |
13 |
| - <li><strong>Uses MongoDB Atlas as the database 🌴</strong></li> |
14 |
| - <li><strong>CI/CD automation with GitHub Actions 🤖</strong></li> |
15 |
| - <li><strong>TypeScript for type safety 💎</strong></li> |
16 |
| - <li><strong>Jest for API endpoint testing ✅</strong></li> |
17 |
| - <li><strong>Rate limiting to prevent abuse ⚖️</strong></li> |
18 |
| - <li><strong>Logging and monitoring with AWS CloudWatch 📊</strong></li> |
19 |
| -</ul> |
20 |
| - |
21 |
| -<h2>Tech Stack 🛠️</h2> |
22 |
| -<ul> |
23 |
| - <li><strong>Node.js (Runtime: 18.x) 💚</strong></li> |
24 |
| - <li><strong>TypeScript (Type-Safe Development) 💎</strong></li> |
25 |
| - <li><strong>MongoDB Atlas (Database) 🌴</strong></li> |
26 |
| - <li><strong>AWS Lambda (Serverless Compute) ⚡</strong></li> |
27 |
| - <li><strong>Redis (Caching Layer) 💨</strong></li> |
28 |
| -</ul> |
29 |
| - |
30 |
| -<h2>Security Features 🔐</h2> |
31 |
| -<ul> |
32 |
| - <li><strong>Rate Limiting:</strong> Prevents abuse and DDoS attacks.</li> |
33 |
| - <li><strong>Code Quality Enforcement:</strong> ESLint integrated into the pipeline.</li> |
34 |
| - <li><strong>Database Security:</strong> MongoDB Atlas secured with IP whitelisting.</li> |
35 |
| -</ul> |
36 |
| - |
37 |
| -<h2>Setup Instructions 🔧</h2> |
38 |
| -<h3>1. Clone the Repository 🔗</h3> |
39 |
| -<pre><code>git clone https://github.com/ap-dev-github/atithidev-db-api.git |
40 |
| -cd atithidev-db-api</code></pre> |
41 |
| - |
42 |
| -<h3>2. Install Dependencies 📦</h3> |
43 |
| -<pre><code>npm install</code></pre> |
44 |
| - |
45 |
| -<h3>3. Environment Variables 🔑</h3> |
46 |
| -<p>Create a <code>.env</code> file in the root directory and add your MongoDB connection string:</p> |
47 |
| -<pre><code>MONGO_URI=your-mongodb-connection-string</code></pre> |
48 |
| - |
49 |
| -<h3>4. Run Locally with Serverless Offline 🖥️</h3> |
50 |
| -<pre><code>npx serverless offline</code></pre> |
51 |
| - |
52 |
| -<h3>5. Deploy to AWS Lambda 🚀</h3> |
53 |
| -<pre><code>npx serverless deploy</code></pre> |
54 |
| - |
55 |
| -<h2>Endpoints 🌐</h2> |
56 |
| -<table> |
57 |
| - <tr> |
58 |
| - <th>Method</th> |
59 |
| - <th>Endpoint</th> |
60 |
| - <th>Description</th> |
61 |
| - </tr> |
62 |
| - <tr> |
63 |
| - <td>GET</td> |
64 |
| - <td>/</td> |
65 |
| - <td>Home route, checks if API is running</td> |
66 |
| - </tr> |
67 |
| - <tr> |
68 |
| - <td>GET</td> |
69 |
| - <td>/fetchHosts</td> |
70 |
| - <td>Fetch all hosts</td> |
71 |
| - </tr> |
72 |
| - <tr> |
73 |
| - <td>GET</td> |
74 |
| - <td>/fetchHosts/:state</td> |
75 |
| - <td>Fetch hosts by state</td> |
76 |
| - </tr> |
77 |
| - <tr> |
78 |
| - <td>POST</td> |
79 |
| - <td>/insert_review</td> |
80 |
| - <td>Insert a new review</td> |
81 |
| - </tr> |
82 |
| -</table> |
83 |
| -</code></pre> |
84 |
| - |
85 |
| -<h2>Security Features 🔐</h2> |
86 |
| -<ul> |
87 |
| - <li><strong>Rate Limiting:</strong> Prevents abuse and DDoS attacks.</li> |
88 |
| - <li><strong>Code Quality Enforcement:</strong> ESLint integrated into the pipeline.</li> |
89 |
| - <li><strong>Database Security:</strong> MongoDB Atlas secured with IP whitelisting.</li> |
90 |
| -</ul> |
91 |
| - |
92 |
| -<h2>Created By 👨💻</h2> |
93 |
| -<p><strong>Ayush Pandey</strong></p> |
94 |
| -<p>Email: <a href="mailto:ayushpandey.cs@gmail.com">ayushpandey.cs@gmail.com</a></p> |
95 |
| -<p>LinkedIn: <a href="https://www.linkedin.com/in/linkedap/" target="_blank">LinkedIn Profile</a></p> |
96 |
| - |
97 |
| -</body> |
98 |
| -</html> |
| 1 | +# Overview 🔍 |
| 2 | + |
| 3 | +## **Atithidev DB API – Scalable & Cost-Optimized Serverless Backend** |
| 4 | +> The Atithidev DB API is a scalable, serverless backend solution designed for efficiently managing profiles and reviews. Built using the Serverless Framework and deployed on AWS Lambda, it eliminates infrastructure management while ensuring cost-effective scaling and high availability. |
| 5 | +
|
| 6 | +--- |
| 7 | + |
| 8 | +## 💰 Cost Efficiency & Scalability |
| 9 | +- The API scales down to approximately **zero cost** for up to **1 million API requests per month**. |
| 10 | +- If there is no traffic, the infrastructure **automatically scales down** to near-zero cost, inclusive of AWS services like **S3, API Gateway**, and other dependencies. |
| 11 | +- When traffic increases, it **seamlessly scales up** using the AWS API Gateway to handle the load. |
| 12 | +- After exceeding **1 million requests**, costs are incurred based on **AWS Lambda pricing**. |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## 🚀 Fully Automated & Cost-Optimized CI/CD Deployment |
| 17 | +1. **Run Code Quality Checks** – ESLint for linting and Jest for API endpoint testing. |
| 18 | +2. **Automated CI/CD Based Testing & Deployment Optimization** |
| 19 | + - Installs the testing dependencies, runs tests, and removes them post-testing to reduce package size. |
| 20 | + - Prunes old versions from the cloud and **reduces dev dependencies** before packaging. |
| 21 | +3. **Deploy to AWS** – Automatically updates the AWS Lambda function and connects with API Gateway. |
| 22 | +4. **Verify and Activate Lambda** – Ensures the function is running seamlessly after deployment. |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## ✨ Features |
| 27 | +- Fetch reviews, post reviews, and find people (hosts) based on various parameters like state or ID. |
| 28 | +- **Fully serverless** with AWS Lambda ⚡ |
| 29 | +- Uses **MongoDB Atlas** as the database 🌴 |
| 30 | +- **CI/CD automation** with GitHub Actions 🤖 |
| 31 | +- **TypeScript** for type safety 💎 |
| 32 | +- Linting Test |
| 33 | +- **Jest** for API endpoint testing ✅ |
| 34 | +- **Rate limiting** to prevent abuse ⚖️ |
| 35 | +- **Logging and monitoring** with AWS CloudWatch 📊 |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## 🛠️ Tech Stack |
| 40 | +- **Node.js** (Runtime: 18.x) 💚 |
| 41 | +- **TypeScript** (Type-Safe Development) 💎 |
| 42 | +- **MongoDB Atlas** (Database) 🌴 |
| 43 | +- **AWS Lambda** (Serverless Compute) ⚡ |
| 44 | +- **AWS API Gateway** |
| 45 | +- **Serverless Framework** |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## 🔐 Security Features |
| 50 | +- ✅ **Rate Limiting** – Prevents abuse and DDoS attacks, ensuring API stability. |
| 51 | +- ✅ **Code Quality Enforcement** – Integrates ESLint into CI/CD to maintain high-quality code. |
| 52 | +- ✅ **Secure Key Management** – Uses GitHub Secrets Manager to protect API keys and environment variables. |
| 53 | +- ✅ **Database Security** – MongoDB Atlas is secured with **IP whitelisting**, restricting unauthorized access. |
| 54 | +- ✅ **AWS Cognito Authentication** – User authentication is managed via AWS Cognito, ensuring **secure access control**. |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +## 🔧 Setup Instructions |
| 59 | +### 1️⃣ Clone the Repository 🔗 |
| 60 | +```sh |
| 61 | +git clone https://github.com/ap-dev-github/atithidev-db-api.git |
| 62 | +``` |
| 63 | +###2️⃣ Install Dependencies 📦 |
| 64 | +```sh |
| 65 | +npm install |
| 66 | +``` |
| 67 | +###3️⃣ Environment Variables 🔑 |
| 68 | +```sh |
| 69 | +MONGO_URI=your-mongodb-connection-string |
| 70 | +``` |
| 71 | +###4️⃣ Run Locally with Serverless Offline 🖥️ |
| 72 | +```sh |
| 73 | +npx serverless offline |
| 74 | +``` |
| 75 | +###5️⃣ Deploy to AWS Lambda 🚀 |
| 76 | +```sh |
| 77 | +npx serverless deploy |
| 78 | +``` |
| 79 | +## 🌐 Endpoints |
| 80 | + |
| 81 | +| **Method**| **Endpoint** | **Description** | |
| 82 | +|-----------|----------------------|-----------------------------------------| |
| 83 | +| GET | `/` | Home route, checks if API is running | |
| 84 | +| GET | `/fetchHosts` | Fetch all hosts | |
| 85 | +| GET | `/fetchHosts/:state` | Fetch hosts by state | |
| 86 | +| POST | `/insert_review` | Insert a new review | |
| 87 | + |
| 88 | + |
| 89 | +## 👨💻Creator and Contributor |
| 90 | +### Ayush Pandey |
| 91 | + |
| 92 | +[🔗 Connect on LinkedIn](https://www.linkedin.com/in/linkedap/) |
| 93 | + |
| 94 | +📧 **Email:** [ayushpandey.cs@gmail.com](mailto:ayushpandey.cs@gmail.com) |
0 commit comments