194 lines
4.4 KiB
Markdown
194 lines
4.4 KiB
Markdown
# Guía de instalación
|
|
|
|
> Paso a paso para correr Mi Ruta Limpia en macOS / Linux.
|
|
|
|
---
|
|
|
|
## 1. Requisitos previos
|
|
|
|
| Software | Versión | Verificar con |
|
|
|----------|---------|---------------|
|
|
| **Node.js** | 20 LTS (**no 22+**) | `node --version` |
|
|
| **Python** | 3.11 - 3.13 | `python3 --version` |
|
|
| **Xcode** (solo iOS) | 15+ | App Store |
|
|
| **Watchman** (opcional pero recomendado) | última | `brew install watchman` |
|
|
|
|
### Instalar Node 20 si tienes versión nueva
|
|
```bash
|
|
# Con nvm (recomendado)
|
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
|
|
nvm install 20
|
|
nvm use 20
|
|
|
|
# O con Homebrew
|
|
brew install node@20
|
|
brew link --overwrite node@20
|
|
```
|
|
|
|
---
|
|
|
|
## 2. Backend
|
|
|
|
```bash
|
|
cd backend
|
|
|
|
# Crear entorno virtual
|
|
python3 -m venv venv
|
|
source venv/bin/activate
|
|
|
|
# Instalar dependencias
|
|
pip install -r requirements.txt
|
|
|
|
# Configurar variables de entorno
|
|
cp .env.example .env
|
|
# Edita .env si quieres cambiar SECRET_KEY (opcional para hackathon)
|
|
|
|
# Poblar BD con datos demo + masivos
|
|
python seed_massive.py
|
|
# Esto crea ~200 usuarios, 62 camiones, 280 reportes, etc.
|
|
```
|
|
|
|
### Arrancar el servidor
|
|
|
|
```bash
|
|
# Con --host 0.0.0.0 para que el simulador iOS lo alcance
|
|
uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
|
```
|
|
|
|
Verifica que esté corriendo:
|
|
- Local: `curl http://localhost:8000/health`
|
|
- Docs OpenAPI: abre `http://localhost:8000/docs` en el navegador
|
|
|
|
---
|
|
|
|
## 3. Frontend
|
|
|
|
```bash
|
|
cd frontend
|
|
|
|
# Aumentar límite de file descriptors (macOS)
|
|
ulimit -n 65536
|
|
|
|
# Instalar dependencias
|
|
npm install
|
|
|
|
# Configurar IP del backend
|
|
# Edita: frontend/src/constants/config.js
|
|
# Cambia la línea:
|
|
# export const API_BASE_URL = 'http://10.82.68.125:8000/api/v1';
|
|
# por la IP de TU Mac (obténla con `ipconfig getifaddr en0`)
|
|
```
|
|
|
|
### Arrancar Metro y la app
|
|
|
|
```bash
|
|
npx expo start --clear
|
|
```
|
|
|
|
Cuando aparezca el menú:
|
|
- **`i`** → iOS Simulator
|
|
- **`a`** → Android Emulator
|
|
- **`w`** → Navegador web
|
|
- Escanea el **QR** con la app **Expo Go** (App Store / Play Store) si quieres usar tu celular físico
|
|
|
|
> ⚠️ Para celular físico, debes estar en la **misma red Wi-Fi** que la Mac.
|
|
|
|
---
|
|
|
|
## 4. Credenciales para probar
|
|
|
|
Después de `seed_massive.py`, usa cualquiera de estas:
|
|
|
|
| Rol | Email | Contraseña |
|
|
|-----|-------|-----------|
|
|
| 🧑 Ciudadano | `demo@celaya.gob.mx` | `Celaya2026` |
|
|
| 👮 Empleado | `empleado@celaya.gob.mx` | `Empleado2026` |
|
|
| 🛡️ Admin | `admin@celaya.gob.mx` | `Admin2026` |
|
|
|
|
---
|
|
|
|
## 5. Troubleshooting
|
|
|
|
### "Credenciales inválidas" pero las escribí bien
|
|
- Verifica que el backend esté corriendo con `--host 0.0.0.0`
|
|
- Verifica que la IP en `config.js` coincida con tu IP local actual
|
|
- Reinicia Metro con `npx expo start --clear`
|
|
|
|
### "EMFILE: too many open files"
|
|
```bash
|
|
ulimit -n 65536
|
|
brew install watchman
|
|
```
|
|
|
|
### "URL.protocol is not implemented"
|
|
Verifica que `index.js` (en la raíz de `frontend/`) sea:
|
|
```js
|
|
import 'react-native-url-polyfill/auto';
|
|
import 'expo/AppEntry';
|
|
```
|
|
Y que `package.json` tenga `"main": "index.js"`.
|
|
|
|
### "main has not been registered"
|
|
Causa más común: un módulo falló al cargar silenciosamente. Reinicia con:
|
|
```bash
|
|
npx expo start --clear
|
|
```
|
|
|
|
### "Cannot find module .../something.types"
|
|
Tu Node.js es muy nuevo (22+). Cambia a Node 20 LTS:
|
|
```bash
|
|
nvm use 20
|
|
rm -rf node_modules package-lock.json
|
|
npm install
|
|
```
|
|
|
|
### Backend dice "passlib bcrypt error"
|
|
```bash
|
|
pip install 'bcrypt==4.0.1'
|
|
```
|
|
|
|
### El simulador no encuentra el servidor
|
|
Confirma la IP correcta con:
|
|
```bash
|
|
ipconfig getifaddr en0
|
|
```
|
|
Y actualiza `frontend/src/constants/config.js` con esa IP.
|
|
|
|
---
|
|
|
|
## 6. Reiniciar todo desde cero
|
|
|
|
Si algo se rompe completamente:
|
|
|
|
```bash
|
|
# Frontend
|
|
cd frontend
|
|
rm -rf node_modules package-lock.json
|
|
npm install
|
|
npx expo start --clear
|
|
|
|
# Backend
|
|
cd ../backend
|
|
source venv/bin/activate
|
|
rm -f mi_ruta_limpia.db # ¡Cuidado! Borra todos los datos
|
|
python seed_massive.py
|
|
uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
|
```
|
|
|
|
---
|
|
|
|
## 7. Cómo configurar para presentar
|
|
|
|
### Pre-checklist (5 min antes del pitch):
|
|
|
|
- [ ] Backend corriendo con `--host 0.0.0.0`
|
|
- [ ] Frontend corriendo con `npx expo start`
|
|
- [ ] iOS Simulator abierto en iPhone 17 Pro (Cmd+R recargado)
|
|
- [ ] Probar login con `demo@celaya.gob.mx` → debe entrar a la vista ciudadana
|
|
- [ ] Probar login con `admin@celaya.gob.mx` → debe ver el dashboard con stats
|
|
- [ ] WiFi estable
|
|
- [ ] Pantalla de Mac compartida en el proyector
|
|
|
|
### Para la demo:
|
|
Sigue el script en [`docs/PRESENTACION.md`](PRESENTACION.md).
|