https://www.ebrlogisticllc.net/logistic-vans-20-26-ft-straight-trucks-43-53-trailers-dry-vans-or-referee-ltl-ptl-and-ftltebr-logistics-transportation-#tebr-logistics-transportation-const express = require('express'); const Load = require('./models/Load'); const { authMiddleware } = require('./auth'); const router = express.Router(); // Post a new load (Shipper) router.post('/', authMiddleware, async (req, res) => { if (req.user.role !== 'Shipper') return res.status(403).json({ error: 'Forbidden' }); const load = await Load.create({ ...req.body, shipper: req.user.id }); res.json(load); }); // Get available loads router.get('/', async (req, res) => { const loads = await Load.find({ status: 'open' }); res.json(loads); }); // Claim a load (Carrier) router.post('/:id/claim', authMiddleware, async (req, res) => { if (req.user.role !== 'Carrier' && req.user.role !== 'Broker') return res.status(403).json({ error: 'Forbidden' }); const load = await Load.findById(req.params.id); if (!load || load.status !== 'open') return res.status(404).json({ error: 'Not found' }); load.status = 'claimed'; load.carrier = req.user.id; await load.save(); res.json(load); }); module.exports = router; const express = require('express'); const jwt = require('jsonwebtoken'); const bcrypt = require('bcrypt'); const User = require('./models/User'); const router = express.Router(); const JWT_SECRET = process.env.JWT_SECRET || 'SECRET'; // Register router.post('/register', async (req, res) => { const { email, password, role, company } = req.body; const hash = await bcrypt.hash(password, 10); const user = await User.create({ email, password: hash, role, company }); const token = jwt.sign({ id: user._id, role: user.role }, JWT_SECRET, { expiresIn: '1d' }); res.json({ token, user }); }); // Login router.post('/login', async (req, res) => { const { email, password } = req.body; const user = await User.findOne({ email }); if (!user) return res.status(401).json({ error: 'Invalid credentials' }); const match = await bcrypt.compare(password, user.password); if (!match) return res.status(401).json({ error: 'Invalid credentials' }); const token = jwt.sign({ id: user._id, role: user.role }, JWT_SECRET, { expiresIn: '1d' }); res.json({ token, user }); }); // JWT Middleware function authMiddleware(req, res, next) { const token = req.headers.authorization?.split(' ')[1]; if (!token) return res.status(401).json({ error: 'No token' }); try { req.user = jwt.verify(token, JWT_SECRET); next(); } catch { res.status(401).json({ error: 'Invalid token' }); } } module.exports = { router, authMiddleware };# Central Dispatch Clone – API Design | Endpoint | Method | Description | Request Body | Response | Roles | |-------------------------|--------|----------------------------------|-------------------|---------------|---------------| | /auth/register | POST | Register new user | email, password, role, company info | JWT, user info | All | | /auth/login | POST | Login user | email, password | JWT, user info| All | | /loads | GET | List available loads | filters | loads array | All | | /loads | POST | Post a new load | load details | load object | Shipper | | /loads/:id | GET | Get load details | | load object | All | | /loads/:id/claim | POST | Claim a load | | job object | Carrier/Broker| | /users/:id | GET | Get user profile | | user object | All | | /messages | GET | List messages | | messages array| All | | /messages | POST | Send new message | to, body | message object| All | | /ratings | POST | Submit a rating | to, rating, review| rating object | All | | /admin/users | GET | List all users | | users array | Admin | | /admin/loads | GET | List all loads | | loads array | Admin |# Central Dispatch Clone – Wireframes ## 1. Login / Signup - Fields: Email, Password, Role Select (Shipper/Carrier/Broker) - Buttons: Login, Signup, Forgot Password ## 2. Dashboard - Tabs/Sidebar: Loads, Profile, Messages, Ratings, Settings - Loads Table/List: - Columns: Load ID, Origin, Destination, Vehicle, Price, Status, Actions ## 3. Load Posting (Shipper) - Form Fields: - Pickup Location (auto-complete) - Dropoff Location (auto-complete) - Date(s) - Vehicle Info (year, make, model, VIN) - Price Offer - Instructions/Notes - Attach Documents ## 4. Search Loads (Carrier/Broker) - Filters: - Location (radius) - Date - Vehicle type - Price range - Status (open/claimed/completed) - Results: Table/List with Claim/Bid button ## 5. Load Details - Full load info - Claim/Bid option - Message Shipper button ## 6. Messaging - Inbox, Conversation view - Respond, attach files ## 7. Profile Page - Company info - Contact, insurance docs - Ratings ## 8. Admin Panel - User list - Load moderation - Disputes - Analytics --- *Ask for Figma or Miro links if you want online editable wireframes!* ## 1. Login / Signup - Fields: Email, Password, Role Select (Shipper/Carrier/Broker) - Buttons: Login, Signup, Forgot Password ## 2. Dashboard - Tabs/Sidebar: Loads, Profile, Messages, Ratings, Settings - Loads Table/List: - Columns: Load ID, Origin, Destination, Vehicle, Price, Status, Actions ## 3. Load Posting (Shipper) - Form Fields: - Pickup Location (auto-complete) - Dropoff Location (auto-complete) - Date(s) - Vehicle Info (year, make, model, VIN) - Price Offer - Instructions/Notes - Attach Documents ## 4. Search Loads (Carrier/Broker) - Filters: - Location (radius) - Date - Vehicle type - Price range - Status (open/claimed/completed) - Results: Table/List with Claim/Bid button ## 5. Load Details - Full load info - Claim/Bid option - Message Shipper button ## 6. Messaging - Inbox, Conversation view - Respond, attach files ## 7. Profile Page - Company info - Contact, insurance docs - Ratings ## 8. Admin Panel - User list - Load moderation - Disputes - Analytics