SPA for an African Startup - Safe Pocket Map (SPM).
# safe-pocket-map-spa
Mini scaffold for Safe Pocket Map (SPM).
Getting started
- Install frontend and backend dependencies:
```bash
npm install --prefix frontend
npm install --prefix backend
```
- Run frontend dev (Vite):
```bash
npm run dev --prefix frontend
```
- Run backend locally:
```bash
npm run dev --prefix backend
```
Tests
- Run backend tests:
```bash
npm test --prefix backend
```
- Run frontend tests:
```bash
npm test --prefix frontend
```
Environment
- Frontend: set `VITE_API_URL` for API base URL and `VITE_GA_ID` for Google Analytics (optional).
- Backend: provide `GOOGLE_CLIENT_EMAIL`, `GOOGLE_PRIVATE_KEY`, `GOOGLE_SHEET_ID`, and `CORS_ORIGIN` in `.env` for production/Vercel.
Deployment notes
- Frontend should be deployed to Vercel (Vite build). Backend can be deployed as serverless using the `backend/api/handler.js` (serverless-http) or as a separate Node service. Use Vercel environment variables to provide Google credentials.
Vercel & environment key notes
- If you deploy to Vercel and paste the service account `GOOGLE_PRIVATE_KEY` into the dashboard, replace real newlines with the two-character escape sequence `\n` (i.e. one-line value with `\n` where newlines were). Example in Vercel: `-----BEGIN PRIVATE KEY-----\nMIIEvg...\n-----END PRIVATE KEY-----\n`.
- Alternatively, base64-encode the JSON private key and set `GOOGLE_PRIVATE_KEY_B64` in Vercel, then decode in your service at runtime. (We didn't implement decoding in scaffold; choose whichever you prefer.)
- Alternatively, base64-encode the JSON private key and set `GOOGLE_PRIVATE_KEY_B64` in Vercel, then decode in your service at runtime. The scaffold supports both methods: `GOOGLE_PRIVATE_KEY` with `\n` escapes or `GOOGLE_PRIVATE_KEY_B64` (the service will decode it at startup).
- CORS: by default the scaffold uses `CORS_ORIGIN=
localhost` for local dev — update this to your Vercel preview/production domain …