A serverless application built with AWS SAM, featuring a Next.js frontend and a serverless backend.
Medium: Racing Through the Cloud
.
├── code/
│ ├── frontend/ # Next.js frontend application
│ └── backend/ # Serverless backend functions
├── stacks/
│ ├── stateful/ # Stateful resources (DynamoDB, Cognito, etc.)
│ └── stateless/ # Stateless resources (API Gateway, Lambda functions)
├── docs/
│ └── api/ # API documentation
└── .github/
└── workflows/ # GitHub Actions deployment workflows
- Node.js 22.x
- AWS CLI configured with appropriate credentials
- AWS SAM CLI
- Yarn package manager
-
Navigate to the frontend directory:
cd code/frontend -
Create a
.envfile:NEXT_PUBLIC_API_BASE_URL=https://your-api-url/api API_BASE_URL=https://your-api-url/api -
Install dependencies:
yarn install
-
Start the development server:
yarn dev
-
Navigate to the backend directory:
cd code/backend -
Install dependencies:
npm install
-
Build the project:
npm run build
The project uses GitHub Actions for automated deployment. The deployment process is split into two stages:
-
Stateful Resources:
- DynamoDB Table
- Cognito User Pool
- Event Bus
- Secrets Manager
-
Stateless Resources:
- API Gateway
- Lambda Functions
- Application Resources
To deploy the backend manually using SAM CLI:
-
First, deploy the stateful resources:
cd stacks/stateful sam deploy --parameter-overrides "MomentoCacheApiKey=your-momento-key"
-
Then, deploy the stateless resources:
cd ../stateless sam deploy --parameter-overrides "AppName=ServerlessHackaton"
Note: The stateless stack depends on the stateful stack, so make sure to deploy the stateful resources first.
The following secrets need to be configured in your GitHub repository:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYMOMENTO_CACHE_API_KEY
The frontend is built with Next.js and includes:
- Modern React features
- TypeScript support
- API proxy for backend communication
- Environment-based configuration
The backend is built with AWS SAM and includes:
- Lambda functions for authentication
- API Gateway integration
- DynamoDB integration
- Cognito integration
- Event Bridge for event handling
For detailed API documentation, please refer to the docs/api folder in the repository. This includes:
- Available endpoints
- Request/response formats
- Authentication requirements
- Example requests
This project is licensed under the MIT License - see the LICENSE file for details.

