Skip to content

Commit

Permalink
Refactor primary README
Browse files Browse the repository at this point in the history
  • Loading branch information
UZ9 committed Feb 17, 2024
1 parent 6803bb3 commit beb9f09
Showing 1 changed file with 43 additions and 17 deletions.
60 changes: 43 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,64 @@
# BoG API

## Overview
<h1 align="center">
Juno
</h1>

Bits of Good's United Infrastructure API to accelerate deveopment and provide simple setup and integration of various services. This project was ideated and created with the input of various project teams and leads and aims to simplify commonly known tedious workflows and setups, supercharging development throughout and reducing tedious setup.

This project was build with scale in-mind, hence the microservice-based architecture and vastly difference from general Bits of Good project repos. It utilizes a custom monorepo structure that's further explained below.
Juno is [Bits of Good](https://bitsofgood.org/)'s central infrastructure API, integrating several in-house services to simplify and streamline project development.

## Repo Structure
The project is a monorepo using a combination of NestJS, gRPC, Protobuf, Prisma, and Postgres for API endpoints, interservice communication, and object storage/modeling.

This repo uses a combination of NestJS, gRPC, Protobuf, Prisma, and Postgres for API endpoints, inter-service communication, and object storage/modeling.

The reoo is structured as a monorepo using yarn's workspaces. The current packages are as follows:
Packages are managed through [Yarn Workspaces](https://yarnpkg.com/features/workspaces). The current packages are as follows:

- [api-gateway](./packages/api-gateway/): The publicly visible API routes and their first-layer validation + logic. Decides what services to utilize per-request via RPC based on the API route and given information
- [auth-service](./packages/auth-service/): An internal service used to handle all API authentication necessities. Provides RPC endpoints for API key generation/validation/revocation and JWT generation/validation. Used in some endpoints but primarily as middleware within the gateway to ensure authorized access to other services
- [db-service](./packages/db-service/): An internal service that interfaces with our database layer (Postgres). Handles all schema structuring and object relations (users, projects, api keys, etc.). This was kept as a single service to provide an interface for all other services to perform CRUD operations on the data they work with without needing to know the underlying storage internals
- [db-service](./packages/db-service/): An internal service that interfaces with the database layer (Postgres). Handles all schema structuring and object relations (users, projects, api keys, etc.). This was kept as a single service to provide an interface for all other services to perform CRUD operations on the data they work with without needing to know the underlying storage internals

## Building

To build this repo for development/testing, I highly recommend using docker. A `docker-compose-dev.yml` file has been provided that will create containers for each microservice (plus postgres) and configures internal networking between services.
### Prerequisites

- Docker Desktop v4.24+
- WSL if running on a Windows OS
- [protoc](https://github.com/protocolbuffers/protobuf)

### Using Docker

As this repository contains multiple packages, [Docker](https://www.docker.com/) is used to spin up all microservices in order with their respective dependencies. For more details regarding the docker process and its internal networking mechanism, take a look at the `docker-compose.yml` file.

Most of the docker-related functionality has been abstracted away into yarn commands.

To spin up the container make sure docker is installed. You will need at least docker desktop v4.24.
### Install needed dependencies

Run the command `yarn start:dev` in the project root to spin up the entire stack. If you're building to develop on Juno and want live-updates of protos and package changes, run the command `yarn start:dev:live-all` instead.
All package dependencies must first be installed by using the following command in the root directory:
```
yarn
```

**NOTE: In order to run the `live-all` command, you must have the `protoc` command avaialble and be in an environment that can run bash shell scripts. Prior to running `live-all` run `yarn` in the root directory to setup protos & dependencies for the live mounting**
### For development
For spinning up the entire stack (not watching for changes):
```
yarn start:dev
```

Run requests at the endpoint `localhost:3000/some/request/path`
For spinning up the stack and automatically updating as changes are made to files:
```
yarn start:dev:live-all
```


### Making requests


Requests can be made at the endpoint `localhost:3000/some/request/path`.

## Testing

Juno currently has support for e2e tests via jest. I recommend these be run via docker again.
Juno currently has support for E2E tests via [Jest](https://jestjs.io/).

### Run tests for specific microservice

To run tests in a one-off fashion, run the command `yarn test:e2e:[service-name]` in the project root. For each service this looks as follows:
(In root directory)

- api-gateway: `yarn test:e2e:api-gateway`
- auth-service: `yarn test:e2e:auth-service`
Expand All @@ -42,4 +68,4 @@ If you're working on juno and wish to test with your updates in live time (watch

- api-gateway: `yarn test:e2e:api-gateway-live`
- auth-service: `yarn test:e2e:auth-service-live`
- db-service: `yarn test:e2e:db-service-live`
- db-service: `yarn test:e2e:db-service-live`

0 comments on commit beb9f09

Please sign in to comment.