RYDAAA... INSTALLATION GUIDE
==============================

WHAT YOU GET
------------
  frontend/   -> Upload to Hostinger public_html  (the website)
  api/        -> Deploy to Railway.app            (the backend server)
  INSTALL.txt -> This file

==============================
STEP 1 - UPLOAD WEBSITE TO HOSTINGER (2 minutes)
==============================

1. Log in to Hostinger cPanel -> File Manager
2. Open public_html folder
3. Upload THIS zip file -> click Extract
4. Make sure index.html and .htaccess are directly inside public_html/
   (not inside a sub-folder called "frontend" or anything else)

Your website is now live at https://yourdomain.com
Data will not load yet - complete Steps 2 and 3 first.

==============================
STEP 2 - DEPLOY API SERVER FREE ON RAILWAY (5 minutes)
==============================

Railway gives you a free Node.js server + free PostgreSQL database.

1. Sign up free at: https://railway.app  (use GitHub login)

2. Create a free GitHub account at: https://github.com  (if you don't have one)

3. On GitHub create a new repository:
   github.com -> click + at top right -> New repository
   Name it: rydaaa-api -> click Create repository

4. Upload the contents of the api/ folder to that GitHub repo:
   Open the repo -> click "uploading an existing file"
   Drag ALL files from the api/ folder -> click Commit changes

5. Back on Railway:
   New Project -> Deploy from GitHub repo -> select rydaaa-api
   Wait about 1 minute for it to deploy.

6. Add a free PostgreSQL database:
   Inside your Railway project -> click + New -> Database -> Add PostgreSQL
   Click the PostgreSQL service -> Variables tab -> copy the DATABASE_URL value

7. Set environment variables on your API service:
   Click your API service -> Variables tab -> + New Variable
   Add:  DATABASE_URL  ->  paste the value copied from step 6
   Add:  NODE_ENV      ->  production

8. Get your API URL:
   Click your API service -> Settings -> Networking -> Generate Domain
   Copy the URL shown (example: https://rydaaa-api-production.up.railway.app)

9. Set up the database tables (run this once in your Replit project):
   DATABASE_URL="postgres://..." pnpm --filter @workspace/db run push

==============================
STEP 3 - CONNECT WEBSITE TO API (1 minute)
==============================

1. In Hostinger cPanel -> File Manager -> open public_html
2. Find the file called: config.js -> click Edit (or right-click -> Edit)
3. Find this line:
       apiUrl: ''
4. Replace it with your Railway URL from Step 2 point 8:
       apiUrl: 'https://rydaaa-api-production.up.railway.app'
5. Save the file

Refresh your website - everything is now connected!

==============================
TROUBLESHOOTING
==============================

Website loads but shows no data:
-> config.js apiUrl is wrong or empty - double check Step 3

404 error when refreshing any page:
-> .htaccess is missing or in wrong location
-> Make sure .htaccess is directly inside public_html/ (not in a subfolder)

API not starting on Railway:
-> DATABASE_URL not set - re-check Step 2 point 7

CORS error in browser console (F12 -> Console tab):
-> Add this in Railway -> your API service -> Variables:
   ALLOWED_ORIGIN  ->  https://yourdomain.com
