Skip to content

2. Development Guide

Ayush Goyal edited this page Aug 7, 2023 · 6 revisions

Getting Started

  1. Run yarn install. The packages in this repo are linked via Yarn Workspaces, so you only need to run yarn install once in the main root folder to install all the dependencies in the monorepo.
  2. Copy the .env.example file to .env in the config folder.
  3. Ask a team member for the secret google-cloud-credentials.json file and place it in the config folder.
  4. Update the GOOGLE_CLOUD_CREDENTIALS environment variable with the path to the secret google-cloud-credentials.json file you just added. (An example would be /Users/john/Coding/api/config/google-cloud-credentials.json on MacOS)
  5. Update the database URI connections for Postgres, MongoDB, and Redis for your system. Defaults are provided.
  6. Run yarn setup to start the setup script. Complete the steps in the command line to initialize your local development.

Finally, after you're setup:

  • Run yarn start:all to start all the services
    • Even though you may only be wanting to edit one service, you'll need to start all of them as they all communicate heavily with each other to perform their tasks
  • Run cd services/<SERVICE_NAME> and then run yarn dev to start a specific service (though this should be used rarely)

Each service will be hosted on its own port, which will be printed to the console. So for example, if you want to access the checkin service, this service is on port 8003, so you would make a request to localhost:8003 an access the appropriate path.

Repo Overview

Here's a breakdown of the major folders you'll interact with and what each one does:

config

This packages handles the configuration for all the gateway and services. It specifies port numbers, database URLs, rate limiting, etc. Use this to setup and add new services. It has information for dev and prod in different files.

common

This package has a bunch of shared code that can be used across all of our services. This includes things like common types, common authentication middleware, error handling, etc.

services

Each of the services in this folder has a unique and distinct job. They each are setup with their own database and have their own routing system.

docs

This is where our docs site is written. It contains the server to run the docs site and also the config .json file that holds all our API info. When you're making a change to a service, you'll need to update the docs site here.

scripts

This folder contains one-off scripts that can be run to perform various tasks. These things include updating secrets, updating prod data, etc.

gateway

The gateway handles all incoming requests. Based on the url format, it will forward the request to the appropriate service to handle it. For example, all requests starting with /users will be sent to the users service.

Clone this wiki locally