Ergono-Backend serves as the central orchestration unit for the Real-Time Data Acquisition System.
Written in Python, this server manages high-concurrency WebSocket connections to facilitate communication between the mobile sensor nodes (ErgonoApp) and the storage layer. It utilizes an asynchronous architecture (asyncio) to handle data ingestion, command synchronization, and high-performance persistence into TimescaleDB via asyncpg.
- Asynchronous WebSocket Server: Manages real-time, bi-directional communication using the
websocketslibrary. - High-Performance Database Access: Uses
asyncpgfor non-blocking, high-speed data insertion into TimescaleDB/PostgreSQL. - Real-Time Data Processing: Handles incoming sensor streams and JSON payloads efficiently using Python's native
asyncioloop. - Session Orchestration: Broadcasts global control commands (Start/Stop) to synchronize data collection across connected devices.
- Simulation Capabilities: Includes logic for data simulation and testing environments.
This project is built on a fully asynchronous Python stack to ensure low latency and high scalability.
| Category | Technology |
|---|---|
| Core Architecture | asyncio |
| Communication | websockets |
| Database Driver | asyncpg (PostgreSQL Client) |
| Data Handling | json, io |
| Utilities | datetime, random |
- Python 3.10 or higher.
- A running instance of TimescaleDB (or PostgreSQL).
- Git.
-
Clone the repository:
git clone https://github.com/cessdel/backend_ergonoapp cd backend_ergonoapp -
Create a Virtual Environment:
python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate
-
Install dependencies: Since
asyncio,json, andrandomare part of the Python standard library, you only need to install the external packages:pip install websockets asyncpg
(Or install via requirements.txt if available)
Ensure your database credentials are correct. You can configure the connection strings directly in the main script or via environment variables, depending on your setup.
- Database: PostgreSQL/TimescaleDB
- Driver: asyncpg
- Port: Default WebSocket port (e.g., 8765)
To start the WebSocket server and begin listening for connections:
python app.py