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.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
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.
Set Up MongoDB Database
You have two options for MongoDB:Option A: MongoDB Atlas (Recommended)
- Create a free account at MongoDB Atlas
- Create a new cluster
- Create a database user with password
- Whitelist your IP address (or use 0.0.0.0/0 for development)
- Get your connection string and update
MONGO_URIin.env
Start Development Server
Run the server in development mode with hot-reload:The server will start on
http://localhost:8031 (or your configured PORT).Frontend Setup (Client)
The frontend is built with Next.js 16 and React 19, using TypeScript and Tailwind CSS.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
Configure Environment Variables
Copy the example environment file:Edit the
.env.local file:Variables prefixed with
NEXT_PUBLIC_ are exposed to the browser.Start Development Server
Run the client in development mode:The client will start on
http://localhost:8030.Running Both Applications
For full functionality, you need to run both the backend and frontend simultaneously: Terminal 1 (Backend):Available Scripts
Server Scripts
Client Scripts
Database Connection Details
The server uses Mongoose to connect to MongoDB with the following configuration:connected- Successfully connected to MongoDBerror- Connection error occurreddisconnected- 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
Port Already in Use
Port Already in Use
If you see Or change the PORT in your
EADDRINUSE error:.env file.MongoDB Connection Failed
MongoDB Connection Failed
Common issues:
- Invalid connection string - Check your
MONGO_URIformat - IP not whitelisted - Add your IP in MongoDB Atlas Network Access
- Wrong credentials - Verify username and password
- Network issues - Check firewall and internet connection
Client Can't Connect to API
Client Can't Connect to API
Verify:
- Backend server is running on port 8031
NEXT_PUBLIC_API_URLin client.env.localpoints to correct backend URL- CORS is properly configured in server
.env - Check browser console for network errors
Module Not Found Errors
Module Not Found 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

