Skip to main content

Catalog Structure

This is the recommended structure for developing AWS Lambda applications using the Node.js runtime.

Catalog Configuration​

This diagram shows the configuration of the source code included in this catalog.

Architecture​

The documentation and source code included in this catalog assumes the following configuration:

Two Application Types​

AWS Lambda startup patterns can be broadly classified into two types. This categorization is based on implementation practice perspectives of this catalog, not AWS Lambda specifications.

  • WebAPI Development
    • e.g. WebAPI logic triggered by API Gateway
  • Event Processing
    • e.g. Event processing triggered by S3, DynamoDB, SQS, SNS, etc.

Although each implementation approach appears different, they share a common layer structure. Each directory structure is inspired by domain-driven development practices, reflecting the script language runtime nature and the AWS Lambda execution environment.

The catalog project is located in the ~/serverless-backend-application-stack-nodejs directory.

Overall Project Structure​

This is the directory and file structure of the entire catalog.

serverless-backend-application-stack-nodejs/
│
├── .vscode/ # VSCode configuration files
│ ├── extensions.json
│ └── settings.json
│
├── .local/ # Execution scripts for local testing
│ ├── sample_api/
│ │ ├── create-user.ts
│ │ └── get-user.ts
│ ├── sample_event/
│ │ └── test-s3-event.ts
│ ├── setup-database.ts
│ ├── setup-minio.ts
│ └── swagger-server.ts
│
├── deploy/
│ ├── cloudformation/
│ │ ├── apigateway-lambda.yaml
│ │ ├── db.yaml
│ │ ├── s3-lambda.yaml
│ │ └── vpc.yaml
│ └── fixtures/
│ └── prisma.zip # DB library (prisma) binary
│
├── src/
│ ├── sample_api/ # WebAPI implementation section
│ │ ├── actions/
│ │ │ ├── CreateUserAction.ts
│ │ │ ├── GetUserAction.ts
│ │ │ └── index.ts
│ │ ├── aws/
│ │ │ ├── DynamoDB.ts
│ │ │ └── index.ts
│ │ ├── daos/
│ │ │ ├── UserDao.ts
│ │ │ └── index.ts
│ │ ├── exception/
│ │ │ ├── ExceptionHandler.ts
│ │ │ ├── SampleException.ts
│ │ │ ├── StatusCode.ts
│ │ │ └── index.ts
│ │ ├── libs/
│ │ │ ├── Hono.ts
│ │ │ ├── Prisma.ts
│ │ │ └── index.ts
│ │ ├── logger/
│ │ │ ├── Logger.ts
│ │ │ └── index.ts
│ │ ├── models/
│ │ │ └── index.ts
│ │ ├── routes/
│ │ │ ├── UserRoute.ts
│ │ │ └── index.ts
│ │ ├── schemas/
│ │ │ ├── ErrorResponseSchema.ts
│ │ │ ├── UserSchema.ts
│ │ │ └── index.ts
│ │ ├── services/
│ │ │ ├── UserService.ts
│ │ │ └── index.ts
│ │ ├── Config.ts
│ │ ├── Env.ts
│ │ ├── SampleAPI.ts
│ │ └── index.ts
│ │
│ ├── sample_event/ # Event processing implementation section
│ │ ├── actions/
│ │ │ ├── ProcessS3EventAction.ts
│ │ │ └── index.ts
│ │ ├── aws/
│ │ │ ├── S3.ts
│ │ │ └── index.ts
│ │ ├── daos/
│ │ │ ├── UserDao.ts
│ │ │ └── index.ts
│ │ ├── helpers/
│ │ │ ├── CsvParser.ts
│ │ │ └── index.ts
│ │ ├── logger/
│ │ │ ├── Logger.ts
│ │ │ └── index.ts
│ │ ├── services/
│ │ │ ├── UserImportService.ts
│ │ │ └── index.ts
│ │ └── index.ts
│ │
│ └── sample_users.csv # Dummy data for local execution
│
├── tests/
│ ├── sample_api/ # Test code for WebAPI implementation section
│ │ ├── CreateUser.test.ts
│ │ └── get-user.test.ts
│ │
│ ├── sample_event/ # Test code for event processing section
│ │ └── process-s3-event.test.ts
│ │
│ └── testing-utils/ # Various helpers, utilities, and setup for testing
│ ├── dynamodb-helper.ts
│ ├── hono-app.ts
│ ├── hono-test-helper.ts
│ ├── minio-client.ts
│ └── setup.ts
│
├── README.md
├── biome.json # Biome (Lint / Formatter) configuration
├── build-app.sh # Script to create deployment zip for WebAPI and event processing Lambda functions
├── docker-compose.yml # For starting up local DB (PostgreSQL) and local S3 (MinIO)
├── esbuild.config.ts # Bundler (ESBuild) configuration
├── package-lock.json
├── package.json
├── tsconfig.json
└── vitest.config.ts # Test framework (vitest) configuration