Skip to content

A template to apply clean arquitecture in a simply way with serverless and localstack to testing and work offline

Notifications You must be signed in to change notification settings

G33N/serverless-clean-architecture-template

Repository files navigation

Template Serverless + Localstack

Project Architecture

This project implements a simplify mode of Clean Architecture

Clean Architecture

Project structure

The project code base is mainly located within the src folder. This folder is divided in:

  • bounded-context - containing code base and configuration for your lambda functions
  • shared - containing shared code base between your lambdas
.
├── tests				         # Unit tests
├── src
│   ├── bounded-context          # Lambda configuration and source code folder
│   │   ├── presentation
│   │   │   ├── handler.ts
│   │   │   ├── index.ts
│   │   │   └── schema.ts
│   │   ├── application         # Application business logic (Use cases).      
│   │   │   └── UseCase.ts
│   │   ├── domain              # Enterprise business logic.
│   │   │   ├── Entity
│   │   │   ├── Failures
│   │   │   └── ValueObjects
│   │   └── infrastructure      # Interface to communicate with other contexts. (Local and remote resources), repositories.
│   │
│   └── shared                  # Lambda shared code
│       └── apiGateway.ts       # API Gateway specific helpers
│       └── handlerResolver.ts  # Sharable library for resolving lambda handlers
│       └── lambda.ts           # Lambda middleware
│
├── package.json
├── serverless.ts               # Serverless service file
├── tsconfig.json               # Typescript compiler configuration
├── tsconfig.paths.json         # Typescript paths
└── webpack.config.js           # Webpack configuration

Prerequisite Software

Before you can work with this project, you must install and configure the following products on your development machine:

It is recommendable to install node via NVM

Set up your AWS Credentials

  1. Log in into Aws Console
  2. Expand Aws Account --> Command line or programmatic access
  3. Find and copy AWS Access Key ID and AWS Secret Access Key

Now you have the information required to create a credential file:

# Run
> aws configure

# Required Data
> AWS Access Key ID [None]: XXXXXXXXXXXXXXXXXXXXX
> AWS Secret Access Key [None]: XXXXXXXXXXXXXXXXXXXXX
> Default region name [None]: us-east-1
> Default output format [None]: json

Now validate that changes have been saved

cat ~/.aws/credentials

Configure AWS Locally

> export AWS_PROFILE=your-aws-profile

Getting the Sources

Clone this repository:

  1. Log in to your GitHub account GitHub and follow the instruction below:
# Clone
> git clone https://github.com/G33N/serverless-clean-architecture-template.git


# Go to the sources directory:
> cd serverless-clean-architecture-template

Installing NPM Modules

Next, install the JavaScript modules needed to build and test the app:

# Install project dependencies (package.json)
> yarn

Quick Start

How to run your local environment.

yarn aws-sso-login
yarn sso-login

To test it, issue the following command

yarn invoke:hello 

About

A template to apply clean arquitecture in a simply way with serverless and localstack to testing and work offline

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published