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!
This guide walks you through:
- Creating a rudimentary backend server
- Running it locally with LARS
- Pushing it to production with CARS
- 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/expressCreate 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}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});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]Local development with LARS
3. Launch LARS with both services
1npx larsLARS 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]6. Register your backend
Here, we register your backend with CARS, provision a cloud project, and link your deploy configuration.
1carsCARS Configurations Menu
-
Manage CARS configurations → Edit an existing CARS configuration
-
Select the
Productionentry -
Confirm that the following prompts are set:
- Configuration name (e.g.
my-bsv-deployment) - CARS Cloud URL Custom → Default (https://cars.babbage.systems)
- Network Default (mainnet)
- What to release? select both
frontendandbackend - Frontend hosting method HTTPS
- Configuration name (e.g.
-
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`- Installs dependencies & runs
npm run buildinbackend/ - Packages your code + metadata into
my-bsv-backend-<timestamp>.tgz
Verify:
1cars artifact ls8. Release to the cloud
Fast path:
1cars release nowManual path:
1cars release get-upload-url
2cars release upload-files <uploadURL> ./my-bsv-backend-*.tgzCheck 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!
