Skip to main content
Get started with developing Lens Music by setting up the monorepo on your local machine. This guide walks you through installing prerequisites, configuring environment variables, and running the development servers.

Prerequisites

Before you begin, ensure you have the following installed on your system:

Node.js

Version 18.x or higher recommended

PostgreSQL

Version 14.x or higher for the database

npm

Comes with Node.js installation

Git

For version control and cloning the repository

Clone the repository

Start by cloning the Lens Music repository to your local machine:
git clone https://github.com/lens-ltd/lens-music
cd lens-music

Configure environment variables

The API requires environment variables to connect to the database and configure the server.
1

Create environment file

Navigate to the api directory and create a .env file:
cd api
cp .env.example .env
2

Configure database connection

Open the .env file and configure your PostgreSQL connection:
.env
NODE_ENV=development
PORT=8080

DB_HOST=localhost
DB_PORT=5432
DB_USER=your_postgres_user
DB_PASSWORD=your_postgres_password
DB_NAME=lens_music
Replace your_postgres_user, your_postgres_password, and lens_music with your actual PostgreSQL credentials and desired database name.
3

Create the database

Create the PostgreSQL database for Lens Music:
psql -U your_postgres_user -c "CREATE DATABASE lens_music;"
For detailed information about all environment variables, see the environment variables documentation.

Quick start with dev script

The easiest way to run both the API and client is using the provided dev.sh script:
1

Make the script executable

chmod +x dev.sh
2

Run the development servers

./dev.sh
This script will:
  • Install dependencies for both API and client
  • Start the API server on port 8080
  • Start the client development server with Vite

Manual setup

If you prefer to run the servers manually or need more control:
1

Install dependencies

cd api
npm install
2

Run database migrations

TypeORM will automatically sync entities in development mode when you start the server.
3

Seed the database (optional)

Populate the database with initial data:
npm run seed
4

Start the development server

npm run dev
The API will be available at http://localhost:8080

Verify the installation

Once both servers are running, verify the installation:
Open your browser or use curl to check the API:
curl http://localhost:8080
You should receive a response from the NestJS server.
Navigate to http://localhost:5173 in your browser. You should see the Lens Music landing page.
Verify that the API can connect to PostgreSQL by checking the server logs for any connection errors.

Available scripts

Here are the key npm scripts available in each workspace:

API Scripts

ScriptCommandDescription
Developmentnpm run devStart the API server with hot reload using nodemon
Buildnpm run buildCompile TypeScript to JavaScript in the dist/ folder
Startnpm run startRun the production build
Seednpm run seedPopulate the database with seed data

Client Scripts

ScriptCommandDescription
Developmentnpm run devStart Vite development server with hot module replacement
Buildnpm run buildBuild the production-ready client application
Previewnpm run previewPreview the production build locally
Lintnpm run lintRun ESLint to check for code issues

Next steps

Monorepo structure

Learn about the project organization and directory structure

Database schema

Understand the database entities and relationships

Environment variables

Complete reference for all configuration options

API reference

Explore the API endpoints and usage
The development servers use port 8080 for the API and port 5173 for the client. Make sure these ports are available on your system.

Build docs developers (and LLMs) love