Multi-module serverless Lambda repository with automated deployment scripts and comprehensive CI/CD workflows
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.
- ποΈ 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
The repository follows a multi-module serverless architecture where each Lambda module:
- π Operates as an independent microservice
- π¦ Has its own
package.json,handler.js, andserverless.ymlconfiguration - π Can be deployed independently to different environments (dev, prod)
- π€ Shares common deployment automation scripts and workflows
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 |
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
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 |
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=taleofddhGet your access key from Serverless Dashboard and set it:
# Set Serverless access key
export SERVERLESS_ACCESS_KEY=your_access_key_hereThe repository uses GitHub Secrets for AWS credentials and Serverless authentication:
AWS_ACCESS_KEY_ID- AWS access key IDAWS_SECRET_ACCESS_KEY- AWS secret access keySERVERLESS_ACCESS_KEY- Serverless Framework v4 access key
- π₯ Clone the repository:
git clone https://github.com/taleofddh/taleofddh-api.git
cd taleofddh-api- π¦ 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 installThe 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
The repository provides automated scripts for common development and deployment tasks:
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- π― 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
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- π― 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
| 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 |
For local development and testing:
- βοΈ Set up AWS credentials:
export AWS_PROFILE=taleofddh- π¦ Install dependencies:
npm run install:all- π Deploy to development environment:
npm run deploy:dev- π― Deploy specific modules (if needed):
cd auth
serverless deploy --stage devProduction deployments are automated through GitHub Actions:
- π― Trigger: Push to
productionbranch - βοΈ Process: Automatically installs dependencies and deploys all changed modules
- π Environment: Production (prod)
You can also trigger deployments manually:
- Go to Actions tab in GitHub repository
- Select Deploy to Production workflow
- Click Run workflow
- Choose deployment stage (prod, dev)
- Click Run workflow
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:prodThe repository includes a comprehensive CI/CD pipeline with the following jobs:
- β Checks out code and sets up Node.js
- βοΈ Configures AWS credentials
- π Validates AWS access
- π― Determines deployment stage
- π₯ Installs root dependencies (if package.json exists)
- π Runs installation script for all Lambda modules
- πΎ Caches node_modules for faster subsequent runs
- π Restores cached dependencies
- β‘ Installs Serverless Framework
- π’ Deploys all modules to specified environment
- π Generates deployment summary
- β Sends success/failure notifications
- π Provides deployment details and commit information
- π€ Automatic: Push to
productionbranch - π§ Manual: Workflow dispatch with stage selection (prod, dev)
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
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
- π― 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
- π― Purpose: User authentication and authorization
- π¦ Dependencies: @taleofddh/database, @taleofddh/response, fast-csv
- β¨ Key Features: User management, security, CSV processing
- π― Purpose: Blog content management
- π¦ Dependencies: @taleofddh/database, @taleofddh/storage, @taleofddh/response, fast-csv
- β¨ Key Features: Blog post management, content storage, CSV data import/export
- π― Purpose: Fundamental application business logic
- π¦ Dependencies: @taleofddh/array, @taleofddh/response, @taleofddh/storage
- β¨ Key Features: Core functionality, data processing
- π― Purpose: Email notifications and processing
- π¦ Dependencies: @taleofddh/response, @taleofddh/notification, mailparser
- β¨ Key Features: Email sending, mail parsing, notification integration
- π― 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
- π― Purpose: Third-party service integrations
- β¨ Key Features: Gmail, WhatsApp, Google Drive, and other external API integrations
- π― Purpose: Link management and URL operations
- π¦ Dependencies: @taleofddh/database, @taleofddh/storage, @taleofddh/response, fast-csv
- β¨ Key Features: URL shortening, link tracking, CSV data management
- π― Purpose: Request processing and management
- β¨ Key Features: Request lifecycle, processing workflows
β Error: Unable to locate credentials
β Solution:
# For local development
export AWS_PROFILE=taleofddh
aws configure --profile taleofddh
# Verify credentials
aws sts get-caller-identityβ Error: serverless: command not found
β Solution:
npm install -g serverlessβ 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
β 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
β 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
- π Check the logs: Use
--verboseflag for detailed output - β Validate environment: Ensure all prerequisites are installed
- π Review configuration: Check serverless.yml and package.json files
- π§ͺ Test locally: Deploy individual modules to isolate issues
- βοΈ Check AWS console: Verify resources are created correctly
- πΏ Create a feature branch:
git checkout -b feature/your-feature-name-
βοΈ Make your changes to the relevant Lambda modules
-
π§ͺ Test locally:
npm run install:all
npm run deploy:dev- π€ Commit and push:
git add .
git commit -m "Add your feature description"
git push origin feature/your-feature-name-
π Create a Pull Request to the main branch
-
π Production deployment: Merge to
productionbranch for automatic deployment
- β¨ 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
-
π Create module directory with required files:
handler.js- Lambda function handlerspackage.json- Module dependencies and metadataserverless.yml- Serverless Framework configuration
-
π Follow naming conventions:
- Module name:
kebab-case - Package name:
module-name-service - Handler functions:
camelCase
- Module name:
-
π Update documentation to include the new module
-
π§ͺ Test thoroughly in development environment
| 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 |