A FastAPI service that sends automated reminders before San Francisco street sweeping to help you avoid parking tickets.
- 📍 Location-based lookup: Finds your exact street and block side from GPS coordinates
- 📅 Accurate scheduling: Calculates next street sweeping date using SF's official data
- 🔔 Automated reminders: Sends notifications at 7 AM and 8 PM the day before sweeping
- 🗄️ Persistent storage: Tracks parking locations in PostgreSQL database
- Share your location via the iOS Shortcut
- The API determines your street, block side, and next sweeping date
- You'll receive reminders the day before and morning of street sweeping.
- Install the Street Sweeping Shortcut
- update the shortcut so it has your phone number instead of mine
- Park your car and run the shortcut
- You'll automatically receive reminders before the next sweep (once i get permission from the US govermnet to send texts - soon!)
That's it! The API is already deployed and running.
Want to run this locally or deploy your own instance? Here's how:
- Docker
- PostgreSQL database
- SimplePush account (for notifications)
- Clone the repository
git clone https://github.com/yourusername/street_sweeping_API.git
cd street_sweeping_API- Create
.envfile
DATABASE_URL=postgresql://user:password@localhost:5432/street_sweeping
SIMPLEPUSH_KEY=your_simplepush_key- Build and run with Docker
docker build -t street-sweep .
docker run -p 8000:8000 --env-file .env street-sweep- Test the API
curl -X POST http://localhost:8000/next_sweep \
-H "Content-Type: application/json" \
-d '{
"latitude": 37.7749,
"longitude": -122.4194,
"phone_number": "4155551234"
}'Important: You need to create the PostgreSQL database first. The parking_records table will be created automatically when the API starts.
If you already have PostgreSQL installed:
# Create the database
createdb street_sweeping
# Update your .env with the connection string
DATABASE_URL=postgresql://username:password@localhost:5432/street_sweepingWhen you start the API, it will automatically create the parking_records table.
# Start PostgreSQL container
docker run -d \
--name postgres \
-e POSTGRES_USER=sweepuser \
-e POSTGRES_PASSWORD=sweeppass \
-e POSTGRES_DB=street_sweeping \
-p 5432:5432 \
postgres:15
# Update your .env
DATABASE_URL=postgresql://sweepuser:sweeppass@localhost:5432/street_sweepingThe -e POSTGRES_DB=street_sweeping automatically creates the database. The API will create the table on startup.
Create docker-compose.yml:
version: '3.8'
services:
db:
image: postgres:15
environment:
POSTGRES_USER: sweepuser
POSTGRES_PASSWORD: sweeppass
POSTGRES_DB: street_sweeping
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
api:
build: .
ports:
- "8000:8000"
environment:
DATABASE_URL: postgresql://sweepuser:sweeppass@db:5432/street_sweeping
SIMPLEPUSH_KEY: ${SIMPLEPUSH_KEY}
depends_on:
- db
volumes:
postgres_data:Then run:
docker-compose upWhat gets created automatically:
- ✅
parking_recordstable (created by SQLAlchemy on API startup)
What you need to create:
- ❌ PostgreSQL database (must exist before running the API)
- ❌ PostgreSQL server (must be running)
Once running, visit
http://localhost:8000/docsfor interactive API documentation.
Running the reminder script:
docker run --rm --env-file .env --network host street-sweep python send_reminders.pySchedule automated reminders with cron:
# Edit crontab
crontab -e
# Add these lines (adjust timezone as needed)
0 7 * * * cd /path/to/street_sweeping_API && docker run --rm --env-file .env --network host street-sweep python send_reminders.py >> reminder.log 2>&1
0 20 * * * cd /path/to/street_sweeping_API && docker run --rm --env-file .env --network host street-sweep python send_reminders.py >> reminder.log 2>&1street_sweeping_API/
├── main.py # FastAPI application
├── send_reminders.py # Notification script
├── Dockerfile # Container configuration
├── requirements.txt # Python dependencies
└── README.md
- FastAPI: REST API framework
- GeoPandas: Geospatial data processing
- PostgreSQL: Database
- SQLAlchemy: ORM
- Docker: Containerization
- SimplePush: Push notifications
This project uses real-time data from SF OpenData:
Pull requests welcome! Feel free to open an issue if you find bugs or have feature suggestions.
MIT
Built by al-gent - 94gent@gmail.com
Note: This service only works for San Francisco street sweeping schedules.