Data visualization tool that authenticates with Google, reads configurable sales notification emails from Gmail, aggregates country data, and displays it on an interactive world map.
The app should be live and usable here: https://mailsalesmap.org
- Frontend: React + TypeScript + Vite (served by Cloudflare Pages)
- Backend: Cloudflare Worker (handles OAuth and Gmail API)
- Storage: Cloudflare KV (sessions and caching)
# Install dependencies for both frontend and backend
npm install
# Run both frontend and backend simultaneously
npm run dev
# Access the app at http://localhost:5173- Node.js 18+
- Google Cloud Console project with OAuth 2.0 credentials
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Gmail API
- Go to APIs & Services → Credentials
- Create OAuth 2.0 Client ID (Web application)
- Add authorized origins:
http://localhost:5173(frontend)https://mailsalesmap.org(production)
- Add authorized redirect URIs:
http://localhost:8787/api/auth/callback(local backend)https://mailsalesmap.org/api/auth/callback(production)
Create worker/.dev.vars with your credentials:
# worker/.dev.vars
CLOUDFLARE_ACCOUNT_ID=your_cloudflare_account_id
CLOUDFLARE_API_TOKEN=your_cloudflare_api_token
GOOGLE_CLIENT_ID=your_google_client_id_here.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-your_google_client_secret_here
GITHUB_TOKEN=your_github_token_here
# Environment configuration
ENVIRONMENT=development.dev.vars to git - it contains secrets!
# Root dependencies (for scripts)
npm install
# Frontend dependencies
cd frontend && npm install && cd ..
# Backend dependencies
cd worker && npm install && cd ..Option A: Run everything at once
npm run dev
# This starts both frontend (localhost:5173) and backend (localhost:8787)Option B: Run separately
# Terminal 1 - Backend
cd worker && npm run dev
# Terminal 2 - Frontend
cd frontend && npm run dev- Frontend: http://localhost:5173
- Backend API: http://localhost:8787/api/health
- Login Flow: Click login button on frontend → complete Google OAuth → redirected back to dashboard
# Build both frontend and backend
npm run build
# Type check both projects
npm run type-check
# Lint both projects
npm run lint- Ensure redirect URIs in Google Console match exactly:
http://localhost:8787/api/auth/callback - Check that
ENVIRONMENT=developmentis set inworker/.dev.vars - Verify your
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETare correct
- Access the app via
http://localhost:5173(frontend), notlocalhost:8787(backend) - Frontend proxies API requests to backend automatically
- Clear browser cookies and restart both servers
- Check that KV namespaces are properly configured in
worker/wrangler.toml
