How tiqi-group/pydase works
Project Type & Purpose
• pydase is a Python library designed to expose a user-defined class’s public attributes via a remote web server using Socket.IO. This service can be accessed via a web browser (auto-generated frontend), Python RPC client, or a RESTful API.
• It leverages the observer pattern to keep service state in sync across clients.
• This is essentially a full-stack (but library-focused) solution where the backend is Python and the frontend is auto-generated and customizable via a separate “frontend” project (using TypeScript/Vite).
File Structure
• Top-level directories:
• docs – Contains comprehensive documentation including dev and user guides.
• frontend – Contains the auto-generated or custom frontend code (React/TypeScript components, configuration via Vite, ESLint, and Prettier).
• src – Contains the main pydase library which is subdivided into:
▪ pydase/client – Code for the Python RPC client (proxy functionality).
▪ pydase/components – Various UI and functional components exposing properties (e.g., number_slider, image, device_connection).
▪ pydase/config – Configuration module that supports environment variable based settings.
▪ pydase/data_service – Implements the DataService abstraction managing service state and properties.
▪ pydase/frontend – Holds assets and an index.html for the web interface.
▪ pydase/observer_pattern – Implements the observer pattern (with observable and observer submodules) for real-time updates.
▪ pydase/server – Contains the server implementation (including web server API endpoints for REST and Socket.IO communication), plus modules for socket setup and API versioning.
▪ pydase/task – Manages task and automated operations (starting/stopping).
▪ pydase/utils – Utility functions (logging, serialization, decorators, helpers).
• Other important files like the CI/CD workflows in .github, configuration files (pyproject.toml, .readthedocs.yaml), and tests that mirror most core components.
Using the README for Additional Insights
• The README clearly describes the three primary usage aspects: defining a DataService (backed by the observer pattern), running the server, and accessing the service via web interface, Python RPC, or RESTful API.
• It emphasizes component auto-generation on the frontend and shows examples of environment-based configuration.
• The documentation also highlights customization options and logging, which are important integration points in the overall design.
a. Main Components to Include:
• DataService (Service Logic Component): The user-defined service class that extends pydase.DataService.
• Server: The Python backend server built in pydase/server. It provides Socket.IO based real-time synchronization and RESTful API endpoints.
• Observer Pattern Module: Depicted as a separate module that handles observability and property updates between the DataService and connected clients.
• Client Proxy: The pydase/client module that dynamically synchronizes with the service.
• Frontend UI: The auto-generated React/TypeScript interface in the “frontend” directory, which interacts with the backend (via Socket.IO and RESTful endpoints).
• Configuration & Environment: The configuration module (and environment variables) that customize behavior of the Server and Frontend.
• Supporting Utilities & Components: Modules for tasks, logging, and serialization that support the core operations.
b. Relationships & Interactions:
• The DataService is the central business logic which has properties exposed to clients.
• The Server acts as the gateway, receiving client requests (via Socket.IO/REST) and updating the DataService.
• The Observer Pattern module watches data changes and pushes real-time updates to all connected clients.
• The Client Proxy uses the pydase/client implementation to mirror the remote service locally.
• The Frontend interacts with the Server to display and allow manipulation of service properties.
• Configuration parameters (possibly coming from environment variables and configuration files) influence server settings, web port, and logging.
c. Architectural Patterns & Design Principles:
• Separation of Concerns: Backend server, service logic, and frontend UI are clearly separated.
• Observer Pattern: Implements reactivity ensuring state consistency across different interfaces.
• Proxy Pattern: The Python RPC client acts as a dynamic proxy to interact seamlessly with the remote service.
• Modular Design: The library and components are organized into separate modules (client, server, data_service, etc.), enabling extensibility.
d. Relevant Technologies & Frameworks:
• Python (core language) with Socket.IO (for real-time web socket communications).
• RESTful API (HTTP endpoints).
• React/TypeScript (in the frontend directory, compiled with Vite).
• Environment variable configuration, logging modules, and task management using decorators.
• Testing framework used in tests/.
Recommended Elements
• From the Frontend UI to the Web Server (indicating REST/Socket.IO communication).
• From the Client Proxy to the Web Server.
• From the Web Server to the DataService.