## Backend Changes - Add new API endpoints: combustible, pois, mantenimiento, video, configuracion - Fix vehiculos endpoint to return paginated response with items array - Add /vehiculos/all endpoint for non-paginated list - Add /geocercas/all endpoint - Add /alertas/configuracion GET/PUT endpoints - Add /viajes/activos and /viajes/iniciar endpoints - Add /reportes/stats, /reportes/templates, /reportes/preview endpoints - Add /conductores/all and /conductores/disponibles endpoints - Update router.py to include all new modules ## Frontend Changes - Fix authentication token handling (snake_case vs camelCase) - Update vehiculosApi.listAll to use /vehiculos/all - Fix FuelGauge component usage in Combustible page - Fix chart component exports (named + default exports) - Update API client for proper token refresh ## Infrastructure - Rename services from ADAN to ATLAS - Configure Cloudflare tunnel for atlas.consultoria-as.com - Update systemd service files - Configure PostgreSQL with TimescaleDB - Configure Redis, Mosquitto, Traccar, MediaMTX ## Documentation - Update installation guides - Update API reference - Rename all ADAN references to ATLAS Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
8.7 KiB
8.7 KiB
Guia de Configuracion
Configuracion detallada de todos los componentes del sistema ATLAS.
Variables de Entorno
El archivo /opt/atlas/.env contiene todas las configuraciones del sistema.
Base de Datos
# PostgreSQL
DATABASE_URL=postgresql://atlas:PASSWORD@localhost:5432/atlas_db
# Conexiones maximas al pool
DB_POOL_SIZE=10
DB_MAX_OVERFLOW=20
Redis
# URL de conexion
REDIS_URL=redis://localhost:6379
# Base de datos (0-15)
REDIS_DB=0
Seguridad
# Clave secreta para JWT (generar con: openssl rand -base64 64)
JWT_SECRET=tu_clave_muy_larga_y_segura
# Expiracion de tokens
ACCESS_TOKEN_EXPIRE_MINUTES=1440 # 24 horas
REFRESH_TOKEN_EXPIRE_DAYS=7
# Clave para encriptar datos sensibles
ENCRYPTION_KEY=otra_clave_segura
Traccar
# Conexion a Traccar
TRACCAR_HOST=localhost
TRACCAR_PORT=5055
TRACCAR_FORWARD_URL=http://localhost:8000/api/v1/traccar/position
Video Streaming
# MediaMTX
MEDIAMTX_API=http://localhost:9997
MEDIAMTX_RTSP=rtsp://localhost:8554
MEDIAMTX_WEBRTC=http://localhost:8889
MEDIAMTX_HLS=http://localhost:8888
# Directorio de grabaciones
VIDEO_STORAGE_PATH=/opt/atlas/videos
VIDEO_RETENTION_DAYS=30
MQTT (Meshtastic)
MQTT_HOST=localhost
MQTT_PORT=1883
MQTT_USER=mesh_gateway
MQTT_PASSWORD=password_seguro
MQTT_TOPIC=atlas/mesh/#
Notificaciones
# Email (SMTP)
SMTP_HOST=smtp.tudominio.com
SMTP_PORT=587
SMTP_USER=notificaciones@tudominio.com
SMTP_PASSWORD=password
SMTP_FROM=ATLAS <notificaciones@tudominio.com>
# Push Notifications (Firebase)
FIREBASE_CREDENTIALS_FILE=/opt/atlas/firebase-credentials.json
Dominio
DOMAIN=atlas.tudominio.com
API_URL=https://atlas.tudominio.com/api
FRONTEND_URL=https://atlas.tudominio.com
Configuracion de Traccar
Archivo: /opt/traccar/conf/traccar.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>
<properties>
<!-- Base de datos -->
<entry key='database.driver'>org.postgresql.Driver</entry>
<entry key='database.url'>jdbc:postgresql://localhost:5432/atlas_db</entry>
<entry key='database.user'>atlas</entry>
<entry key='database.password'>TU_PASSWORD</entry>
<!-- Deshabilitar web UI de Traccar (usamos nuestro dashboard) -->
<entry key='web.enable'>false</entry>
<entry key='api.enable'>false</entry>
<!-- Forward de posiciones a nuestra API -->
<entry key='forward.enable'>true</entry>
<entry key='forward.url'>http://localhost:8000/api/v1/traccar/position</entry>
<entry key='forward.json'>true</entry>
<!-- Protocolos habilitados (agregar segun tus GPS) -->
<entry key='gt06.port'>5023</entry>
<entry key='tk103.port'>5002</entry>
<entry key='gps103.port'>5001</entry>
<entry key='osmand.port'>5055</entry>
<!-- Logging -->
<entry key='logger.enable'>true</entry>
<entry key='logger.level'>info</entry>
</properties>
Protocolos GPS Comunes
| Protocolo | Puerto | Dispositivos |
|---|---|---|
| osmand | 5055 | Apps moviles, GPS genericos |
| gt06 | 5023 | Concox, Wetrack, JM01 |
| tk103 | 5002 | TK103, GPS103 |
| h02 | 5013 | Sinotrack ST-901 |
| watch | 5093 | Smartwatches GPS |
| teltonika | 5027 | Teltonika FM |
Para habilitar un protocolo adicional, agregar la linea:
<entry key='PROTOCOLO.port'>PUERTO</entry>
Y abrir el puerto en el firewall:
ufw allow PUERTO/tcp
Configuracion de MediaMTX
Archivo: /etc/mediamtx/mediamtx.yml
# Logging
logLevel: info
logDestinations: [stdout]
# API para control
api: yes
apiAddress: 127.0.0.1:9997
# RTSP Server (para recibir streams de camaras)
rtsp: yes
rtspAddress: :8554
protocols: [tcp, udp]
rtspAuthMethods: []
# WebRTC Server (para dashboard)
webrtc: yes
webrtcAddress: :8889
webrtcAllowOrigin: '*'
webrtcICEServers2:
- urls: [stun:stun.l.google.com:19302]
# HLS Server (para app movil)
hls: yes
hlsAddress: :8888
hlsAllowOrigin: '*'
hlsAlwaysRemux: yes
hlsSegmentCount: 3
hlsSegmentDuration: 1s
# Grabacion
record: no # Manejamos grabacion desde nuestra API
recordPath: /opt/atlas/videos/%path/%Y%m%d_%H%M%S.mp4
# Paths (camaras)
paths:
# Patron para camaras: cam_{vehiculo_id}_{posicion}
cam~:
source: publisher
# Autenticacion para publicar
publishUser: camuser
publishPass: campass
# Autenticacion para ver (vacio = sin auth, lo manejamos con JWT)
readUser: ''
readPass: ''
Agregar Camara Manualmente
# Crear path para una camara
curl -X POST http://localhost:9997/v2/config/paths/add/cam_1_frontal \
-H "Content-Type: application/json" \
-d '{
"source": "rtsp://usuario:password@192.168.1.100/stream1",
"sourceOnDemand": true
}'
Configuracion de Cloudflare Tunnel
Archivo: /etc/cloudflared/config.yml
tunnel: TU_TUNNEL_ID
credentials-file: /root/.cloudflared/TU_TUNNEL_ID.json
ingress:
# API Backend
- hostname: atlas.tudominio.com
path: /api/*
service: http://localhost:8000
# WebSocket
- hostname: atlas.tudominio.com
path: /ws/*
service: http://localhost:8000
# Frontend (default)
- hostname: atlas.tudominio.com
service: http://localhost:3000
# Catch-all
- service: http_status:404
Comandos Utiles
# Ver estado del tunnel
cloudflared tunnel info TU_TUNNEL_ID
# Listar tunnels
cloudflared tunnel list
# Ver conexiones activas
cloudflared tunnel run --url http://localhost:3000
# Reiniciar
systemctl restart cloudflared
Configuracion de PostgreSQL
Ajustes de Rendimiento
Archivo: /etc/postgresql/15/main/postgresql.conf
# Memoria (ajustar segun RAM disponible)
shared_buffers = 2GB # 25% de RAM
effective_cache_size = 6GB # 75% de RAM
work_mem = 256MB
maintenance_work_mem = 512MB
# Conexiones
max_connections = 100
# WAL
wal_buffers = 64MB
checkpoint_completion_target = 0.9
# Logging
log_min_duration_statement = 1000 # Log queries > 1 segundo
TimescaleDB
-- Ver chunks de la hypertable
SELECT show_chunks('ubicaciones');
-- Comprimir chunks antiguos
SELECT compress_chunk(c, if_not_compressed => true)
FROM show_chunks('ubicaciones', older_than => INTERVAL '7 days') c;
-- Configurar compresion automatica
SELECT add_compression_policy('ubicaciones', INTERVAL '7 days');
-- Configurar retencion automatica
SELECT add_retention_policy('ubicaciones', INTERVAL '90 days');
Configuracion de Redis
Archivo: /etc/redis/redis.conf
# Memoria
maxmemory 512mb
maxmemory-policy allkeys-lru
# Persistencia
save 900 1
save 300 10
save 60 10000
# Solo conexiones locales
bind 127.0.0.1
Configuracion de Firewall (UFW)
# Ver estado actual
ufw status verbose
# Reglas recomendadas
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow 5055/tcp # GPS Traccar
# Si necesitas mas puertos GPS
ufw allow 5001:5099/tcp # Rango de puertos Traccar
# Habilitar
ufw enable
Configuracion de Systemd Services
atlas-api.service
[Unit]
Description=ATLAS API Backend
After=network.target postgresql.service redis.service
[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/opt/atlas/backend
Environment="PATH=/opt/atlas/venv/bin"
EnvironmentFile=/opt/atlas/.env
ExecStart=/opt/atlas/venv/bin/uvicorn app.main:app \
--host 127.0.0.1 \
--port 8000 \
--workers 4 \
--loop uvloop \
--http httptools
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
atlas-web.service
[Unit]
Description=ATLAS Web Frontend
After=network.target
[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/opt/atlas/frontend
ExecStart=/usr/bin/npx serve -s dist -l 3000
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
Configuracion desde el Dashboard
Muchas configuraciones se pueden cambiar desde Configuracion en el dashboard:
General
- Zona horaria
- Unidades (km/millas, litros/galones)
- Moneda
- Idioma
Alertas
- Velocidad maxima global
- Tiempo de parada para alerta (minutos)
- Tiempo offline para alerta (minutos)
- Notificaciones por email
Mapa
- Proveedor de mapas
- Estilo (claro/oscuro)
- Capas por defecto
Retencion de Datos
- Dias de ubicaciones detalladas
- Dias de ubicaciones agregadas
- Dias de grabaciones de video
- Dias de alertas
Aplicar Cambios
Despues de modificar archivos de configuracion:
# Recargar configuracion de systemd
systemctl daemon-reload
# Reiniciar servicio especifico
systemctl restart atlas-api
# Reiniciar todos los servicios
systemctl restart atlas-api atlas-web traccar mediamtx
# Verificar estado
systemctl status atlas-api atlas-web traccar mediamtx