Presented at PGMeetup Helsinki on January 28, 2026
- Meetup Event: https://www.meetup.com/helsinki-postgresql-meetup/events/312404579/
- Slides: https://docs.google.com/presentation/d/1uW7cfhSDwW7BLjbrP_by7eFtcU_5sFm4GDUK98tpUVE/edit?slide=id.p1#slide=id.p1
This document provides instructions on how to run and test the ChargeSync application.
This project requires the following tools:
- uv: For managing Python dependencies and running the worker.
- Docker: For running the PostgreSQL database.
Ensure you have Docker installed and running.
-
Start the PostgreSQL Database:
docker run --name chargesync-db -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres:latest
-
Initialize the Database Schema:
docker exec -i chargesync-db psql -U postgres -d postgres < init.sql
-
Seeding the Database
docker exec -i chargesync-db psql -U postgres -d postgres < seed.sql
-
Start the Hardware Controller Worker:
uv run worker.py
The worker will start listening for database notifications from new reservations.
-
Start a psql prompt:
docker exec -ti chargesync-db psql -U postgres -d postgres -
Search for a charger:
-- Show the auto generated search vector SELECT name, search_vector FROM stations WHERE name = 'ChargePoint A';
-- Search for stations with "coffee" SELECT name, location_name, amenities FROM stations WHERE search_vector @@ to_tsquery('english', 'coffee'); -- Search for "wifi" AND "food" using logic operators SELECT id, name, amenities FROM stations WHERE search_vector @@ to_tsquery('english', 'wifi & food');
-
Book a charger:
INSERT INTO reservations (charger_id, user_email, booking_period) VALUES ( 3, '[email protected]', tsrange('2026-01-27 17:30:00', '2026-01-27 18:30:00') );
-
Attempt to double-book same charger:
INSERT INTO reservations (charger_id, user_email, booking_period) VALUES ( 3, '[email protected]', tsrange('2026-01-27 18:05:00', '2026-01-27 18:20:00') );
-
Log usage for a reservation:
INSERT INTO usage_logs (reservation_id, kwh_used) VALUES (1, 45.50);