Full-stack demo based on the Ping design doc.
- Node.js 18+
- MongoDB (Atlas or local)
- Google Maps API key (Maps JavaScript API enabled)
- Google OAuth credentials (OAuth 2.0 Client ID)
- Copy env:
cp backend/.env.example backend/.env
- Update
MONGODB_URIinbackend/.env. - Seed demo data:
cd backendnpm installnpm run db:seed
- Start the API:
npm run dev
- Add Google OAuth credentials in
backend/.env:
GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETGOOGLE_CALLBACK_URL(default already set)
- Copy env:
cp frontend/.env.example frontend/.env
- Set
VITE_GOOGLE_MAPS_API_KEYinfrontend/.env. - Start the app:
cd frontendnpm installnpm run dev
Open http://localhost:5173.
- The frontend login page uses Google OAuth via
GET /auth/google. - Dev login is still available at
POST /auth/devwhenDEV_AUTH_ENABLED=true(useful for local API testing). REDIS_URLis optional for local development (in-memory sessions are used when omitted), but required for AWS Lambda deployments.
Recommended setup:
- Frontend: Vercel
- Backend API: AWS Lambda + API Gateway
- Database: MongoDB Atlas
If deploying the backend to Lambda, use backend/src/lambda.handler as the
function entrypoint and keep Redis sessions enabled (REDIS_URL required).
Quick deploy with Serverless Framework:
- Install backend dependencies:
cd backendnpm install
- Export required environment variables in your shell (or set in CI):
NODE_ENV=productionMONGODB_URI=<your mongodb atlas uri>SESSION_SECRET=<strong random secret>SESSION_TTL_SECONDS=604800REDIS_URL=<your redis connection url>REDIS_SESSION_PREFIX=ping:sess:ALLOWED_ORIGINS=https://<your-frontend-domain>FRONTEND_URL=https://<your-frontend-domain>- (optional) Google OAuth values if used:
GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETGOOGLE_CALLBACK_URL=https://<your-backend-domain>/auth/google/callback
- Deploy:
npm run deploy:lambda -- --stage prod --region us-east-1
- Use the printed API Gateway URL as your backend URL.
- Verify
https://<your-backend-domain>/healthreturns{ "ok": true }. - Update frontend
VITE_API_BASE_URLto that URL and redeploy frontend.
Deploy frontend/ with:
- Build command:
npm run build - Output directory:
dist
Set environment variables:
VITE_API_BASE_URL=https://<your-backend-domain>VITE_GOOGLE_MAPS_API_KEY=<your maps browser key>VITE_GOOGLE_MAP_ID=<your map id>(optional, defaults toDEMO_MAP_ID)
- Use your frontend production URL as the public site.
- Ensure backend
ALLOWED_ORIGINSincludes that exact URL. - If you update domains, redeploy both sides with matching env vars.
The initial idea was developed during a hackathon collaboration with @jl205-maker, Suosi He, Zihan Zhu. This version has been fully redesigned and implemented independently.