Sports turf booking: React (Vite) + Chakra UI frontend, Express API, Neon Postgres + JWT auth. Payments are cash at the venue.
- Frontend: React 18, Vite, Chakra UI, React Router, Axios
- Backend: Node.js, Express,
pg,jsonwebtoken,bcryptjs - Database: Neon Postgres
-
Install
npm install cd server && npm install && cd ..
-
Environment
- Root: copy
.env.example→.env. UseVITE_API_URL=/apiso Vite proxies API calls to the backend (seevite.config.js). server/: copyserver/.env.example→server/.env. SetDATABASE_URL,JWT_SECRET(long random string), andFRONTEND_URL=http://localhost:3001.
- Root: copy
-
Optional sample turfs
cd server && npm run seed && cd ..
-
Run
npm run dev:all
Open http://localhost:3001. API: http://localhost:5000 (browser uses
/apivia the proxy).The first user who signs up is an admin (bootstrap). Add more admins from the admin dashboard if needed.
Separate terminals: cd server && npm run dev and npm run dev.
- Frontend:
npm run build→ output inbuild/. PointVITE_API_URLat wherever your API is served (same origin, or full URL with CORS allowed inFRONTEND_URLon the server). - API:
cd server && npm start(setNODE_ENV=production,JWT_SECRET, and comma-separatedFRONTEND_URLorigins as needed).
| Command | Description |
|---|---|
npm run dev:all |
API (5000) + Vite (3001) |
npm run dev |
Vite only |
npm run build |
Production build → build/ |
npm test |
Vitest (frontend) |
cd server && npm test |
Jest (API) |