# AURA LIVE — Installation Guide

Full stack: **web (React+Vite)** · **admin panel** · **Android app (React Native)** · **API server (Express+TS+Socket.IO)** · **MySQL 8** · **optional Redis** · **LiveKit voice** · **Razorpay payments**.

## 0. Requirements
| Tool | Version |
|---|---|
| Node.js | ≥ 18.17 (20 LTS recommended) |
| MySQL | 8.0+ (or `docker compose up mysql`) |
| Redis | 7+ (optional; in-memory fallback used otherwise) |
| Java 17 + Android SDK | only for building the Android app |

## 1. Get the code & configure
```bash
unzip aura-live.zip && cd aura-live
cp .env.example .env
```
Edit `.env` (minimum):
```ini
DB_PASSWORD=<strong password>
JWT_ACCESS_SECRET=<64 random chars>
JWT_REFRESH_SECRET=<64 random chars>
```
Generate secrets: `node -e "console.log(require('crypto').randomBytes(48).toString('hex'))"`

Optional integrations (all degrade gracefully with clear errors when unset):
- `LIVEKIT_*` — real voice chat (see docs/VOICE_SETUP.md)
- `RAZORPAY_*` — real payments (dev mode auto-credits via mock provider; production fails safe)
- `SMTP_*` — real email (dev mode logs emails to console)
- `S3_*` — S3 media storage (dev mode uses local `uploads/` dir)

## 2. Database
```bash
cd server
npm install
npm run migrate          # creates schema (45 tables)
npm run seed             # demo users, rooms, gifts, packages, admin
```
Demo login (dev): any seeded user, e.g. `aarav_demo` / `Demo#Pass123`.
Admin login: value of `ADMIN_INITIAL_EMAIL` / `ADMIN_INITIAL_PASSWORD` (default `admin@auralive.example` / `ChangeMe!123` — **change it**).

## 3. Run the backend
```bash
cd server
npm run dev              # http://localhost:4000  (REST + Socket.IO)
```
Health check: `curl http://localhost:4000/health`

## 4. Run the website
```bash
cd apps/web
npm install
npm run dev              # http://localhost:5173 (proxies /api + /socket.io to :4000)
```

## 5. Run the admin panel
```bash
cd admin
npm install
npm run dev              # http://localhost:5174
```

## 6. Android app
See `apps/mobile/BUILD_GUIDE.md` (creates the `android/` shell, debug + signed release APK/AAB).

## 7. Production build
```bash
# from repo root
npm run build:shared
npm run build:server     # server/dist
npm run build:web        # apps/web/dist (static)
npm run build:admin      # admin/dist (static)
```
Serve the static builds with Nginx (see docs/DEPLOYMENT.md) or:
```bash
docker compose up -d --build   # mysql + redis + server + web + admin
```

## 8. Running the automated tests
```bash
cd server
npm test                  # unit tests (no DB needed)
TEST_DB=1 npm test        # + full API integration tests against the configured MySQL
```

## Troubleshooting
| Symptom | Fix |
|---|---|
| `DB_UNAVAILABLE` 503 | MySQL not running / wrong `.env` → start it, check creds, re-run migrate |
| Voice rooms show "not configured" banner | set `LIVEKIT_URL`, `LIVEKIT_API_KEY`, `LIVEKIT_API_SECRET` → restart server |
| Checkout says payments not configured | set Razorpay keys (prod) — dev uses the mock provider automatically |
| Socket disconnects | ensure the proxy forwards websocket upgrades (`/socket.io`) |
