- Install dependencies (requires Node 18+):
npm install
- Run both the Vite client and Express API with one command:
npm run dev
- Vite serves the React app on
http://localhost:4173. - The backend API runs on
http://localhost:4000(override withAPI_PORT).
- Vite serves the React app on
- The client proxies
/api/*requests to the backend during development.
npm run build # bundles the React app to /dist
npm run start # serves the API and, in production mode, the /dist filesSet VITE_API_BASE_URL if the client needs to call a hosted API that is not the same origin. The backend respects API_PORT or PORT for binding.
- Ensure
vercelCLI is installed (npm i -g vercel) and runvercel loginif needed. - Add the required environment variables in the Vercel dashboard or via CLI:
DATABASE_URL(andPGSSLMODEif your Postgres host enforces TLS)- Optional client vars prefixed with
VITE_…
- Deploy:
vercel # first deployment, answers will be stored in .vercel/project.json vercel --prod # promote to production
- Vercel uses
npm run buildand serves/distas a static site. - The catch-all function
api/[...route].jsmounts the Express app so/api/*works in both dev and prod.
- Vercel uses
- Provision a PostgreSQL database and capture the connection string, e.g.
postgres://user:password@localhost:5432/mdh. - Export
DATABASE_URLbefore starting the server:export DATABASE_URL="postgres://user:password@localhost:5432/mdh" export PGSSLMODE=require # optional, enables SSL with relaxed cert checking
- Start the backend (
npm run devornpm run start). The API now exposes:/api/health→ includes database health metadata if configured./api/db/time→ runsSELECT NOW()to confirm connectivity.