Skip to content

mbocevski/chargesync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChargeSync EV Charging Station

Presented at PGMeetup Helsinki on January 28, 2026

This document provides instructions on how to run and test the ChargeSync application.

Prerequisites

This project requires the following tools:

  • uv: For managing Python dependencies and running the worker.
  • Docker: For running the PostgreSQL database.

Prepare the Database

Ensure you have Docker installed and running.

  1. Start the PostgreSQL Database:

    docker run --name chargesync-db -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres:latest
  2. Initialize the Database Schema:

    docker exec -i chargesync-db psql -U postgres -d postgres < init.sql
  3. Seeding the Database

    docker exec -i chargesync-db psql -U postgres -d postgres < seed.sql
  4. Start the Hardware Controller Worker:

    uv run worker.py

    The worker will start listening for database notifications from new reservations.

How to Demonstrate

  1. Start a psql prompt:

    docker exec -ti chargesync-db psql -U postgres -d postgres
  2. 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');
  3. Book a charger:

    INSERT INTO reservations (charger_id, user_email, booking_period)
    VALUES (
        3, 
        'helsinki.developer@example.com', 
        tsrange('2026-01-27 17:30:00', '2026-01-27 18:30:00')
    );
  4. Attempt to double-book same charger:

    INSERT INTO reservations (charger_id, user_email, booking_period)
    VALUES (
        3, 
        'helsinki.hacker@example.com', 
        tsrange('2026-01-27 18:05:00', '2026-01-27 18:20:00')
    );
  5. Log usage for a reservation:

    INSERT INTO usage_logs (reservation_id, kwh_used) VALUES (1, 45.50);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published