System Overview
The Conversor de Unidades Remoto implements a three-tier client-server architecture using ZeroC Ice middleware for remote procedure calls (RPC). This design separates concerns and enables distributed computing across network boundaries.Frontend Layer
Vanilla JavaScript single-page application with real-time conversion and theming support
Flask Server
Python web server that serves static files and proxies API requests to the ICE backend
ICE Server
ZeroC Ice RPC server handling business logic for unit conversions
Architecture Diagram
Component Interaction
User Input
User enters a value and selects conversion units in the browser interface. JavaScript captures the input through event listeners.
Business Logic Execution
ICE server executes conversion algorithm and returns result as a double-precision float.
Technology Stack
Backend Technologies
| Component | Technology | Purpose |
|---|---|---|
| RPC Middleware | ZeroC Ice 3.7+ | Remote procedure calls, marshalling, network transport |
| Web Framework | Flask 2.0+ | HTTP server, static file serving, REST API |
| Interface Definition | Slice Language | Language-agnostic RPC contract |
| Code Generation | slice2py | Python stubs/skeletons from Slice |
Frontend Technologies
| Component | Technology | Purpose |
|---|---|---|
| UI Framework | Vanilla JavaScript | DOM manipulation, event handling |
| HTTP Client | Fetch API | Asynchronous API requests |
| Styling | CSS3 Custom Properties | Theming, responsive design |
| Icons | Bootstrap Icons | Visual elements |
Design Patterns
The application demonstrates several key architectural patterns:
- Proxy Pattern: Flask server acts as a proxy between HTTP clients and ICE server
- Servant Pattern: ICE object implementation (servant) handles remote invocations
- Strategy Pattern: Base unit conversion strategy (normalize to base unit, then convert)
- Repository Pattern: Separation of business logic (ICE) from presentation (Flask/JS)
Network Communication
Port Configuration
ICE Server
Port: 10000
Protocol: TCP (ZeroC Ice)
Binding: localhost (default)
Endpoint:
Protocol: TCP (ZeroC Ice)
Binding: localhost (default)
Endpoint:
default -p 10000Flask Server
Port: 5000 (configurable via PORT env var)
Protocol: HTTP
Binding: localhost (configurable via HOST env var)
Routes:
Protocol: HTTP
Binding: localhost (configurable via HOST env var)
Routes:
/, /api/convert, /api/statusConnection String
The Flask server connects to ICE using a stringified proxy reference:- Object Identity:
ConversorUnidades- the name of the remote object - Endpoint:
default -p 10000- TCP on port 10000
Error Handling Strategy
- ICE Layer
- Flask Layer
- Frontend Layer
Slice-defined exceptions for domain errors:Thrown when invalid units are provided.
Data Flow Example
Here’s a complete trace of converting 100°C to Fahrenheit:Deployment Considerations
Environment Variables
Flask server configuration (fromweb_server.py:184-186):
Security Considerations
Current Implementation: Both servers bind to localhost by default, restricting access to local machine.Production Recommendations:
- Add authentication/authorization to Flask API endpoints
- Use ICE SSL endpoints for encrypted communication
- Implement rate limiting on conversion endpoints
- Validate and sanitize all user inputs
- Consider using environment-specific Ice configurations
Performance Characteristics
- Latency: Sub-millisecond for local ICE calls
- Throughput: Limited by Flask’s development server (use Gunicorn/uWSGI for production)
- Concurrency: ICE server handles concurrent requests via thread pool
- Caching: No caching implemented (stateless conversions)
Next Steps
ICE Middleware
Deep dive into ZeroC Ice implementation
Flask Server
Explore REST API and proxy implementation
Frontend
Learn about the JavaScript architecture
Getting Started
Set up the application locally