Eco-It’s production architecture separates the backend from the frontend across two purpose-built hosting platforms. The Node.js/Express API (including Socket.IO, MongoDB via Mongoose, and the OpenRouter-powered EcoBot) runs on Railway, which handles automatic HTTPS, zero-configuration Node.js detection, and theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/vanegasjoseignacio2-cyber/Eco-It/llms.txt
Use this file to discover all available pages before exploring further.
PORT injection that the server already reads from process.env. The React SPA is deployed to Netlify — as confirmed by frontend/.env.production pointing to a *.up.railway.app backend and the frontend/public/_redirects file that enables client-side SPA routing. The sections below walk through each deployment target in order, followed by the external service setup required before either service can fully start.
External services setup
Before deploying the application itself, provision the three external services that both environments depend on.MongoDB Atlas
Create a free cluster
Sign in to MongoDB Atlas and create a new M0 (free-tier) shared cluster. Choose a region close to your Railway deployment for lower latency.
Create a database user
In Database Access, add a new database user with a strong password. Grant the Atlas admin or readWriteAnyDatabase built-in role.
Whitelist Railway's egress IPs
In Network Access, add the IP addresses used by your Railway service. During initial setup you may use
0.0.0.0/0 (allow all), but restrict this to Railway’s static IP ranges once your service is stable.Cloudinary
Create a free account
Register at cloudinary.com. The free tier provides 25 GB of storage and 25 GB of monthly bandwidth, which is sufficient for development and moderate production usage.
Google OAuth
Create OAuth 2.0 credentials
In the Google Cloud Console, navigate to APIs & Services → Credentials → Create Credentials → OAuth 2.0 Client ID. Choose Web application as the application type.
Add the authorized redirect URI
Under Authorized redirect URIs, add the Railway callback URL:Replace
your-backend with your actual Railway service subdomain. This URI must match exactly what passport-google-oauth20 sends during the OAuth handshake.Backend deployment (Railway)
Railway detects Node.js projects automatically and runs thestart script from backend/package.json (node index.js). No Dockerfile or Procfile is required.
Create a new Railway project
Log in to Railway and click New Project → Deploy from GitHub repo. Authorize Railway to access your repository and select the Eco-It repo.
Set the root directory
In your service settings, set Root Directory to
backend/. Railway will then use backend/package.json to install dependencies and determine the start command.Configure the start command
Railway auto-detects the
start script, so no manual override is usually needed. If you need to set it explicitly, use:Add environment variables
Open Variables in the Railway service panel and add every backend variable. Use the values from your MongoDB Atlas, Cloudinary, Google Cloud Console, and OpenRouter setups:Railway injects
PORT automatically — do not set it manually.The CORS
origin allowlist in backend/index.js is hardcoded to include http://localhost:5173, http://localhost:5174, http://localhost:5175, and https://eco-it.netlify.app. The same origins are mirrored in the Socket.IO server configuration. If you deploy the frontend to a different domain, you must update both the cors() middleware and the new Server(httpServer, { cors: { origin: [...] } }) call in backend/index.js to include your actual production URL, then redeploy the backend.Frontend deployment (Netlify)
The frontend is a Vite-built React SPA. Netlify serves the static output fromfrontend/dist/ and uses the frontend/public/_redirects file to handle client-side navigation.
Connect the repo to Netlify
Log in to Netlify and click Add new site → Import an existing project. Authorize Netlify to access your GitHub account and select the Eco-It repository.
Set the build command
In the build settings, enter the build command. You can use either of the following (they are equivalent because the root Or the root-level shortcut:
package.json delegates to the frontend workspace):Set the publish directory
Set the Publish directory to:Vite outputs the production build to
frontend/dist by default.Add environment variables
In Site configuration → Environment variables, add the two frontend variables. Use the Railway URL you obtained after deploying the backend:These are injected at build time by Vite — they are baked into the static bundle and are not secret. Do not place sensitive credentials here.
Verify SPA routing
Eco-It ships with Netlify copies this file into
frontend/public/_redirects containing:frontend/dist/ during the build and uses it to serve index.html for every route, enabling React Router to handle client-side navigation without 404 errors on page refresh or direct URL access. No manual configuration is needed — the file is already in place.Production environment variable summary
For quick reference, here is a complete production.env for the backend. Place this in backend/.env for local production simulation, or enter each key-value pair directly into Railway’s Variables panel.
The CORS configuration in
backend/index.js is applied identically to both the Express HTTP middleware and the Socket.IO server. Both use the same hardcoded origin array: ['http://localhost:5173', 'http://localhost:5174', 'http://localhost:5175', 'https://eco-it.netlify.app']. If you fork Eco-It and deploy the frontend to a custom domain, you must update the origin array in both places within index.js and redeploy the backend before the frontend will be able to make credentialed API requests or establish WebSocket connections.