Skip to content

BinaryStudioAcademy/bsa-winter-2021-2022-bws

Repository files navigation

Binary Web Services

Amazon Web Services wrapper

Table of contents

1. Introduction

  1.1 Useful Links

2. Domain

3. Database Schema

4. Architecture

  4.1 Global

    4.1.1 Technologies

  4.2 Frontend

    4.2.1 Technologies

    4.2.2 Folder Structure

  4.3 Backend

    4.3.1 Technologies

    4.3.2 Folder Structure

  4.4 Shared Package

    4.4.1 Reason

    4.4.2 Technologies

5. How to Run

  5.1 Manually

  5.2 In Docker

6. Deployment

1. Introduction

1.1 Useful Links

2. Domain

TODO: explain domain

3. Database Schema

Database schema is available here. There is a couple of conventions:

  1. Data is divided into several schemas. Tables are named as follows: {schema}___{table}. In postgres it should be converted into {schema}.{table}.

4. Architecture

4.1 Global

4.1.1 Technologies

  1. Typescript

4.2 Frontend

4.2.1 Technologies

  1. React as a frontend library
  2. Redux + Redux Toolkit as a state manager

4.2.2 Folder Structure

  1. Assets - static assets (images, global styles)
  2. Common - common/shared files (types, enums)
  3. Components - plain react components
  4. Exceptions
  5. Helpers
  6. Services - api accessing services
  7. Store - redux store with all features as sub folders
  8. Validation-schemas - schemas that used for forms validation

4.3 Backend

4.3.1 Technologies

  1. Fastify as a backend framework
  2. Knex as a query builder
  3. Objection as an ORM

4.3.2 Folder Structure

  1. Api - rest endpoints. There should be no domain logic
  2. Common - common/shared files (types, enums)
  3. Data - everything related to data access (migrations, models, repositories)
  4. Exceptions
  5. Helpers
  6. Services - domain logic
  7. Validation-schemas - schemas that used for input data validation

4.4 Shared Package

4.4.1 Reason

As we are already using js on both frontend and backend it would be useful to share some contracts and code between them.

4.4.2 Technologies

  1. Joi as a schema validator

5. How to Run

5.1 Manually (with hot reload)

  1. Create and fill all .env files. These files are:
  • .env/frontend.env
  • .env/backend.env
  • .env/postgres.env

You should use .env.example folder as a reference.

  1. Install dependencies (node_modules). Run npm run install:all in the root folder.

  2. Install pre-commit hooks: npx simple-git-hooks in the root folder. This hook is used to verify code style on commit.

  3. Run database. You can either run it in docker using command cd ./docker/bws && docker-compose -f docker-compose.services.yml up --build or by installing postgres on your computer. Docker variant is preferred.

  4. Apply migrations: cd backend && npm run migrate:dev

  5. Run backend: cd backend && npm run start:dev

  6. Run frontend: cd frontend && npm run start

5.2 In Docker (without hot reload)

  1. Create and fill all .env files. These files are:
  • .env/frontend.env
  • .env/backend.env
  • .env/postgres.env

You should use .env.example folder as a reference.

  1. Run docker: cd .docker/bws && docker-compose -f docker-compose.yml up --build

6. Deployment

All code is hosted in docker containers on AWS. CI/CD implemented using Github Actions

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages