This guide covers how to deploy the Web Application to the cloud and how to package the Desktop Application as an executable file.
Before deploying, you must update the API URLs so your apps know where to send data (instead of localhost).
The code is already set up to look for an environment variable.
- Locally: It uses
http://localhost:8000/api/by default. - In Production (Render/Netlify): Add an Environment Variable named
VITE_API_URLwith your backend URL (e.g.,https://your-app.onrender.com/api/). - Alternatively, modify
frontend-web/src/api.jsmanually.
- Open
frontend-desktop/main.py. - Locate line 12:
API_BASE_URL. - Uncomment the Production URL and comment out the Localhost URL:
API_BASE_URL = "https://your-app.onrender.com/api/" # API_BASE_URL = "http://localhost:8000/api/"
- Then build the executable (Part 4).
-
Repo: Push your code to GitHub.
-
Service: Create a new Web Service on Render.
-
Settings:
- Root Directory:
backend(Important!) - Build Command:
pip install -r requirements.txt && python manage.py migrate && python create_superuser.py - Start Command:
gunicorn config.wsgi:application
- Root Directory:
-
Environment Variables:
PYTHON_VERSION:3.13.0SECRET_KEY: (Random String)DEBUG:FalseADMIN_USERNAME:adminADMIN_PASSWORD:yoursecurepassword
-
Important: Update
backend/config/settings.pywith your Vercel URL.- Once you deploy the frontend (Part 3), copy the URL (e.g.,
https://my-app.vercel.app). - Add it to
CORS_ALLOWED_ORIGINSinsettings.py. - Redeploy the Backend.
- Once you deploy the frontend (Part 3), copy the URL (e.g.,
- Repo: Push code to GitHub.
- Service: Import project on Vercel.
- Settings:
- Root Directory:
frontend-web - Framework Preset: Vite
- Build Command:
npm run build - Output Directory:
dist
- Root Directory:
- Environment Variables:
VITE_API_URL:https://your-render-backend-name.onrender.com/api/(Note: Must end with/)
We will use PyInstaller to convert the Python scripts into a standalone .exe file that can run on any Windows machine without needing Python installed.
Warning: Ensure you are in your virtual environment.
pip install pyinstallerRun the following command from the root directory (ChemicalEquipmentVisualizer):
pyinstaller --noconfirm --onefile --windowed --name "ChemEquipVisualizer" --add-data "backend/db.sqlite3;." --hidden-import "matplotlib.backends.backend_qt5agg" frontend-desktop/main.py--onefile: Packages everything into a single.exe.--windowed: Hides the console window (no black box popping up).--add-data: Includes the database file inside the exe (Note: Data changes inside the exe won't persist after restart. For data persistence in an exe, you usually keep the DB outside).--hidden-import: Ensures hidden dependencies like Matplotlib's backend are found.
The executable will be in the dist/ folder.
- Locate
dist/ChemEquipVisualizer.exe. - Double-click to run.
Free tier services (Render/Heroku) often "sleep" after 15 minutes of inactivity, causing a 30-50 second delay on the next request.
Strategy: Use a Cron Job Pinger
I added a special "Ping" endpoint to your API: GET /api/ping/.
- Sign up for a free service like Cron-job.org or UptimeRobot.
- Create a new Monitor/Job.
- URL:
https://your-app-name.onrender.com/api/ping/ - Interval: Every 14 minutes.
- Method: HTTP GET.
This will send a tiny request to your server 24/7, preventing it from ever going to sleep!