Backend repo @ Geocipher-backend
A React + Vite frontend that recreates the GeoGuessr-style experience using Google Street View. This repository contains the client-side application for single-player rounds, timed challenges, and a multiplayer mode (WebSocket-based). It includes Google OAuth for authentication and a token-refresh flow handled by an Axios instance.
Key features:
- Interactive Street View gameplay (pan/zoom) via Google Maps/Street View components
- Single-player rounds with scoring and timer
- Multiplayer support via WebSocket (
VITE_WS_BASEURL) - Google OAuth sign-in and JWT handling (access token stored in cookie)
- Responsive UI styled with Tailwind CSS
Note: This repository is the frontend only. A backend server (API + WebSocket endpoints) is required for authentication, token refresh, score persistence, and multiplayer matchmaking.
Table of contents
- Why this project is useful
- Tech stack
- Getting started
- Environment variables
- Running the app
- Project structure
- Learning project for modern React with Vite and Tailwind CSS.
- Demonstrates integration with Google OAuth and the Street View API.
- Shows a practical token-refresh pattern and axios interceptors for authenticated APIs.
- Includes a lightweight multiplayer example using WebSockets.
- React 19 (functional components)
- Vite (dev server, build)
- Tailwind CSS for utility-first styling
- Axios for HTTP requests
- react-router for client routing
- @react-oauth/google for Google sign-in
- @vis.gl/react-google-maps for Street View / maps integration
Prerequisites:
- Node.js 18+ and npm (or use your preferred package manager)
Clone and install dependencies:
git clone https://github.com/kabir-afk/Geoguesser-clone-frontend.git
cd Geoguesser-clone-frontend
npm installCreate a .env file (do NOT commit secrets). Example .env:
# Set to "development" or "production"
VITE_ENVIRONMENT=development
# Google APIs (replace with your keys)
VITE_GOOGLE_MAPS_API_KEY=YOUR_GOOGLE_MAPS_API_KEY
VITE_GOOGLE_CLIENT_ID=YOUR_GOOGLE_CLIENT_ID
# Backend endpoints
VITE_SERVER_BASEURL=http://localhost:8000/
VITE_WS_BASEURL=ws://localhost:8000/ws/Important: keep credentials and API keys out of source control. The repository contains an example .env for local development only.
Development server (hot reload):
npm run devBuild for production:
npm run buildThe frontend expects the following environment variables (set these in a local .env):
VITE_ENVIRONMENT—developmentorproduction. Whendevelopment,axiosdefaults tohttp://localhost:8000/.VITE_SERVER_BASEURL— Backend base URL used in production builds.VITE_WS_BASEURL— WebSocket URL for multiplayer.VITE_GOOGLE_MAPS_API_KEY— Google Maps / Street View API key.VITE_GOOGLE_CLIENT_ID— Google OAuth client ID.
The client uses src/axiosinstance.js to attach Authorization headers (reads accessToken from cookies) and runs a transparent refresh flow on 401 responses.
Top-level files & folders you will use most often:
src/— application sourceApp.jsx— route definitions and top-level UImain.jsx— app entryaxiosinstance.js— axios instance + token refresh logiccomponents/— UI components (e.g.,StreetView.jsx,Timer.jsx,Navbar.jsx,GoogleAuth.jsx)pages/— route pages (Login,Register,Multiplayer,Profile)
index.html— Vite HTML entrypackage.json— scripts and dependencies
This frontend expects a backend that provides:
- Authentication endpoints (login, logout,
api/token/refresh/) - HTTP API endpoints for game state and scores
- A WebSocket endpoint for multiplayer at the
VITE_WS_BASEURLaddress
For local development the axios instance falls back to http://localhost:8000/ when VITE_ENVIRONMENT is development.
Built with ❤️