A web application that visualizes city road networks. A new city is featured every day.
- City Road Visualization: Render detailed road networks for cities.
- Daily City: A new city featured every day.
- Random City: Discover a random city's road network.
- Interactive Map: Zoom and pan to explore the details.
- Framework: FastAPI
- Language: Python
- Key Libraries:
uvicorn,httpx,pydantic
- Docker and Docker Compose (Recommended)
- OR Node.js and Python 3.8+ for manual setup
-
Clone the repository:
git clone <repository-url> cd city-roads
-
Start the application:
docker-compose up --build
-
Access the application:
- Frontend: http://localhost:5173
- Backend API Docs: http://localhost:8001/docs
- Navigate to the backend directory:
cd backend - Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Run the server:
uvicorn app.main:app --reload --port 8000
- Navigate to the frontend directory:
cd frontend - Install dependencies:
npm install
- Run the development server:
npm run dev
This project includes a GitHub Action workflow that automatically generates a new random city every day.
- Workflow:
.github/workflows/daily_city.yml - Script:
scripts/generate_city.py - Output:
frontend/public/data/current_city.pbf(JSON format) andmetadata.json
The frontend can be deployed as a static site (e.g., GitHub Pages, Netlify) that consumes the pre-generated daily city data.
To enable static mode:
- Set the environment variable
VITE_USE_STATIC_DATA=truein your build environment or.env.local. - Build the frontend:
npm run build.
In this mode, the app will load the city from /data/current_city.pbf instead of querying the backend API.
.
├── backend/ # FastAPI backend application
│ ├── app/ # Application source code
│ │ ├── api/ # API routers (roads, daily, random)
│ │ └── main.py # Application entry point
│ └── requirements.txt
├── frontend/ # React frontend application
│ ├── src/ # Source code
│ └── package.json
├── scripts/ # Utility scripts
│ └── generate_city.py # Daily city generator
└── docker-compose.yaml # Docker orchestration
Inspired by: https://github.com/anvaka/city-roads
