Skip to main content

Backend Local Development

This guide will walk you through setting up the backend environment for development.

Prerequisites

Before you begin, ensure you have the following installed:

Local Development Setup

git clone <repository_url>
cd jet-admin
  1. Install dependencies

    npm install
    npm install --workspaces

Environment Configuration

Create a .env file in the apps/backend directory with the following variables:

# Server Configuration
NODE_ENV=development
PORT=8090
EXPRESS_REQUEST_SIZE_LIMIT="5mb"

# Database Configuration
DATABASE_URL="postgresql://user:pass@localhost:5432/db?schema=public"


# Node Identification
NODE_ID="dev_node_1"

# AI configuration
GEMINI_API_KEY=""

# CORS Settings
CORS_WHITELIST="http://localhost:3000,http://localhost:5173,http://127.0.0.1:3000,http://127.0.0.1:3001,http://localhost:3001"

# Logging Configuration
SYSLOG_HOST=127.0.0.1
SYSLOG_PORT=514
SYSLOG_PROTOCOL=udp4
SYSLOG_LEVEL="warning"
LOG_LEVEL="info"
LOG_RETENTION=7
LOG_FILE_SIZE=1
caution

Be sure to replace the placeholder values with your actual configurations, especially the DATABASE_URL for security purposes.

Firebase Configuration

Generate Firebase key from Firebase console and rename the file to firebase-key.json in the root directory with the following structure:

{
"type": "",
"project_id": "",
"private_key_id": "",
"private_key": "",
"client_email": "",
"client_id": "",
"auth_uri": "",
"token_uri": "",
"auth_provider_x509_cert_url": "",
"client_x509_cert_url": "",
"universe_domain": ""
}
warning

Fill in your actual Firebase credentials. Never commit this file to your repository.

Database Setup

We use Prisma as our ORM for database management. Set up your database with these commands:

# Navigate to backend app
cd apps/backend

# Create database schema
npx prisma migrate dev

# Open visual database editor (optional)
npx prisma studio

# Return to root
cd ../..

The first command applies migrations based on your schema definition in prisma/schema.prisma, while the second opens a visual interface to manage your database at http://localhost:5555.

Running the Application

Start the development server with hot-reload enabled:

npm run start:b

Your API will be available at http://localhost:8090.

Troubleshooting

If you encounter issues during setup or deployment, check the following:

  • Ensure PostgreSQL is running and accessible
  • Verify environment variables are correctly set
  • Check network connectivity for external services
  • Review logs for specific error messages

Additional Resources