This guide walks you through a production deployment of CoffePrice. The backend runs as a Railway service, the frontend is served globally from Netlify’s CDN, and the ML prediction pipeline runs on a GitHub Actions schedule. Follow the sections in order — the backend must be deployed first so you have its public URL ready for the frontend environment variables.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/JaiderT/CoffeePrice/llms.txt
Use this file to discover all available pages before exploring further.
Architecture at a Glance
Backend on Railway
Create a Railway project from the repository
- Go to railway.app and click New Project.
- Choose Deploy from GitHub repo and authorize Railway to access your fork or the
JaiderT/CoffeePricerepository. - Railway will detect the monorepo structure. When prompted, select Add a service and point it to the
backend/subdirectory.
Set the start command and root directory
In the service settings (Settings → Build & Deploy):
Railway will run
| Setting | Value |
|---|---|
| Root directory | backend |
| Start command | npm start |
node server.js (the start script in backend/package.json). It will also inject a PORT environment variable automatically — the server falls back to 8081 if PORT is not set.Set required environment variables
Navigate to Variables in your Railway service and add at minimum:
| Variable | Production value |
|---|---|
MONGODB_URI | Your MongoDB Atlas SRV connection string |
JWT_SECRET | A long, random secret (use openssl rand -base64 48) |
SESSION_SECRET | A separate long random secret for Passport sessions |
FRONTEND_URL | https://YOUR-SITE.netlify.app (fill in after Netlify deploy) |
NODE_ENV | production |
JWT_EXPIRES_IN | 1d (or your preferred duration) |
Set optional environment variables for platform features
Add these variables to unlock the corresponding features:
See the Quickstart page for the full list of
| Variable | Feature | Notes |
|---|---|---|
GOOGLE_CLIENT_ID | Google OAuth login | From Google Cloud Console |
GOOGLE_CLIENT_SECRET | Google OAuth login | From Google Cloud Console |
GOOGLE_CALLBACK_URL | Google OAuth login | https://YOUR-BACKEND.up.railway.app/api/auth/google/callback |
EMAIL_USER | Price alert emails | Gmail address or SMTP user |
EMAIL_PASS | Price alert emails | App password for the account |
OPENAI_API_KEY | AI chatbot (/api/chatbot) | OpenAI platform key |
NEWSAPI_KEY | News feed | newsapi.org key |
GNEWS_API_KEY | News feed | gnews.io key |
THENEWSAPI_TOKEN | News feed | thenewsapi.com token |
NOTICIAS_GENERAR_AL_INICIAR | News feed | Set true to seed articles on first boot |
NOTICIAS_* tuning variables.Frontend on Netlify
Import the repository and configure the build
- Go to app.netlify.com and click Add new site → Import an existing project.
- Authorize Netlify to access the repository and select it.
- Set the build configuration:
| Setting | Value |
|---|---|
| Base directory | frontend |
| Build command | npm run build |
| Publish directory | frontend/dist |
netlify.toml from the repository root — it already contains these exact values:Set frontend environment variables
In Site configuration → Environment variables, add:
Vite embeds these values at build time. After adding or changing them you must trigger a new deploy for the changes to take effect.
| Variable | Value |
|---|---|
VITE_API_URL | https://YOUR-BACKEND.up.railway.app (the Railway URL from above) |
VITE_MAPBOX_TOKEN | Your Mapbox public access token |
VITE_MAPTILER_KEY | Your MapTiler API key |
SPA routing — already handled by netlify.toml
CoffePrice is a React single-page application. Client-side routes such as No additional configuration is needed. Netlify applies this rule automatically on every deploy.
/login, /precios, and /completar-perfil must return index.html when reloaded directly. The netlify.toml in the repository root already includes the required catch-all redirect:Google OAuth Configuration
If you enabled Google sign-in by settingGOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET, you must update the authorized origins and redirect URIs in Google Cloud Console to match your production domains.
- Open console.cloud.google.com and navigate to APIs & Services → Credentials.
- Click your OAuth 2.0 Client ID.
- Under Authorized JavaScript origins, add:
https://YOUR-SITE.netlify.apphttps://YOUR-BACKEND.up.railway.app
- Under Authorized redirect URIs, add:
https://YOUR-BACKEND.up.railway.app/api/auth/google/callback
- Click Save and wait a few minutes for the change to propagate.
- Make sure
GOOGLE_CALLBACK_URLin your Railway environment variables matches the redirect URI exactly.
ML Pipeline Automation
The price prediction pipeline is driven by a GitHub Actions workflow at.github/workflows/actualizar-predicciones.yml. No additional hosting or server is required.
Schedule: The workflow runs automatically Monday through Friday at 20:15 UTC (3:15 pm Colombia time, UTC−5).
What it does:
-
Checks out the repository with full history (
fetch-depth: 0). -
Sets up Python 3.11 and installs dependencies from
ml-service-experimental/requirements_hibrido.txt. -
Runs
python ml-service-experimental/actualizar_todo.py, which fetches the latest FNC price data, retrains the Prophet + XGBoost hybrid model, and generates the next business-day prediction. -
Commits the updated artefacts back to the repository:
backend/datos/— prediction JSON files served by/api/prediccionesml-service-experimental/datos/— raw data snapshotsml-service-experimental/modelos/metricas_fnc_hibrido.json— model metrics
- Pushes the commit, which triggers Railway and Netlify auto-deploys if connected.
- The repository must be connected to Railway and Netlify with auto-deploy on push enabled.
- GitHub Actions must be enabled for the repository (it is by default for public repos).
- To change the run time, update the
cronexpression in the workflow file (values are in UTC).
Verification
After both services are live, run these checks: Backend health check:"status": "degraded", MongoDB Atlas has not yet accepted the connection. Double-check MONGODB_URI and ensure your Atlas cluster’s Network Access allows connections from 0.0.0.0/0 (all IPs) since Railway uses dynamic outbound IPs.
Backend root:
- Open
https://YOUR-SITE.netlify.app— the home page should load. - Navigate to
/loginthen press F5 to reload — the page should still render (SPA redirect working). - Navigate to
/precios— the price chart should appear and fetch data from Railway. - Try Google login if OAuth is configured.
Recommended Deployment Order
- Deploy the backend to Railway first and wait for it to be healthy (
/healthzreturnsok). - Copy the Railway public URL.
- Set
VITE_API_URLin Netlify environment variables to that URL. - Deploy the frontend to Netlify.
- Go back to Railway and confirm
FRONTEND_URLis set to the live Netlify domain. - If using Google OAuth, update the authorized URIs in Google Cloud Console.
- Enable auto-deploy on push in both Railway and Netlify so that the nightly ML pipeline commit triggers a re-deploy automatically.