Skip to main content
This guide will walk you through setting up the Horse Trust platform for local development.

Prerequisites

Before you begin, ensure you have the following installed:

Node.js

Version 24.13.0 or higher recommended

Git

Version 2.43.0 or higher

MongoDB

MongoDB Atlas account or local MongoDB instance

npm

Comes with Node.js installation

Project Structure

The Horse Trust platform is a monorepo with two main applications:

Clone the Repository

First, clone the repository and navigate to the project directory:

Backend Setup (Server)

The backend is built with Express.js and TypeScript, using MongoDB as the database.
1

Navigate to Server Directory

2

Install Dependencies

Install all required npm packages:
This will install:
  • Express.js - Web framework
  • Mongoose - MongoDB ODM
  • Socket.io - Real-time messaging
  • JWT & bcryptjs - Authentication
  • TypeScript - Type safety
  • And other dependencies
3

Configure Environment Variables

Copy the example environment file and configure it:
Edit the .env file with your configuration:
See the Environment Variables guide for detailed configuration options.
4

Set Up MongoDB Database

You have two options for MongoDB:Option A: MongoDB Atlas (Recommended)
  1. Create a free account at MongoDB Atlas
  2. Create a new cluster
  3. Create a database user with password
  4. Whitelist your IP address (or use 0.0.0.0/0 for development)
  5. Get your connection string and update MONGO_URI in .env
Option B: Local MongoDB
5

Start Development Server

Run the server in development mode with hot-reload:
The server will start on http://localhost:8031 (or your configured PORT).
6

Verify Server is Running

Test the server endpoint:
Expected response:
If you see this response, your backend is configured correctly!

Frontend Setup (Client)

The frontend is built with Next.js 16 and React 19, using TypeScript and Tailwind CSS.
1

Navigate to Client Directory

Open a new terminal window and navigate to the client directory:
2

Install Dependencies

Install all required npm packages:
This will install:
  • Next.js 16 - React framework
  • React 19 - UI library
  • Tailwind CSS - Styling
  • Lucide React - Icons
  • TypeScript - Type safety
3

Configure Environment Variables

Copy the example environment file:
Edit the .env.local file:
Variables prefixed with NEXT_PUBLIC_ are exposed to the browser.
4

Start Development Server

Run the client in development mode:
The client will start on http://localhost:8030.
5

Access the Application

Open your browser and navigate to:
You should see the Horse Trust application home page!

Running Both Applications

For full functionality, you need to run both the backend and frontend simultaneously: Terminal 1 (Backend):
Terminal 2 (Frontend):

Available Scripts

Server Scripts

Client Scripts

Database Connection Details

The server uses Mongoose to connect to MongoDB with the following configuration:
Connection Events:
  • connected - Successfully connected to MongoDB
  • error - Connection error occurred
  • disconnected - Connection lost, automatic reconnection attempts

Real-Time Features (Socket.io)

The platform includes real-time messaging functionality powered by Socket.io:
  • Authentication: JWT-based socket authentication
  • Events: Message sending, typing indicators, read receipts
  • Rooms: User-specific and conversation-specific rooms
  • Port: WebSocket runs on the same port as HTTP server (8031)

Troubleshooting

If you see EADDRINUSE error:
Or change the PORT in your .env file.
Common issues:
  1. Invalid connection string - Check your MONGO_URI format
  2. IP not whitelisted - Add your IP in MongoDB Atlas Network Access
  3. Wrong credentials - Verify username and password
  4. Network issues - Check firewall and internet connection
Enable MongoDB connection logs to see detailed error:
Verify:
  1. Backend server is running on port 8031
  2. NEXT_PUBLIC_API_URL in client .env.local points to correct backend URL
  3. CORS is properly configured in server .env
  4. Check browser console for network errors

Next Steps

Environment Variables

Learn about all configuration options

Production Deployment

Deploy your application to production

Contributing

Read CONTRIBUTING.md for development guidelines

API Documentation

Explore the API endpoints and usage