Skip to content

Nx monorepo using Angular & NestJS for querying OPENAI

Notifications You must be signed in to change notification settings

parisfreire/space-odissey

Repository files navigation

SpaceOdyssey

A 2001: A Space Odyssey inspired Nx monorepo using Angular and NestJS for querying OpenAI Chat Completions API, keeping track of tokens usage via MongoDB for billing purposes.

EVA library was created for sharing common models among the projects. MOONBASE library provides a generic way of client HTTP requests handling.

Check Understand this workspace section for dependencies graph.

How to install

npm install

How to run

Option 1 - Nx

✨HAL - FE✨

node node_modules/.bin/nx serve hal

✨DISCOVERY - BE✨

node node_modules/.bin/nx serve discovery

✨SPACE ODISSEY - Monorepo✨

node node_modules/.bin/nx run-many --target=serve -p discovery,hal

Option 2 - Docker

docker compose up

Mongo Shell

Commands to run:

  1. mongosh
  2. db.auth("$USER", "$PASSWORD"); - Check mongo-init.js for credentials
  3. show dbs
  4. use $DB - Replace $DB for any existing DB
  5. show collections
  6. db.$COLLLECTION.find() - Replace $COLLECTION for any existing collection

Production config

  1. Set NODE_ENV to production.

  2. Create apps/discovery/config/env/production.env file and set OPENAI_API_KEY to "your-OPENAI-API-key"

Nx Monorepo

This workspace has been generated by Nx, a Smart, fast and extensible build system.

Understand this workspace

Run nx graph to see a diagram of the dependencies of the projects.

Remote caching

Run npx nx connect-to-nx-cloud to enable remote caching and make CI faster.

Further help

Visit the Nx Documentation to learn more.