# Municipal Transit Planner

A planning and analysis tool for municipal transit agencies to evaluate routes, stops, schedules, service coverage, and rider access across a city or region.

## Overview

Municipal Transit Planner helps planners combine GTFS data, demographic layers, street networks, and service policy rules to model transit accessibility and identify service gaps. It supports day-to-day planning workflows such as route review, stop consolidation, frequency analysis, and equity-focused coverage reporting.

## Features

- Import and validate GTFS feeds
- View routes, stops, trips, and service calendars on an interactive map
- Analyze stop spacing, route overlap, and schedule frequency
- Calculate walksheds and population coverage by stop or route
- Compare existing and proposed service scenarios
- Export reports as CSV, GeoJSON, and PDF
- Configure agency-specific service standards
- Support multiple planning scenarios without modifying source data

## Install

### Requirements

- Node.js 20+
- PostgreSQL 15+
- PostGIS 3+
- npm or pnpm

### Setup

```bash
git clone https://github.com/example/municipal-transit-planner.git
cd municipal-transit-planner
npm install
cp .env.example .env
npm run db:migrate
npm run dev
```

The app will be available at:

```text
http://localhost:3000
```

## Usage

### Import a GTFS feed

```bash
npm run gtfs:import -- ./data/agency-feed.zip
```

### Start the planner

```bash
npm run dev
```

### Run analysis jobs

```bash
npm run analyze:coverage
npm run analyze:frequency
npm run analyze:stop-spacing
```

### Export scenario results

```bash
npm run export -- --scenario baseline --format geojson
npm run export -- --scenario proposed-network --format csv
```

## Configuration

Configuration is managed through environment variables in `.env`.

```env
DATABASE_URL=postgres://planner:planner@localhost:5432/transit_planner
APP_PORT=3000
MAP_DEFAULT_LAT=43.6532
MAP_DEFAULT_LNG=-79.3832
MAP_DEFAULT_ZOOM=12
GTFS_UPLOAD_DIR=./data/uploads
EXPORT_DIR=./exports
WALKSHED_DISTANCE_METERS=800
DEFAULT_SERVICE_DAY=weekday
ENABLE_EQUITY_ANALYSIS=true
```

### Key Settings

| Variable | Description | Default |
| --- | --- | --- |
| `DATABASE_URL` | PostgreSQL connection string | Required |
| `APP_PORT` | Local application port | `3000` |
| `MAP_DEFAULT_LAT` | Initial map latitude | `43.6532` |
| `MAP_DEFAULT_LNG` | Initial map longitude | `-79.3832` |
| `MAP_DEFAULT_ZOOM` | Initial map zoom level | `12` |
| `GTFS_UPLOAD_DIR` | Directory for uploaded GTFS feeds | `./data/uploads` |
| `EXPORT_DIR` | Directory for generated exports | `./exports` |
| `WALKSHED_DISTANCE_METERS` | Walking distance used for coverage analysis | `800` |
| `DEFAULT_SERVICE_DAY` | Default service calendar type | `weekday` |
| `ENABLE_EQUITY_ANALYSIS` | Enables demographic overlay reporting | `true` |

## License

MIT