Go to file
Josh Finlay a3ecf3a606 fix: implement proper database connection context manager
- Created DBConnection class to manage database connections
- Each connection is now properly created and closed
- Removed global connection pool to fix thread issues
2025-01-08 08:48:38 +10:00
backend fix: implement proper database connection context manager 2025-01-08 08:48:38 +10:00
frontend fix: database connection handling 2025-01-08 08:36:50 +10:00
.gitignore UI/UX Improvements and Infrastructure Updates 2025-01-07 15:33:31 +10:00
README.md Updated README with comprehensive API documentation and latest features 2025-01-07 15:35:56 +10:00
deploy.sh Add MQTT integration with Home Assistant and update deployment script 2025-01-08 07:39:07 +10:00
requirements.txt Add MQTT integration with Home Assistant and update deployment script 2025-01-08 07:39:07 +10:00

README.md

DLB Gate Keeper

A modern web application for controlling the DLB gate, featuring a beautiful macOS-inspired UI and robust backend.

Features

  • Single-button gate control with automatic state detection
  • Real-time gate status monitoring
  • Event logging for all gate operations
  • Configurable settings for gate timing
  • Mobile-responsive design with glass morphism effects
  • Modern macOS-inspired user interface

Technical Stack

Frontend

  • React with TypeScript
  • Tailwind CSS for styling
  • Modern glass morphism design
  • Mobile-first responsive layout

Backend

  • FastAPI (Python)
  • SQLite for data persistence
  • RPi.GPIO for hardware control
  • Async operations for improved performance

API Documentation

Endpoints

Gate Control

  • POST /api/trigger
    • Toggles the gate state (open/close)
    • Response: { "success": boolean, "currentStatus": boolean }

Gate Status

  • GET /api/status
    • Returns current gate status
    • Response: { "isOpen": boolean, "lastChanged": string }

Event History

  • GET /api/events
    • Returns gate operation history
    • Query Parameters:
      • limit: number (default: 10)
    • Response: Array of { "id": number, "timestamp": string, "action": string, "source": string, "success": boolean }

Settings

  • GET /api/settings
    • Returns current settings
    • Response: { "maxOpenTimeSeconds": string, "triggerDuration": string }
  • POST /api/settings
    • Updates gate settings
    • Body: { "maxOpenTimeSeconds": string, "triggerDuration": string }
    • Response: { "success": boolean }

Installation

  1. Clone the repository:

    git clone https://git.athenanetworks.com.au/josh/dlbGatekeeper.git
    
  2. Install backend dependencies:

    cd backend
    pip install -r requirements.txt
    
  3. Install frontend dependencies:

    cd frontend
    npm install
    

Development

  1. Start the backend:

    cd backend
    python main.py
    
  2. Start the frontend development server:

    cd frontend
    npm run dev
    

Deployment

Use the deployment script:

./deploy.sh

This will:

  1. Build the frontend
  2. Package all files
  3. Deploy to the Raspberry Pi
  4. Restart the service

Configuration

GPIO Pins

  • RELAY_1_PIN: 22 (default)
  • RELAY_2_PIN: 5 (default)
  • STATUS_PIN: 4 (default)

Timing Settings

  • maxOpenTimeSeconds: Maximum time the gate stays open (default: 300 seconds)
  • triggerDuration: Duration of the trigger pulse in milliseconds (default: 500ms)

Status Indicators

  • Gate Open: Status LED shows HIGH (3.3V)
  • Gate Closed: Status LED shows LOW (0V)

Security

  • No authentication required (internal network only)
  • CORS enabled for development
  • Rate limiting on API endpoints

Contributing

  1. Create a feature branch
  2. Make your changes
  3. Submit a pull request

License

Copyright 2025 DLB. All rights reserved.