A serverless Certificate Service with SQS and Twillio SendGrid
This project follows a Layered Serverless Architecture with Use-Case Driven Design.
It separates responsibilities into:
- Entry Layer –
handler.py,CertEnvInit.py - Business Layer –
usecase/ - Domain Layer –
model/ - Data Layer –
repository/ - Infrastructure Layer –
s3/,layers/,template/ - Support Layer –
constants/,utils/,resources/,scripts/
- AWS Lambda receives an event (API Gateway or SQS).
CertEnvInit.pyinitializes environment and services.handler.pydelegates processing to a specific use case.- Use case executes business logic.
- Certificate is generated → uploaded to S3 → emailed via SendGrid.
├── constants/ # Application-wide constants
├── layers/ # AWS Lambda shared dependencies
├── model/ # Domain models
├── repository/ # Data access layer
├── resources/ # Static configuration/resources
├── s3/ # AWS S3 integration
├── scripts/ # Dev and deployment scripts
├── template/ # Certificate templates
├── usecase/ # Business logic
├── utils/ # Shared helpers
├── handler.py # Lambda entry point
└── CertEnvInit.py # Environment/bootstrap initialization
-
Prerequisites:
- Visual Studio Code
- VS Code Dev Containers extension
- Docker Desktop
- AWS CLI configured on host machine (
aws configure)
-
Clone and Open Project
git clone https://github.com/SPARCS-UP-Mindanao/SPARCS-Certificate-Service.git cd SPARCS-Certificate-ServiceOpen the folder in VS Code. VS Code will detect the dev container configuration and show a notification:
"Folder contains a Dev Container configuration file. Reopen folder to develop in a container"
Click Reopen in Container or manually open with
Ctrl+Shift+P→Dev Containers: Reopen in ContainerThe dev container will automatically:
- Build the container environment
- Install all dependencies
- Configure AWS CLI with your host credentials
-
Install Python Dependencies:
pipenv install
-
Activate Virtual Environment:
pipenv shell
-
Configure AWS SSO Profile:
aws configure sso
You will be prompted for:
- SSO Start URL (provided by your organization)
- SSO Region →
ap-southeast-1 - CLI default client Region →
ap-southeast-1 - CLI default output format →
json - CLI profile name →
sparcs
After entering SSO details, authenticate in your browser and select your AWS account and role.
-
Login via SSO:
aws sso login --profile sparcs
-
Verify Identity:
aws sts get-caller-identity --profile sparcs
-
Install serverless plugins:
npm install
-
Deploy:
npx serverless deploy --stage dev --aws-profile sparcs --verbose
- Layered Architecture (separation of concerns)
- Use-case driven business logic
- Repository pattern for data access
- Thin Lambda handler
- Dedicated environment bootstrap (
CertEnvInit.py) - Infrastructure isolation (S3, SendGrid, SQS separated from business logic)
- No business logic inside handlers
- Environment-based configuration
- No hardcoded secrets
- Lambda layer for heavy dependencies (e.g., WeasyPrint)
Consistency is enforced across the project.
- Use
snake_case - Descriptive and responsibility-based naming
Examples:
- generate_certificate.py
- events_repository.py
- s3_constants.py
- Use
PascalCase - Singular nouns
- Clear responsibility
Examples:
- Certificate
- EventsRepository
- RegistrationGlobalSecondaryIndex
- Use
snake_case - Verb-based naming
Examples:
- generate_certificate()
- upload_file()
- generate_presigned_url()
- Use
UPPER_CASE - Stored inside
constants/
Examples:
- HASH_KEY
- REGISTRATION_ID
- SUPER_ADMIN