Skip to content

Developing the Application

Clone the GitHub repository to start development. You can edit the code using your preferred editor and use the application in a local environment with Node.js.

Below are examples of environment variables. Set them in /apps/frontend/.env and /apps/backend/.env.

/apps/frontend/.env
VITE_BACKEND_URL=http://localhost:3001
/apps/backend/.env
OPENAI_API_KEY="sk-xxxxxx"
OPENAI_API_ENDPOINT="https://your-openai-api-endpoint"
BETTER_AUTH_URL="http://localhost:3001"
BETTER_AUTH_SECRET=dummyDummyDummy
CORS_ORIGIN="http://localhost:3000"
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
DB_PORT=5432
POSTGRES_DB="tutoriallm_db"
DB_HOST="db.tutoriallm.local"
DOMAIN="localhost"
DEFAULT_USER_PASSWORD="admin"
DEFAULT_USER_NAME="admin"
S3_USER="s3_root"
S3_PASSWORD="s3_password"
S3_ACCESS_KEY_ID="s3_access_key_id"
S3_SECRET_ACCESS_KEY="s3_secret_access_key"

When using the documentation development server (apps/docs), set the environment variables in /apps/docs/.env.

/apps/docs/.env
OPENAPI_DOCS_URL=http://localhost:3001

TutoriaLLM requires a connection to PostgreSQL with vector capabilities. Here’s how to use Docker compose with pgvector.

/docker-compose.pg.yml
services:
db:
container_name: tutoriallm_db
image: pgvector/pgvector:pg14
ports:
- "5432:5432"
env_file:
- ./apps/backend/.env
environment:
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_DB
- PGDATA=/var/lib/postgresql/data/pgdata
- TZ=UTC
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $POSTGRES_USER -d $POSTGRES_DB"]
interval: 5s
timeout: 60s
retries: 5
start_period: 5s
volumes:
- db_data_db:/var/lib/postgresql/data
volumes:
db_data_db:

Use Docker compose to start the frontend and backend. Use the docker-compose.yml and docker-compose.dev.override.yml files in the TutoriaLLM repository.

Start the server
docker compose -f docker-compose.yml -f docker-compose.dev.override.yml up --build # Build and start
docker compose -f docker-compose.yml -f docker-compose.dev.override.yml up # Start

If you need to start the documentation development server, use pnpm.

You can start the frontend and backend individually using pnpm.

Start the database:

Start the database
docker compose up

Start the frontend, backend, and documentation (if needed) with the following commands:

Start the development server
# Frontend
cd apps/frontend
pnpm i && pnpm dev
# Backend
cd apps/backend
pnpm i && pnpm dev
# Documentation
cd apps/docs
pnpm i && pnpm dev

This repository uses pnpm workspace to share type definitions between the frontend and backend. Type definitions are defined in the backend and can be used in the frontend.

Build the type definitions
# Generate type definitions in the backend
cd apps/backend
pnpm run build

Run tests with the following command in the root directory:

Test
pnpm test

Extensions are located in /packages/extensions by default. Place your extensions in this directory when creating them. The values exported in index.ts are used by the frontend and backend.

After defining an extension, build it with the following command:

Build the extension
# Build the extension
pnpm run build

After building, restart the frontend and backend.