Skip to content

Backend Overview

Code Genie backends are comprised of the following key services:

  1. A Serverless Express REST API hosted on AWS Lambda and API Gateway.
  2. An infinitely scalable Serverless Database using AWS DynamoDB.
  3. User identity/authentication via AWS Cognito User Pool.

This guide covers everything you need to know to build, deploy, and extend your application’s backend.

Core Technology

The backend utilizes the following core services, libraries, and frameworks:

  • Express – The most popular API Framework in Node.js.
  • AWS Lambda – Serverless compute for running the Express REST API.
  • AWS API Gateway – Provides HTTPS access to Lambda and ensures requests are authenticated with a valid access token from Cognito.
  • AWS Cognito User Pool – Handles user identity/authentication.
  • AWS DynamoDB – Infinitely scalable database.
  • AWS SES – Sends transactional emails, such as those needed by auth flows (register, verify, forgot password, etc.).
  • AWS CDK – Infrastructure as Code for all of the AWS services used.
  • Serverless Express – Enables Express to run on Serverless services (API Gateay and Lambda).
  • DynamoDB Toolbox – Simplifies querying and updating DynamoDB.
  • Winston – Advanced logging including structured logging, log levels, and more.

Project Structure

  • Directorypackages
    • Directoryapi
      • Directorycontrollers
        • user.ts
      • Directorymodels
        • User.ts
      • Directoryerrors
        • BadRequestError.ts
        • BaseError.ts
        • index.ts
        • NotFoundError.ts
        • UnauthenticatedError.ts
        • UserInputError.ts
      • Directoryroutes
        • apps.ts
        • me.ts
        • my-entities.ts 1 route per entity
      • README.md
      • app.local.ts
      • app.ts
      • constants.ts
      • jest.config.js
      • lambda.test.ts
      • lambda.ts
      • package-lock.json
      • package.json
      • try-parse-req.ts
      • tsconfig.json
      • types.d.ts
    • Directorycdk
      • Directorybin
        • cdk.ts
        • copy-outputs-to-dotenv.ts
        • pull-stack-outputs.ts
      • Directorylib
        • Directoryconstructs
          • Directorytables
            • WidgetTable.ts 1 table per entity
            • UserTable.ts
          • Auth.ts
          • BaseTable.ts
          • ExpressApi.ts
          • WebApp.ts
        • cdk-stack.ts
        • environment-config.ts
        • get-output-by-prefix.ts
      • Directorytest
        • cdk.test.ts
      • .gitignore
      • .npmignore
      • README.md
      • cdk.context.json
      • cdk.json
      • jest.config.js
      • package-lock.json
      • package.json
      • tsconfig.json
    • Directorycognito
      • cognito-post-confirmation.test.ts
      • cognito-post-confirmation.ts
      • cognito-pre-signup.test.ts
      • cognito-pre-signup.ts