Skip to Content

Installation

Clone Repo

Before cloning the repo we must create a fork from the repo provided

https://gitlab.forge99.com/oqulo/aishow

In order to get the project files from current development, first must clone the gitlab repo. First create an empty directory mkdir aiaccess following cd aiaccess once inside the folder initialize git by git init. Next step is to get current files in development, these are files that will be “pulled” to our local environment.

terminal
git remote add upstream [email protected]:oqulo/aishow.git

Next proceed to adding the fork created at the start.

terminal
git remote add origin {link to fork}

Once both commands have been entered you can check the commands git remote -v and should see origin and upstream with both fetch and push. To proceed in fetching the files from upstream with the command.

terminal
git fetch upstream

From a specific branch type in

terminal
git checkout develop

After all commands have been entered, local files from the repo should appear on your local machine.

Environment Variables

Copy .env.example to .env and update the corresponding values.

terminal
APP_TITLE="AI Access" NODE_ENV=development PLAYGROUND_PORT=4000 DB_NAME=aiaccess DB_HOST=localhost DB_PORT=5432 DB_USER={your_username_here} DB_PASS={your_password_here} DB_URL="postgresql://{your_username_here}:{your_password_here}@localhost:5432/aiaccess" GRAPH_ENDPOINT="http://localhost:3000/api/graphql" CLIENT_URL="http://localhost:3000" APP_JWT_REFRESH="omae-wa-mou-shindeiru" APP_JWT_SECRET="CHA-LA-HEAD-CHA-LA-Nani-ga-okite-mo-kibun-wa-heno-heno-kappa" ALLOWED_STATIC_EXTENSIONS="jpg,jpeg,png,svg" SMTP_HOST="smtp.gmail.com" SMTP_PORT=465 SMTP_SECURE=false SMTP_USER="[email protected]" SMTP_CLIENT_SENDER="[email protected]" SMTP_PASS="711mineshine" AWS_REGION="us-west-2" AWS_IDENTITY_POOL_ID="us-west-2:22c525d7-f097-4b3c-b15f-909734de8b96" AWS_API_VERSION="2006-03-01" AWS_BUCKET_NAME="ai-show" AWS_MAX_KEYS=1000 CLOUDFRONT_ENDPOINT="https://d1clzpghk6wjpn.cloudfront.net" S3_ENDPOINT="https://ai-show.s3.ap-southeast-1.amazonaws.com" IMAGE_PROXY_ENDPOINT="https://imageproxy.agentimage.com/"

Node Version Manager

The project uses nvm to easily switch versions when patches are available. Notice the .nvmrc file, this contains the needed version for the project. To switch version, make sure you have nvm avaible then run nvm use.

terminal
nvm use 12.18.1

Install Dependencies

Run npm install or npm i to install project dependencies.

You can also run npm ci to install with a clean slate.

terminal
npm install

Database Setup

Make sure you have DB_URL in the environment variables.

Migration files are based on Prisma. You can check the documentation here.

To run initial migration:

terminal
npm run migrate:up

Database Migrations

Create Migration

Everytime you make changes on prisma/schema.prisma, you have to create a migration file. To make easier migration management, making migration with small changes are encouraged. This defines the steps necessary to update your current schema

To create your migration file:

terminal
npm run migrate:save

The command will prompt to name your migration.

Naming pattern [action]-[entity]-[column]

Examples:

terminal
add-user-createdAt alter-user-createdAt delete-user-createdAt

Once done, prisma will create your migration files under prisma/migrations.

Apply Migrations

To apply latest available migrations:

terminal
npm run migrate:up

Apply the next two migrations:

terminal
npm run migrate:up -- 2

Apply all migrations up to and including migration by name:

terminal
npm run migrate:up -- "alter-user-createdAt"

Or by timestamp:

terminal
npm run migrate:up -- 20200624072801

Prisma migration up docs.

Revert Migrations

Revert migrations one step at a time:

terminal
npm run migrate:down

Migrate the database backwards by two migrations:

terminal
npm run migrate:down -- 2

Migrate backwards through all migrations up to and including a migration by name:

terminal
npm run migrate:down -- "alter-user-createdAt"

Or by timestamp:

terminal
npm run migrate:down -- 20200624072801

Prisma migration down docs.

GraphQL Dev Server

Run GraphQL server with playground.

terminal
npm run server

NextJS Dev Server

Run NextJS dev server

terminal
npm run dev

Codegen

Create or update codegen files.

terminal
npm run generate

Generated files are put on generated directory.

Codegen file exposes hooks that can be used for React operations.

Important! Codegen depends on running graphql server. Check schema on codegen.yml.

Check out their docs.

Deployment

Run build

terminal
npm run build

Deploy app

terminal
npm start

Or via PM2

terminal
pm2 start npm --name "aishow-live" -- start
Last updated on