Adding a Backend Server to Your LARS and CARS Project

Implement a backend server that can communicate with your frontend project with LARS and CARS!

Read as Markdown

This guide walks you through:

  1. Creating a rudimentary backend server
  2. Running it locally with LARS
  3. Pushing it to production with CARS
  4. Attaching (or sharing) a custom domain

Assumes you've completed the Starting a Frontend Project… quickstart.
Later guides will cover implementing the Topic Manager and Lookup Service in depth.


Prerequisites

  • Node.js 22 or 24 (maintained and patched)
  • Docker (with Compose plugin)
  • Git (optional, but recommended)
  • A BRC-100 wallet such as BSV Desktop installed and running
  • Your frontend project already set up with LARS & CARS

1. Scaffold your backend

1## 1. Create workspace and enter it
2mkdir backend && cd backend
3
4# 2. Initialize npm and install dependencies
5npm init -y
6npm install express
7npm install --save-dev typescript ts-node-dev @types/node @types/express
Copied!

Create a tsconfig.json in backend/:

1{
2  "compilerOptions": {
3    "target": "ES6",
4    "module": "commonjs",
5    "rootDir": "src",
6    "outDir": "dist",
7    "esModuleInterop": true,
8    "strict": true
9  }
10}
Copied!

Add a boilerplate express src/index.ts:

1import express, { Request, Response } from 'express';
2
3const app = express();
4const port = 3000;
5
6app.get('/', (req: Request, res: Response) => {
7  res.send('Hello, World!');
8});
9
10app.listen(port, () => {
11  console.log(`Server is running on port ${port}`);
12});
Copied!

Note: this boilerplate is a placeholder and will be replaced by the overlay system (Topic Manager & Lookup Service) during actual LARS/CARS deployment.

This allows LARS and CARS to invoke your server.


2. Update deployment-info.json for LARS

Open your root deployment-info.json and update your existing frontend deployment config to include "backend":

1"configs": [
2  {
3    "name": "Local LARS",
4    "provider": "LARS",
5    "network": "testnet",
6    "run": [
7      "backend",
8      "frontend"
9    ]
10  },
11  …,
12]
Copied!

Local development with LARS

3. Launch LARS with both services

1npx lars
Copied!

LARS Main Menu (template)

  • Manage LARS configuration → Edit LARS Deployment Info
  • Select “Local LARS” and ensure run: ["frontend", "backend"]
  • Start LARS (local only)

This will:

  • Run your frontend (npm run start) and the default backend SHIP and SLAP overlay service.
  • Open the frontend in your browser
  • Hot-reload both on file changes

4. Hook in Topic Manager & Lookup Service

Once your server is live, you'll plug in the Topic Manager and Lookup Service (covered in upcoming guides) under /backend/src. This will work with the default SHIP and SLAP implementation to add utility to your backend, allowing you to store and access data from the database.

Note: to deploy a backend with CARS, you must implement and register both the Topic Manager and Lookup Service—CARS will not function with only the default overlay logic. See the Guides section for setup instructions.


Production deployment with CARS

5. Update Your Production config

In the same deployment-info.json, add:

1"configs": [
2  …,
3    {
4      "name": "Production",
5      "provider": "CARS",
6      "CARSCloudURL": "https://cars.babbage.systems",
7      "network": "mainnet",
8      "deploy": [
9        "frontend",
10        "backend"
11      ],
12      "frontendHostingMethod": "HTTPS",
13      "projectID": "YOUR_PROJECT_ID"
14    }
15]
Copied!

6. Register your backend

Here, we register your backend with CARS, provision a cloud project, and link your deploy configuration.

1cars
Copied!

CARS Configurations Menu

  • Manage CARS configurations → Edit an existing CARS configuration

  • Select the Production entry

  • Confirm that the following prompts are set:

    1. Configuration name (e.g. my-bsv-deployment)
    2. CARS Cloud URL Custom → Default (https://cars.babbage.systems)
    3. Network Default (mainnet)
    4. What to release? select both frontend and backend
    5. Frontend hosting method HTTPS
  • Then choose to use your existing Project ID and your Prod deployment should be updated


7. Build a deployable artifact

1cars build            # or `cars build Production`
Copied!
  • Installs dependencies & runs npm run build in backend/
  • Packages your code + metadata into my-bsv-backend-<timestamp>.tgz

Verify:

1cars artifact ls
Copied!

8. Release to the cloud

Fast path:

1cars release now
Copied!

Manual path:

1cars release get-upload-url
2cars release upload-files <uploadURL> ./my-bsv-backend-*.tgz
Copied!

Check logs under Releases and find your backend URL in Project Info.


What you’ve achieved

  • A live backend service alongside your frontend that can communicate with one another
  • A comprehensive understanding of how to deploy your applications for both local (LARS) and prod (CARS) usage
  • A ready path to integrate Topic Manager and Lookup Service

Happy coding!

Was this page helpful?