Developing the Application
Cloning the Repository
Section titled “Cloning the Repository”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.
Setting Environment Variables
Section titled “Setting Environment Variables”Below are examples of environment variables. Set them in /apps/frontend/.env and /apps/backend/.env.
VITE_BACKEND_URL=http://localhost:3001OPENAI_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=postgresPOSTGRES_PASSWORD=postgresDB_PORT=5432POSTGRES_DB="tutoriallm_db"DB_HOST="db.tutoriallm.local"
DOMAIN="localhost"EMAIL="[email protected]"
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.
OPENAPI_DOCS_URL=http://localhost:3001Connecting to the Database
Section titled “Connecting to the Database”TutoriaLLM requires a connection to PostgreSQL with vector capabilities. Here’s how to use Docker compose with pgvector.
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/datavolumes: db_data_db:Starting the Server
Section titled “Starting the Server”(Recommended) Starting with Docker
Section titled “(Recommended) Starting with Docker”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.
docker compose -f docker-compose.yml -f docker-compose.dev.override.yml up --build # Build and startdocker compose -f docker-compose.yml -f docker-compose.dev.override.yml up # StartIf you need to start the documentation development server, use pnpm.
Starting with pnpm
Section titled “Starting with pnpm”You can start the frontend and backend individually using pnpm.
Start the database:
docker compose upStart the frontend, backend, and documentation (if needed) with the following commands:
# Frontendcd apps/frontendpnpm i && pnpm dev
# Backendcd apps/backendpnpm i && pnpm dev
# Documentationcd apps/docspnpm i && pnpm devSharing Type Definitions
Section titled “Sharing Type Definitions”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.
# Generate type definitions in the backendcd apps/backendpnpm run buildTesting
Section titled “Testing”Run tests with the following command in the root directory:
pnpm testDeveloping Extensions
Section titled “Developing Extensions”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 extensionpnpm run buildAfter building, restart the frontend and backend.