This guide walks you through running the full CoffePrice stack on your local machine. You will have the Express backend listening on port 8081 and the React frontend on port 5173 in under ten minutes. The ML pipeline runs separately on GitHub Actions and is not required to explore most platform features locally.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.
Prerequisites
Make sure the following are available on your machine before you begin:| Requirement | Minimum version | Notes |
|---|---|---|
| Node.js | 18 LTS | Backend and frontend both require Node 18+ |
| npm | 9+ | Bundled with Node 18 |
| MongoDB | 6+ | A local instance or a free MongoDB Atlas cluster |
| nodemon | any | Installed automatically as a dev dependency |
| Python | 3.9+ | Only needed if you want to run the ML pipeline locally |
Setup Steps
Install backend dependencies
backend/package.json.Configure the backend environment
Copy the example file and fill in your values:The table below documents every variable in
A minimal
backend/.env.example:| Variable | Required | Description |
|---|---|---|
MONGODB_URI | ✅ | Full MongoDB connection string, e.g. mongodb://localhost:27017/coffeeprice or an Atlas SRV URI |
JWT_SECRET | ✅ | Secret used to sign and verify JWT tokens. Use a long random string |
SESSION_SECRET | ✅ | Secret for Express session (used by Passport during OAuth flow) |
FRONTEND_URL | ✅ | Origin the CORS policy allows. Set to http://localhost:5173 locally |
JWT_EXPIRES_IN | ✅ | JWT lifetime, e.g. 1d |
NODE_ENV | ✅ | development locally, production on Railway |
GOOGLE_CLIENT_ID | OAuth | Google OAuth 2.0 client ID from Google Cloud Console |
GOOGLE_CLIENT_SECRET | OAuth | Google OAuth 2.0 client secret |
GOOGLE_CALLBACK_URL | OAuth | Defaults to http://localhost:8081/api/auth/google/callback |
EMAIL_USER | Alerts | Gmail (or SMTP) address used by Nodemailer to send price alerts |
EMAIL_PASS | Alerts | App password for the email account above |
OPENAI_API_KEY | Chatbot | OpenAI API key for the /api/chatbot route |
NEWSAPI_KEY | News | API key for newsapi.org |
GNEWS_API_KEY | News | API key for gnews.io |
THENEWSAPI_TOKEN | News | Token for thenewsapi.com |
NOTICIAS_GENERAR_AL_INICIAR | News | true to seed news immediately on server start. Default: false |
NOTICIAS_POR_CICLO | News | Articles fetched per cron cycle. Default: 3 |
NOTICIAS_DIAS_CONSERVAR | News | Days to keep articles before expiry |
NOTICIAS_MAX_HORAS_FUENTE | News | Maximum age (hours) of source articles to accept. Default: 12 |
NOTICIAS_MIN_ARTICULOS_FUENTE | News | Minimum articles accepted from a single source per run. Default: 1 |
NOTICIAS_MAX_ARTICULOS_FUENTE | News | Maximum articles accepted from a single source per run. Default: 12 |
NOTICIAS_OBJETIVO_CANDIDATAS | News | Target number of candidate articles per cycle. Default: 8 |
NOTICIAS_HORAS_REVISAR_DUPLICADOS | News | Look-back window (hours) for duplicate detection. Default: 48 |
NOTICIAS_MAX_HORAS_SIN_ACTUALIZAR | News | Hours before the news cron forces a refresh. Default: 8 |
NOTICIAS_MIN_ACTIVAS | News | Minimum active articles to keep in the feed. Default: 6 |
NOTICIAS_HORAS_INVENTARIO | News | Inventory window (hours) for article accounting. Default: 72 |
NOTICIAS_MODO_ADAPTACION | News | Adaptation strategy (local or cloud). Default: local |
NOTICIAS_BLOQUEAR_REPETIDAS_HORAS | News | Hours to block a repeated article from re-appearing. Default: 168 |
NOTICIAS_MIN_INTERVALO_REVISION_MS | News | Minimum milliseconds between news review cycles. Default: 300000 (5 min) |
.env for local development looks like this:Start the backend
nodemon watches for file changes and restarts automatically. You should see:esperarMongoDisponible).Install frontend dependencies
Open a new terminal tab, then:This installs React 19, Vite 5, Tailwind CSS 4, react-router-dom 7, Recharts, Mapbox GL, and all other frontend packages.
Configure the frontend environment
Create
frontend/.env (Vite reads .env files in the frontend/ directory):| Variable | Description |
|---|---|
VITE_API_URL | Full base URL of the backend. All Axios requests are prefixed with this value |
VITE_MAPBOX_TOKEN | Public Mapbox access token for the buyer map. Get one free at mapbox.com |
VITE_MAPTILER_KEY | MapTiler API key used as an alternative tile source. Get one at maptiler.com |
The buyer map (
/features/buyer-map) will not render without valid map tokens, but all other platform features work without them.Start the frontend
http://localhost:8081.Health Check
Once the backend is running, verify it is healthy and MongoDB is connected:503 and "status": "degraded". All /api/* routes also return 503 until the database connection is established — this is by design to prevent partial reads during startup.
You can also hit the root endpoint for a quick API map:
ML pipeline is not required locally. The Prophet + XGBoost prediction pipeline runs automatically via GitHub Actions (Monday–Friday at 20:15 UTC). It commits updated prediction artefacts to
backend/datos/ and ml-service-experimental/datos/, which the backend serves through /api/predicciones. If you want stale-but-functional predictions locally, those committed artefacts are already in the repository. To run the pipeline yourself, install dependencies from ml-service-experimental/requirements_hibrido.txt using Python 3.11 and execute python ml-service-experimental/actualizar_todo.py.