dlbGatekeeper/README.md

135 lines
2.9 KiB
Markdown

# 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:
```bash
git clone https://git.athenanetworks.com.au/josh/dlbGatekeeper.git
```
2. Install backend dependencies:
```bash
cd backend
pip install -r requirements.txt
```
3. Install frontend dependencies:
```bash
cd frontend
npm install
```
## Development
1. Start the backend:
```bash
cd backend
python main.py
```
2. Start the frontend development server:
```bash
cd frontend
npm run dev
```
## Deployment
Use the deployment script:
```bash
./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.