How rafacalassara/fluke_dewk_1620a_project works
Project type and purpose
• This is a full-stack Django web application with real-time device communication. It manages Fluke DewK 1620A thermohygrometers, collects streaming data, stores it in SQLite, and exposes both web pages (Django templates) and a REST/WebSocket API for data visualization and control.
Main components
a. Frontend (Browser)
• HTML templates (fluke_data/templates/…)
• CSS (static/css/styles.css)
• JavaScript modules (static/js/*.js) for REST calls and WebSocket real-time updates
b. Backend Application
• Django ASGI/WSGI server (fluke_dewk_1620A_project/asgi.py & wsgi.py)
• URL router (fluke_dewk_1620A_project/urls.py & fluke_data/urls.py & fluke_data/api/urls.py)
• Django apps:
• fluke_data (models, forms, views, templates)
• fluke_data/api (REST views for sensor, certificate, analysis, export)
• Real-time layer:
• consumers.py & routing.py (Django Channels for live data)
• connection_manager.py (manages connections to device streams)
c. Device Integration
• PyVISA interface (thermohygrometer/thermohygrometer.py & fluke_data/visa_communication.py)
• Fluke DewK 1620A Thermohygrometer (Ethernet/USB device)
d. Database
• SQLite (configured in fluke_dewk_1620A_project/settings.py)
e. Deployment & Containerization
• Dockerfile & docker-compose.yml defining application container
• UV package manager for virtual env (pyproject.toml, uv.lock)
Relationships and data flows
• The user’s browser sends HTTP requests (page loads, REST calls) to the Django server.
• JS on the client subscribes to WebSocket channels for real-time updates.
• Django Channels routes WebSocket events to consumers, which push data to clients.
• Consumers and Django views both invoke connection_manager → visa_communication → thermohygrometer driver to poll or push commands to the physical device.
• Device readings flow back through the driver into Python, then to:
• Django Channels (live stream)
• Django ORM (persist in SQLite)
• REST endpoints for on-demand queries or export
• Admin/users interact via Django’s standard WSGI routes for CRUD (models, forms, templates).
Architectural patterns & design principles
• MVC/MVT: Models (fluke_data/models.py) → Views (Django views & API views) → Templates (HTML)
• Layered Architecture:
• Presentation Layer (templates + JS)
• Application Layer (Django views, REST API)
• Real-time Layer (Channels consumers)
• Domain Layer (models, business logic in crews, analysis tools)
• Infrastructure Layer (PyVISA driver, SQLite DB)
• Modularization by feature: fluke_data/api, fluke_data/crews, fluke_data/templates/fluke_data/...
• Separation of concerns: device driver separate from web logic.