This project is a serverless API designed to fetch review data from Google and ingest it into MongoDB.
- Serverless architecture using AWS Lambda and API Gateway
- Fetches review data from Google API
- Stores data in MongoDB
- CI/CD pipeline deploys code to AWS based on branch configuration
- Supports local testing with Serverless Offline plugin
To fetch review data from Google, you need to set up Google API credentials and configure them securely in the Serverless environment variables. Follow these steps:
- Set up Google API credentials with appropriate permissions to access review data.
The deployment pipeline is configured to deploy based on the following branch mappings:
- Development branch (
dev
): Code pushed to this branch triggers deployment to thebeta
environment. - Staging branch (
staging
): Code pushed to this branch triggers deployment to thestaging
environment. - Main branch (
main
): Code pushed to this branch triggers deployment to theprod
(production) environment.
Deployment to AWS regions is handled according to the pipeline settings configured for each environment.
The pipeline deploys the code to the AWS region configured in the pipeline settings.
To test the API locally, follow these steps:
-
Install Dependencies: Ensure you have Node.js and npm installed.
-
Clone the Repository: Clone this repository to your local machine.
-
Install Serverless Framework: Install the Serverless Framework globally if not already installed:
npm install -g serverless
-
Set Up Environment Variables: Create a .env file in the project root and add your Google API credentials:
GOOGLE_API_KEY_SECRET=<GOOGLE_API_KEY_SECRET> GOOGLE_PRIVATE_KEY=<your_google_private_key>
-
Start Serverless Offline: Start the Serverless Offline plugin for local testing:
serverless offline start
-
Test the API: Use tools like Postman or cURL to test the API endpoints locally. Example endpoint:
POST http://localhost:3000/api/reviews