Railway is the recommended hosting platform for MELIKA. Its project model maps cleanly to the monorepo’s three concerns — a Node.js/Express API, a React/Vite static site, and a managed PostgreSQL database — each running as an isolated service with its own environment, resource limits, and URL. This guide walks through every step from creating the Railway project to verifying a live health-check endpoint, including the critical ordering of environment variables that Vite requires at build time.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Imjuanisss/proyecto-melika/llms.txt
Use this file to discover all available pages before exploring further.
Architecture overview
MELIKA runs as three Railway services within a single project. Keeping them separate gives you independent deploy pipelines, isolated restart behaviour, and per-service environment variable scopes.server
Node.js ≥ 20 + Express 5. Reads
DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD, JWT_SECRET, FRONTEND_URL, and the Gmail OAuth2 variables. Start command: node src/server.js.client
React 19 + Vite 8 static build. Needs
VITE_API_URL set before the build runs. Served with the serve package. Start command: npm start.postgres
Railway-managed PostgreSQL. Exposes
PGHOST, PGPORT, PGUSER, PGPASSWORD, and PGDATABASE — wire these into the server service as DB_* variables using Railway variable references.Deployment steps
Create a Railway project
Log in to railway.app and click New Project. Choose Empty project — you will add each service manually so you have full control over the configuration order.Give the project a name (e.g.
melika) and note the project URL. All three services will live under this project.Add the PostgreSQL database service
Inside the project, click New → Database → Add PostgreSQL. Railway provisions a managed Postgres instance and immediately makes the following variables available:
Railway exposes individual
PG* variables for the Postgres service. You will wire these into the server service as DB_HOST, DB_PORT, DB_NAME, DB_USER, and DB_PASSWORD using Railway variable references in the next step.Deploy the backend service
Click New → GitHub Repo and select your MELIKA repository. Railway will detect the monorepo. Configure the service as follows:
Click Deploy. Watch the build logs — the server starts when you see output like:
- Service settings
- Environment variables
| Setting | Value |
|---|---|
| Root directory | /server |
| Build command | npm install |
| Start command | node src/server.js |
| Service name | server |
Apply the database schema
The schema must be applied once to the Railway Postgres instance before the API can serve requests.After the command completes, verify the tables exist:
- Railway shell (recommended)
- Local psql with Railway URL
Open the Railway’s internal network gives the shell direct access to Postgres via the injected
server service in Railway, click Shell, and run:DB_* variables.Create the first admin user
Still in the The script does not prompt for input — admin credentials are hardcoded inside the script. On success it prints the email, role, and initial plaintext password. Change the password immediately after the first login.
server service Shell on Railway, run the admin-creation script:This step must be performed after the schema is applied. The script will fail with a relation-not-found error if the
usuarios table does not exist yet. The shell opens at /server (the service root directory), so the path is scripts/crearAdmin.js, not server/scripts/crearAdmin.js.Deploy the frontend service
Back in the Railway project, click New → GitHub Repo → same MELIKA repository. Configure the service:
| Setting | Value |
|---|---|
| Root directory | /client |
| Build command | npm run build |
| Start command | npm start |
| Service name | client |
Set VITE_API_URL on the frontend service
In the Copy the exact public URL of your
client service Settings → Variables, add:server service from its Settings → Networking section (no trailing slash).Now trigger the build by clicking Deploy or pushing a commit. Vite will embed VITE_API_URL during the build step.client/railway.json
The/client directory includes a railway.json configuration file that Railway reads automatically when deploying the client service. It codifies the builder, build command, start command, and restart policy so you do not need to re-enter them manually in the dashboard. If you need to change build behaviour, edit client/railway.json rather than the dashboard setting so the configuration stays in version control.
client/railway.json
Verifying the deployment
Once all three services are running, confirm the backend is healthy with a GET request to the root endpoint:Environment variable reference summary
- server service
- client service
Common issues
CORS errors in the browser console
CORS errors in the browser console
The most common cause is a mismatch between
FRONTEND_URL on the server and the actual client URL. Check for a trailing slash, an http:// vs https:// difference, or a stale Railway-generated subdomain. Copy the URL directly from the Railway dashboard and update the variable, then redeploy the server service.API calls return 'Failed to fetch' or network errors
API calls return 'Failed to fetch' or network errors
This usually means
VITE_API_URL was not set when the frontend was built. The compiled bundle is calling undefined as the base URL. Set the correct VITE_API_URL value and trigger a fresh build by redeploying the client service.Database connection refused on first deploy
Database connection refused on first deploy
Make sure all five
DB_* variables are set on the server service and point to the Railway Postgres instance. Use Railway variable references (${{Postgres.PGHOST}} etc.) to ensure the values stay in sync if the Postgres service is reprovisioned.Admin script fails with 'relation does not exist'
Admin script fails with 'relation does not exist'
The schema has not been applied yet. Run the
psql command with melika_db.sql in the Railway shell first, then retry node scripts/crearAdmin.js.