Skip to main content

Quickstart Guide

Get the Horse Trust platform running locally in just a few minutes. This guide will walk you through cloning the repository, installing dependencies, configuring environment variables, and starting both the client and server applications.

Prerequisites

Before you begin, ensure you have the following installed:

Node.js

Version 24.13.0 or higher

Git

Version 2.43.0 or higher

MongoDB

MongoDB Atlas account or local MongoDB instance

npm

Comes bundled with Node.js

Installation

1

Clone the Repository

Clone the Horse Trust repository to your local machine:
The repository follows a monorepo structure with separate client and server directories.
2

Set Up the Backend Server

Navigate to the server directory and install dependencies:

Configure Server Environment Variables

Create a .env file in the server directory based on .env.example:
server/.env
Replace MONGO_URI with your actual MongoDB connection string. You can get one from MongoDB Atlas for free.
The JWT_SECRET should be a long, random string. In production, use a cryptographically secure random value.

Start the Server

Run the development server:
The server will start on http://localhost:8031 (or the port specified in your .env file).

Test the Server

Verify the server is running by testing the health endpoint:
You should receive a response like:
3

Set Up the Frontend Client

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

Configure Client Environment Variables

Create a .env.local file in the client directory:
client/.env.local
The NEXT_PUBLIC_API_URL should point to your backend server. Make sure the port matches your server configuration.

Start the Client

Run the Next.js development server:
The client will start on http://localhost:8030.
4

Access the Application

Open your browser and navigate to:
You should see the Horse Trust landing page with:
  • Hero section introducing the platform
  • Featured horses section
  • Security features section
  • Navigation header and footer

Development Workflow

Running Both Services

For development, you’ll need two terminal windows:

Available Scripts

Backend Scripts

server/package.json

Frontend Scripts

client/package.json

Authentication Flow

Register a New User

Use the registration action to create a new account:
client/app/actions/auth.ts

Login Flow

Creating Your First Horse Listing

Once logged in as a seller, you can create horse listings:
client/app/actions/horses.ts

Horse Data Structure

At least 3 photos are required for each horse listing. The platform validates this at the database level.

Real-time Chat Setup

The platform uses Socket.io for real-time messaging between buyers and sellers:
server/src/index.ts

Troubleshooting

Common Issues

  • Verify your MONGO_URI is correct
  • Check if your IP address is whitelisted in MongoDB Atlas
  • Ensure network connectivity to MongoDB
  • Check MongoDB Atlas cluster status
  • Ensure CORS_ORIGINS in server .env includes your client URL
  • Check that both frontend and backend are running
  • Verify the NEXT_PUBLIC_API_URL matches your backend URL
Change the port in your .env files:
  • Server: Update PORT in server/.env
  • Client: Update the -p flag in client/package.json scripts
  • Ensure JWT_SECRET is set in server .env
  • Check token expiration (default 10 days)
  • Clear browser cookies and re-login

Database Auto-Reconnect

The platform includes an automatic database reconnection feature:
client/app/utils/apiFetch.ts
The /health/reconnect endpoint called by the frontend is referenced in the client code but not yet implemented in the backend API. The frontend includes this code for future database reconnection functionality.

Next Steps

Architecture Overview

Learn about the system architecture and how components interact

API Reference

Explore the complete API documentation

Contributing

Learn how to contribute to the Horse Trust project

Deployment

Deploy Horse Trust to production
For production deployment, remember to:
  • Use strong, unique values for JWT_SECRET
  • Set NODE_ENV=production
  • Configure proper CORS origins
  • Use SSL/TLS certificates
  • Set up proper MongoDB authentication
  • Enable security features (Helmet, rate limiting)