This guide details how to set up and run the Binary MLM application, which consists of a Node.js/Express backend and a React/Vite frontend.
Before starting, ensure you have the following installed:
- Node.js (v16+ recommended)
- MongoDB (Must be running locally on default port
27017or configured viaMONGO_URI)
The backend handles the API, authentication, and database connections.
-
Navigate to the backend directory:
cd backend -
Install Dependencies:
npm install
-
Environment Configuration: The backend uses
dotenv. You can create a.envfile in thebackenddirectory if you wish to override defaults, but it runs out-of-the-box with:- Port:
5000 - MongoDB URI:
mongodb://localhost:27017/mlm - JWT Secret:
secret
Example
.envcontent (optional):PORT=5000 MONGO_URI=mongodb://localhost:27017/mlm JWT_SECRET=your_super_secret_key
- Port:
-
Start the Server: For development (with hot-reload via nodemon):
npm run dev
Or for standard start:
npm start
You should see:
MongoDB Connected Server running on port 5000
The frontend is a React application powered by Vite.
-
Navigate to the frontend directory: Open a new terminal window (keep the backend running) and run:
cd frontend -
Install Dependencies:
npm install
-
API Configuration: The frontend is configured to communicate with the backend at
http://localhost:5000/api/v1/by default (defined insrc/store/api.ts). Ensure your backend is running on this port. -
Start the Development Server:
npm run dev
You will see output similar to:
VITE v5.0.8 ready in 250 ms ➜ Local: http://localhost:5173/ -
Access the App: Open your browser and navigate to
http://localhost:5173/.
- MongoDB Connection Error: Ensure your local MongoDB service is running (
mongod). - API Connection Failed: Check if the backend is running on port
5000. If you changed the backend port, updatefrontend/src/store/api.tsto match. - Login Issues: Ensure you have registered a user or seeded the database. The initial "root" user might need to be created via the registration page or directly in the DB if not handled by a seed script.