A comprehensive hydroponics nutrient solution calculator with an integrated SOCKS5 proxy over TLS WebSockets for secure remote access.
NSCalc is a dual-purpose application that serves as:
- Hydroponics Calculator: A web-based tool for calculating nutrient solutions, EC/TDS values, and managing hydroponic growing parameters
- Secure Proxy: A SOCKS5 proxy server tunneled over TLS WebSockets for secure remote access and traffic routing
- Backend: C++ server using Boost.Beast for HTTP/WebSocket handling and NPRPC for RPC communication
- Frontend: Modern web client built with React and Svelte
- Proxy Client: Cross-platform Qt application for SOCKS5 proxy functionality
- Database: SQLite for data persistence
- Security: TLS encryption with self-signed certificate support for development
- ✅ Nutrient solution calculations
- ✅ EC/TDS value management
- ✅ Multi-user support with authentication
- ✅ Real-time chat functionality
- ✅ Solution history and data persistence
- ✅ Web-based responsive UI
- ✅ SOCKS5 proxy over TLS WebSockets
- ✅ Cross-platform Qt client (Windows/Linux/macOS)
- ✅ Secure tunnel establishment
- ✅ Session management and callbacks
- ✅ Bidirectional data forwarding
- CMake 3.20+
- C++20 compatible compiler (GCC 11+, Clang 13+, MSVC 2022)
- Node.js 16+ (for client build)
- Qt 6+ (for proxy client)
- OpenSSL
- Boost 1.83+
# Clone and build
git clone <repository-url>
cd nscalc
# Configure and build
cmake -B .build_local -S . -DCMAKE_BUILD_TYPE=Debug
cmake --build .build_local
# Or use the convenience script
./01_build_app.sh
# Start the hydroponics calculator server
./run.sh
# For debugging
./run.sh debug
The server will start on https://archvm:8080
(or your configured hostname).
# Build proxy client
cmake --build .build_local --target=proxy_client
# Run proxy client (connects to server and starts SOCKS5 on port 1080)
./.build_local/debug/proxy_client
nscalc/
├── server/ # C++ backend server
│ ├── src/
│ │ ├── main.cpp # Main server entry point
│ │ ├── services/ # Business logic and services
│ │ └── util/ # Utilities and thread pool
├── client/ # React/Svelte frontend
│ ├── src/
│ │ ├── App.svelte # Main application component
│ │ ├── calculation/ # Calculation logic
│ │ ├── gui/ # UI components
│ │ └── rpc/ # RPC client code
├── proxy_client/ # Qt SOCKS5 proxy client
│ └── src/
│ ├── main.cpp # Proxy client entry
│ ├── socks5.cpp # SOCKS5 implementation
│ └── MainWindow.* # Qt GUI (if applicable)
├── external/npsystem/ # NPRPC framework
├── idl/ # Interface definitions
├── docs/ # Documentation
├── certs/ # SSL certificates
└── sample_data/ # Sample database
The server accepts several command-line options:
--hostname <host> # Server hostname (default: localhost)
--port <port> # Server port (default: 8080)
--http-dir <path> # Static files directory
--data-dir <path> # Database directory
--use-ssl <0|1> # Enable SSL/TLS
--public-key <path> # SSL certificate file
--private-key <path> # SSL private key file
--dh-params <path> # Diffie-Hellman parameters
For development with self-signed certificates:
- Linux/macOS: Certificates are in
certs/
directory - Windows Testing: See Windows Certificate Setup Guide
The proxy client connects to the NSCalc server and establishes a SOCKS5 proxy on local port 1080. Configure your applications to use:
- Proxy Type: SOCKS5
- Host: 127.0.0.1
- Port: 1080
The application uses NPRPC (Nikita's Protocol RPC) for communication between client and server. Interface definitions are in the idl/
directory:
nscalc.npidl
: Main calculator interfacesproxy.npidl
: Proxy service interfaces
# Configure with debug symbols
cmake -B .build_local -S . -DCMAKE_BUILD_TYPE=Debug -DOPT_NPRPC_SKIP_TESTS=ON
# Build specific targets
cmake --build .build_local --target=nscalc
cmake --build .build_local --target=proxy_client
cd client
npm install
npm run dev # Development server
npm run build # Production build
# Test SOCKS5 functionality
python test_socks5.py
# HTTP stress testing
cd server
python http_stress_test.py
The project includes Docker support for containerized deployment:
# Build development image
./00_build_docker_dev.sh
# Build application
./01_build_app.sh
# Package runtime
./02_pack_runtime.sh
# Deploy
./03_deploy.sh
- TLS Encryption: All communications encrypted with TLS 1.2+
- Authentication: User authentication for calculator access
- Proxy Security: SOCKS5 proxy tunneled over secure WebSockets
- Session Management: Secure session handling and timeouts
- Chrome/Chromium 90+
- Firefox 88+
- Safari 14+
- Edge 90+
- Certificate Warnings: Install self-signed certificate in browser (see Windows setup guide)
- Build Failures: Ensure all dependencies are installed and C++20 support is available
- Proxy Connection Issues: Check firewall settings and ensure server is running with SSL enabled
Run the server in debug mode for detailed logging:
./run.sh debug
- Server logs are output to console
- Client logs available in browser developer tools
- Proxy client logs to console/system tray
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the terms specified in the LICENSE file.
The project uses a custom RPC framework (NPRPC) that provides:
- High-performance binary protocol
- WebSocket transport
- Automatic client/server stub generation
- Thread-safe operations
- HTTP/HTTPS: Boost.Beast for web server functionality
- WebSockets: Secure WebSocket connections for RPC
- SOCKS5: RFC 1928 compliant SOCKS5 implementation
- SSL/TLS: OpenSSL for encryption
- Engine: SQLite 3
- Schema: See
database/create.sql
- Sample Data: Provided in
sample_data/
- Concurrent Users: Supports multiple simultaneous users
- Memory Usage: Optimized for low memory footprint
- CPU Usage: Multi-threaded design for efficient CPU utilization
- Network: Optimized binary protocol reduces bandwidth usage
Project Status: Active Development
Last Updated: June 2025
Author: Nikita (nikitapnn1@gmail.com)