Skip to content

taleofddh/taleofddh-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

169 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Tale of DDH API

Multi-module serverless Lambda repository with automated deployment scripts and comprehensive CI/CD workflows

Node.js Version AWS Lambda Serverless License


πŸ“‹ Table of Contents


🎯 Overview

This project is a serverless API built with AWS Lambda functions using the Serverless Framework. The architecture promotes modularity, scalability, and maintainability across multiple independent Lambda services. Each module is deployed independently while sharing common deployment automation and CI/CD workflows.

✨ Key Features

  • πŸ—οΈ Multi-module serverless architecture
  • πŸ€– Automated deployment scripts
  • πŸ”„ Comprehensive CI/CD workflows
  • 🎯 Smart change detection
  • 🌍 Multi-environment support (dev, prod)
  • ⚑ Parallel processing for installations and deployments
  • πŸ“Š Detailed progress reporting

πŸ—οΈ Architecture

πŸ”§ Serverless Lambda Architecture

The repository follows a multi-module serverless architecture where each Lambda module:

  • πŸ”„ Operates as an independent microservice
  • πŸ“¦ Has its own package.json, handler.js, and serverless.yml configuration
  • πŸš€ Can be deployed independently to different environments (dev, prod)
  • 🀝 Shares common deployment automation scripts and workflows

πŸ“¦ Lambda Modules

The repository contains 10 Lambda modules:

Module Purpose Key Features
οΏ½β€πŸ’Όa admin Administrative operations Admin APIs, CSV processing, email integration
οΏ½ authi Authentication and authorization service User management, security, CSV processing
πŸ“ blog Blog management APIs Blog posts, content management, storage
βš™οΈ core Core business logic APIs Fundamental application functionality
οΏ½ emtail Email service APIs Email notifications, mail parsing
�️* gallery Gallery and media management Image galleries, CloudFront distribution, media storage
πŸ”— integration Third-party integrations Gmail, WhatsApp, Google Drive, etc.
οΏ½ linuk Link management APIs URL shortening, link tracking
🏒 org Organization management APIs About us, people management, role-based menus
πŸ“ request Request handling APIs Request processing, management

βš™οΈ Deployment Automation System

The project includes a comprehensive deployment automation system with:

  • πŸ› οΈ Development Scripts: Automated installation and deployment scripts for local development
  • πŸ”„ GitHub Actions Workflow: CI/CD pipeline for production deployments
  • 🎯 Change Detection: Smart deployment that only deploys modules with changes
  • 🌍 Multi-Environment Support: Support for dev and prod environments

πŸ› οΈ Development Setup

πŸ“‹ Prerequisites

Before getting started, ensure you have the following installed:

Requirement Version Installation
🟒 Node.js >= 22.0.0 Download
πŸ“¦ npm >= 10.0.0 Included with Node.js
☁️ AWS CLI Latest pip install awscli
⚑ Serverless Framework v4.x npm install -g serverless
πŸ”§ Git Latest Download

☁️ AWS Configuration

πŸ”§ Local Development

Set up AWS credentials using a profile (recommended):

# Configure AWS CLI with your profile
aws configure --profile taleofddh

# Set the profile for this project
export AWS_PROFILE=taleofddh

⚑ Serverless Framework v4 Authentication

πŸ”§ Local Development

Get your access key from Serverless Dashboard and set it:

# Set Serverless access key
export SERVERLESS_ACCESS_KEY=your_access_key_here

πŸ€– CI/CD (GitHub Actions)

The repository uses GitHub Secrets for AWS credentials and Serverless authentication:

  • AWS_ACCESS_KEY_ID - AWS access key ID
  • AWS_SECRET_ACCESS_KEY - AWS secret access key
  • SERVERLESS_ACCESS_KEY - Serverless Framework v4 access key

πŸ“₯ Installation

  1. πŸ“₯ Clone the repository:
git clone https://github.com/taleofddh/taleofddh-api.git
cd taleofddh-api
  1. πŸ“¦ Install dependencies for all Lambda modules:
# Install dependencies for all modules automatically
npm run install:all

# Or install manually for a specific module
cd auth
npm install

The install:all script will:

  • πŸ” Discover all Lambda modules automatically
  • ⚑ Install dependencies in parallel for faster setup
  • ⏭️ Skip modules with no changes (smart installation)
  • πŸ“Š Provide detailed progress reporting

πŸ“œ Script Usage

The repository provides automated scripts for common development and deployment tasks:

πŸ“¦ Installation Script

Install dependencies for all Lambda modules:

# Basic installation (installs only modules with changes)
npm run install:all

# Force install all modules regardless of changes
node scripts/install.js --force

# Install with custom concurrency (1-5 parallel installations)
node scripts/install.js --concurrency=3

# Verbose output for debugging
node scripts/install.js --verbose

✨ Features:

  • 🎯 Smart Change Detection: Only installs modules with package.json changes
  • ⚑ Parallel Processing: Configurable concurrency for faster installation
  • πŸ“Š Progress Reporting: Detailed status for each module
  • πŸ›‘οΈ Error Handling: Continues with other modules if one fails

πŸš€ Deployment Script

Deploy Lambda modules to different environments:

# Deploy changed modules to development (default)
npm run deploy:dev

# Deploy changed modules to production
npm run deploy:prod



# Force deploy all modules regardless of changes
node scripts/deploy.js dev --force

# Deploy with custom concurrency (1-3 parallel deployments)
node scripts/deploy.js prod --concurrency=1

# Get help and see all options
node scripts/deploy.js --help

✨ Features:

  • 🎯 Change Detection:
    • Dev: Uses file hash comparison
    • Production: Uses Git commit comparison
  • 🌍 Multi-Environment: Support for dev and prod stages
  • ⚑ Controlled Concurrency: Respects AWS API rate limits
  • πŸ”„ Rollback Support: Maintains deployment state for rollback capabilities
  • πŸ“Š Endpoint Reporting: Shows deployed API Gateway endpoints

⚑ Available npm Scripts

Script Command Description
πŸ“¦ Install All npm run install:all Install dependencies for all modules
πŸ”§ Deploy Dev npm run deploy:dev Deploy to development environment
🏭 Deploy Prod npm run deploy:prod Deploy to production environment

🚒 Deployment Procedures

πŸ”§ Development Deployment

For local development and testing:

  1. ☁️ Set up AWS credentials:
export AWS_PROFILE=taleofddh
  1. πŸ“¦ Install dependencies:
npm run install:all
  1. πŸš€ Deploy to development environment:
npm run deploy:dev
  1. 🎯 Deploy specific modules (if needed):
cd auth
serverless deploy --stage dev

🏭 Production Deployment

Production deployments are automated through GitHub Actions:

πŸ€– Automatic Deployment

  • 🎯 Trigger: Push to production branch
  • βš™οΈ Process: Automatically installs dependencies and deploys all changed modules
  • 🌍 Environment: Production (prod)

πŸ”§ Manual Deployment

You can also trigger deployments manually:

  1. Go to Actions tab in GitHub repository
  2. Select Deploy to Production workflow
  3. Click Run workflow
  4. Choose deployment stage (prod, dev)
  5. Click Run workflow

🚨 Local Production Deployment

For emergency production deployments from local environment:

# Ensure you're on the production branch
git checkout production

# Set AWS credentials for production
export AWS_PROFILE=taleofddh

# Deploy to production
npm run deploy:prod

πŸ”„ GitHub Actions Workflow

The repository includes a comprehensive CI/CD pipeline with the following jobs:

1. πŸ” Setup and Validate

  • βœ… Checks out code and sets up Node.js
  • ☁️ Configures AWS credentials
  • πŸ” Validates AWS access
  • 🎯 Determines deployment stage

2. πŸ“¦ Install Dependencies

  • πŸ“₯ Installs root dependencies (if package.json exists)
  • πŸƒ Runs installation script for all Lambda modules
  • πŸ’Ύ Caches node_modules for faster subsequent runs

3. πŸš€ Deploy Modules

  • πŸ”„ Restores cached dependencies
  • ⚑ Installs Serverless Framework
  • 🚒 Deploys all modules to specified environment
  • πŸ“Š Generates deployment summary

4. πŸ“’ Notify Status

  • βœ… Sends success/failure notifications
  • πŸ“‹ Provides deployment details and commit information

🎯 Workflow Triggers

  • πŸ€– Automatic: Push to production branch
  • πŸ”§ Manual: Workflow dispatch with stage selection (prod, dev)

πŸ“ Project Structure

taleofddh-api/
β”œβ”€β”€ πŸ”„ .github/
β”‚   └── workflows/
β”‚       └── deploy.yml              # GitHub Actions CI/CD workflow
β”œβ”€β”€ βš™οΈ .kiro/
β”‚   β”œβ”€β”€ settings/                   # Kiro IDE settings
β”‚   └── specs/                      # Feature specifications
β”‚       └── deployment-automation/  # Deployment automation spec
β”œβ”€β”€ πŸ“œ scripts/
β”‚   β”œβ”€β”€ deploy.js                   # Deployment automation script
β”‚   β”œβ”€β”€ install.js                  # Installation automation script
β”‚   └── utils.js                    # Shared utilities for scripts
β”œβ”€β”€ οΏ½ β€πŸ’Ό admin/                       # Admin service
β”‚   β”œβ”€β”€ handler.js                  # Lambda function handlers
β”‚   β”œβ”€β”€ package.json               # Module dependencies
β”‚   β”œβ”€β”€ serverless.yml             # Serverless configuration
β”‚   └── .env                       # Environment variables
β”œβ”€β”€ οΏ½ auth/  /                      # Authentication service
β”œβ”€β”€ πŸ“ blog/                        # Blog management service
β”œβ”€β”€ βš™οΈ core/                        # Core business logic service
β”œβ”€β”€ οΏ½ emtail/                       # Email service
β”œβ”€β”€ �️ gaillery/                     # Gallery and media management service
β”œβ”€β”€ πŸ”— integration/                 # Third-party integrations service
β”œβ”€β”€ οΏ½ rlink/                        # Link management service
β”œβ”€β”€ πŸ“ request/                     # Request handling service
β”œβ”€β”€ πŸ“¦ package.json                 # Root package.json with scripts
└── πŸ“– README.md                    # This documentation

πŸ“¦ Module Structure

Each Lambda module follows a consistent structure:

module-name/
β”œβ”€β”€ πŸ”§ handler.js                   # Lambda function handlers
β”œβ”€β”€ πŸ“¦ package.json                 # Module-specific dependencies
β”œβ”€β”€ βš™οΈ serverless.yml               # Serverless Framework configuration
β”œβ”€β”€ πŸ” .env                         # Environment variables (optional)
β”œβ”€β”€ πŸ“Š data/                        # Sample data and fixtures
β”œβ”€β”€ ☁️ resources/                   # CloudFormation resources
└── πŸ“ node_modules/                # Installed dependencies

πŸ“‹ Module Details

οΏ½β€πŸ’Ό Admtin Service (admin)

  • 🎯 Purpose: Administrative operations and management
  • πŸ“¦ Dependencies: @taleofddh/database, @taleofddh/email, @taleofddh/storage, @taleofddh/secret, @taleofddh/response, fast-csv, mailparser
  • ✨ Key Features: Admin APIs, CSV data processing, email integration, secure storage

οΏ½ Ahuthentication Service (auth)

  • 🎯 Purpose: User authentication and authorization
  • πŸ“¦ Dependencies: @taleofddh/database, @taleofddh/response, fast-csv
  • ✨ Key Features: User management, security, CSV processing

πŸ“ Blog Service (blog)

  • 🎯 Purpose: Blog content management
  • πŸ“¦ Dependencies: @taleofddh/database, @taleofddh/storage, @taleofddh/response, fast-csv
  • ✨ Key Features: Blog post management, content storage, CSV data import/export

βš™οΈ Core Service (core)

  • 🎯 Purpose: Fundamental application business logic
  • πŸ“¦ Dependencies: @taleofddh/array, @taleofddh/response, @taleofddh/storage
  • ✨ Key Features: Core functionality, data processing

οΏ½ Email Servnice (email)

  • 🎯 Purpose: Email notifications and processing
  • πŸ“¦ Dependencies: @taleofddh/response, @taleofddh/notification, mailparser
  • ✨ Key Features: Email sending, mail parsing, notification integration

πŸ–ΌοΈ Gallery Service (gallery)

  • 🎯 Purpose: Image gallery and media management
  • πŸ“¦ Dependencies: @taleofddh/database, @taleofddh/storage, @taleofddh/distribution, @taleofddh/date, @taleofddh/array, @taleofddh/secret, fast-csv, uuid
  • ✨ Key Features: Image galleries, CloudFront distribution, media storage, CSV data management

πŸ”— Integration Service (integration)

  • 🎯 Purpose: Third-party service integrations
  • ✨ Key Features: Gmail, WhatsApp, Google Drive, and other external API integrations

πŸ”— Link Service (link)

  • 🎯 Purpose: Link management and URL operations
  • πŸ“¦ Dependencies: @taleofddh/database, @taleofddh/storage, @taleofddh/response, fast-csv
  • ✨ Key Features: URL shortening, link tracking, CSV data management

πŸ“ Request Service (request)

  • 🎯 Purpose: Request processing and management
  • ✨ Key Features: Request lifecycle, processing workflows

πŸ”§ Troubleshooting

🚨 Common Issues

1. ☁️ AWS Credentials Not Configured

❌ Error: Unable to locate credentials

βœ… Solution:

# For local development
export AWS_PROFILE=taleofddh
aws configure --profile taleofddh

# Verify credentials
aws sts get-caller-identity

2. ⚑ Serverless Framework Not Found

❌ Error: serverless: command not found

βœ… Solution:

npm install -g serverless

3. πŸ“¦ Module Installation Failures

❌ Error: npm install failed for module X

βœ… Solutions:

  • Check Node.js version (must be >= 22.0.0)
  • Clear node_modules and reinstall: rm -rf node_modules && npm install
  • Use force installation: node scripts/install.js --force

4. πŸš€ Deployment Failures

❌ Error: Various deployment errors

βœ… Solutions:

  • Verify AWS credentials and permissions
  • Check if all dependencies are installed
  • Ensure serverless.yml configuration is valid
  • Use verbose mode: serverless deploy --verbose

5. πŸ”„ GitHub Actions Failures

❌ Error: CI/CD pipeline failures

βœ… Solutions:

  • Check GitHub Secrets are properly configured
  • Verify AWS credentials have necessary permissions
  • Review workflow logs for specific error messages
  • Ensure production branch is up to date

πŸ†˜ Getting Help

  1. πŸ“‹ Check the logs: Use --verbose flag for detailed output
  2. βœ… Validate environment: Ensure all prerequisites are installed
  3. πŸ” Review configuration: Check serverless.yml and package.json files
  4. πŸ§ͺ Test locally: Deploy individual modules to isolate issues
  5. ☁️ Check AWS console: Verify resources are created correctly

🀝 Contributing

πŸ”„ Development Workflow

  1. 🌿 Create a feature branch:
git checkout -b feature/your-feature-name
  1. ✏️ Make your changes to the relevant Lambda modules

  2. πŸ§ͺ Test locally:

npm run install:all
npm run deploy:dev
  1. πŸ“€ Commit and push:
git add .
git commit -m "Add your feature description"
git push origin feature/your-feature-name
  1. πŸ”„ Create a Pull Request to the main branch

  2. 🏭 Production deployment: Merge to production branch for automatic deployment

πŸ“ Code Standards

  • ✨ Use ES6+ modules (type: "module" in package.json)
  • πŸ“ Follow consistent naming conventions for modules and functions
  • πŸ›‘οΈ Include proper error handling in all Lambda functions
  • πŸ” Use environment variables for configuration
  • πŸ“‹ Write clear commit messages describing changes
  • πŸ§ͺ Test changes in development environment before production

βž• Adding New Modules

  1. πŸ“ Create module directory with required files:

    • handler.js - Lambda function handlers
    • package.json - Module dependencies and metadata
    • serverless.yml - Serverless Framework configuration
  2. πŸ“ Follow naming conventions:

    • Module name: kebab-case
    • Package name: module-name-service
    • Handler functions: camelCase
  3. πŸ“– Update documentation to include the new module

  4. πŸ§ͺ Test thoroughly in development environment


ℹ️ Repository Information

Information Details
πŸ“‚ Repository https://github.com/taleofddh/taleofddh-api
πŸ› Issues https://github.com/taleofddh/taleofddh-api/issues
πŸ‘¨β€πŸ’» Author Devadyuti Das
🏷️ Version 4.3.0
🟒 Node.js >= 22.0.0
πŸ“¦ npm >= 10.0.0

Made with ❀️ for serverless development

GitHub stars GitHub forks

About

Repository for AWS Serverless APIs for taleofddh.com (Tale of Devadyuti, Debarati & Deeptanal's Home) application

Topics

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors