Skip to content

singhsayan/ecommerce-cloud-backend

Repository files navigation

E-Commerce Backend (AWS Serverless Architecture)

This project implements a complete backend for an e-commerce platform using AWS serverless technologies. It includes user registration, product management, and order placement via REST APIs. The architecture is deployed using Terraform (for core infrastructure) and the Serverless Framework (for function deployment).

Features

  • RESTful APIs for Users, Products, and Orders
  • Serverless architecture using AWS Lambda, API Gateway, and DynamoDB
  • User authentication via Amazon Cognito
  • Infrastructure provisioned via Terraform
  • CI/CD pipeline with GitHub Actions for automated deployments
  • Centralized logging and monitoring using CloudWatch
  • Optional product image/file storage with Amazon S3

Architecture Overview

Component Service Used
API Gateway HTTP interface
AWS Lambda Function execution
DynamoDB NoSQL storage
Amazon Cognito Authentication
S3 (optional) File/image storage
CloudWatch Logs and monitoring
Terraform Infrastructure setup
Serverless Framework Lambda deployment
GitHub Actions CI/CD pipeline

Screenshots

API Gateway Configuration

API Gateway

Lambda Function Deployments

Lambda Functions

DynamoDB Tables

DynamoDB Tables

CloudFormation Stack

CloudFormation Stack

Sample cURL Tests

Register User
Register User

Create Product
Create Product

Place Order
Place Order

Get User
Get User

Get Product
Get Product

Get Order
Get Order

Users Table View
My Users

Products Table View
My Products

Orders Table View
My Orders

Getting Started

Prerequisites

  • Node.js and npm
  • Terraform CLI
  • AWS CLI (configured with credentials)
  • Serverless Framework installed globally
    npm install -g serverless

Folder Structure

  • /terraform: Contains Terraform files for setting up infrastructure
  • /services: Contains Serverless services and Lambda functions

Deployment Instructions

1. Provision Infrastructure with Terraform

Navigate to the terraform folder and run:

cd terraform
terraform init
terraform apply

This will create:

  • DynamoDB tables
  • Cognito User Pool
  • API Gateway and supporting resources (if defined in Terraform)

2. Deploy Lambda Functions with Serverless Framework

Navigate to the Serverless function folder (e.g., services/) and run:

npx serverless deploy

This will deploy all Lambda functions defined in serverless.yml and hook them to API Gateway.


Teardown / Cleanup

To clean up all resources:

1. Remove Serverless Stack

npx serverless remove

2. Destroy Terraform Infrastructure

cd terraform
terraform destroy

Deploying with GitHub Actions

GitHub Actions is set up to automatically deploy the backend on push to the main branch.

To trigger:

  1. Push code changes to main:

    git push origin main
  2. GitHub Actions will:

    • Run Terraform (optional, if you define it in .github/workflows)
    • Run npx serverless deploy
    • Deploy latest code to AWS

Make sure your GitHub repo is configured with the correct AWS credentials via GitHub Secrets (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, etc.).


API Testing

You can test the endpoints using cURL or Postman. Example cURL commands are provided in the curl-*.png screenshots above.


License

This project is licensed under the MIT License.

About

A cloud-native e-commerce backend built for scalable APIs, automation, and reliable data handling.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published