Skip to content

Franklindot04/lambda-text-processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Text Processing Serverless API

AWS API Gateway DynamoDB Python IaC Ready Status

A fully serverless CRUD API built using AWS Lambda, API Gateway, and DynamoDB.
Designed with clean architecture, structured logging and production‑grade error handling.


📑 Table of Contents

📸 Screenshots

01 — API Gateway Routes

API Gateway Routes

02 — DynamoDB Table

DynamoDB Table

03 — CloudWatch Logs

CloudWatch Logs

04 — cURL Tests (POST → GET All → GET One → DELETE)

cURL Tests


🏗 Architecture Overview

High‑Level Architecture Diagram

                ┌──────────────────────────┐
                │      API Gateway         │
                │  (REST Endpoints Layer)  │
                └─────────────┬────────────┘
                              │
     ┌────────────────────────┼────────────────────────┐
     │                        │                        │
┌──────────┐           ┌──────────────┐         ┌──────────────┐
│ POST /   │           │ GET /results │         │ GET /results/ │
│process   │           │   (list)     │         │     {id}      │
└────┬─────┘           └──────┬───────┘         └──────┬───────┘
     │                        │                        │
     ▼                        ▼                        ▼
┌──────────┐           ┌──────────────┐         ┌──────────────┐
│ Lambda   │           │ Lambda       │         │ Lambda       │
│Process   │           │ListResults   │         │GetResult     │
└────┬─────┘           └──────┬───────┘         └──────┬───────┘
     │                        │                        │
     └──────────────┬─────────┴──────────┬────────────┘
                    ▼                    ▼
                ┌──────────────────────────────┐
                │     DynamoDB Table           │
                │  TextProcessingResults       │
                └──────────────────────────────┘

Sequence Diagram (POST → DynamoDB)

Client
  │
  │ POST /
  ▼
API Gateway
  │
  │ invokes Lambda
  ▼
ProcessTextFunction
  │
  │ put_item()
  ▼
DynamoDB
  │
  │ success
  ▼
ProcessTextFunction
  │
  │ returns JSON
  ▼
Client

🌐 Base URL

📚 API Documentation

🔵 POST /

Process text and store the result.

Request Body

{
  "text": "hello world"
}

Example Response

{
  "id": "uuid",
  "original": "hello world",
  "uppercase": "HELLO WORLD",
  "length": 11,
  "timestamp": 1771283745
}

Example cURL

curl -X POST https://3ki380u3fc.execute-api.eu-north-1.amazonaws.com/ \
  -H "Content-Type: application/json" \
  -d '{"text": "hello world"}'

🟢 GET /results

List all stored results.

Example Response

[
  {
    "id": "uuid",
    "original": "hello",
    "uppercase": "HELLO",
    "length": 5,
    "timestamp": 1771283745
  }
]

Example cURL

curl https://3ki380u3fc.execute-api.eu-north-1.amazonaws.com/results

🟡 GET /results/{id}

Retrieve a single result by ID.

Example Request

GET /results/f5e565d8-bc1f-4911-a810-e1c3e06d8c98

Example Response

{
  "id": "f5e565d8-bc1f-4911-a810-e1c3e06d8c98",
  "original": "hello",
  "uppercase": "HELLO",
  "length": 5,
  "timestamp": 1771283745
}

Example cURL

curl https://3ki380u3fc.execute-api.eu-north-1.amazonaws.com/results/<id>

🔴 DELETE /results/{id}

Delete a result by ID.

Example Request

DELETE /results/f5e565d8-bc1f-4911-a810-e1c3e06d8c98

Example Response

{ "message": "Item deleted successfully" }

Example cURL

curl -X DELETE https://3ki380u3fc.execute-api.eu-north-1.amazonaws.com/results/<id>

🛡 CORS

All responses include:

{
  "Access-Control-Allow-Origin": "*",
  "Access-Control-Allow-Methods": "GET,POST,DELETE,OPTIONS",
  "Access-Control-Allow-Headers": "Content-Type"
}

🗄 DynamoDB Schema

Table: TextProcessingResults

Attribute   | Type
------------|--------
id          | String (PK)
original    | String
uppercase   | String
length      | Number
timestamp   | Number

📊 Logging Strategy

Every Lambda uses structured JSON logs:

{
  "level": "INFO",
  "message": "Item stored successfully",
  "requestId": "abc-123",
  "details": { "id": "uuid" }
}

This makes CloudWatch logs:

  • searchable
  • filterable
  • machine‑readable
  • consistent across all Lambdas

🧪 Local Testing

POST

curl -X POST https://3ki380u3fc.execute-api.eu-north-1.amazonaws.com/ \
  -H "Content-Type: application/json" \
  -d '{"text": "hello"}'

GET all

curl https://3ki380u3fc.execute-api.eu-north-1.amazonaws.com/results

GET one

curl https://3ki380u3fc.execute-api.eu-north-1.amazonaws.com/results/<id>

DELETE

curl -X DELETE https://3ki380u3fc.execute-api.eu-north-1.amazonaws.com/results/<id>

🚧 Future Improvements

Planned enhancements for the next iteration:

  • Add authentication (Cognito or JWT-based access control)
  • Add pagination support to /results
  • Add an update endpoint (PATCH)
  • Build a frontend UI (React or Svelte)
  • Add full infrastructure-as-code deployment (CloudFormation or CDK)

🎉 Final Notes

This project demonstrates:

  • Clean serverless architecture
  • Modular Lambda design
  • Consistent structured logging
  • DynamoDB best practices
  • Production‑grade error handling

A solid showcase of DevOps and backend engineering skills.

About

A serverless text processing microservice using AWS Lambda, API Gateway, and DynamoDB.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages