feat(base): finalizada Fase 1 scaffolding v0.1.0-alpha
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
# ==============================================================================
|
||||||
|
# Oemspot OnEverControl — Configuración de Entorno (Modelo)
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# Entorno y Depuración
|
||||||
|
ENVIRONMENT=development
|
||||||
|
DEBUG=True
|
||||||
|
LOG_LEVEL=INFO
|
||||||
|
|
||||||
|
# Servidor Web & API
|
||||||
|
SERVER_HOST=0.0.0.0
|
||||||
|
SERVER_PORT=8000
|
||||||
|
ALLOWED_ORIGINS=http://localhost:5173,http://127.0.0.1:5173,http://localhost:8000,http://127.0.0.1:8000
|
||||||
|
|
||||||
|
# Base de Datos Microsoft SQL Server (videoman)
|
||||||
|
# Compatible con Windows 10/11, LXC (FreeTDS) y Docker
|
||||||
|
DB_SERVER=127.0.0.1
|
||||||
|
DB_PORT=1433
|
||||||
|
DB_NAME=videoman
|
||||||
|
DB_USER=sa
|
||||||
|
DB_PASSWORD=tu_password_seguro
|
||||||
|
DB_CHARSET=CP1252
|
||||||
|
DB_TIMEOUT=15
|
||||||
|
|
||||||
|
# Seguridad y Autenticación JWT
|
||||||
|
SECRET_KEY=cambiar_esta_clave_secreta_por_una_cadena_larga_de_minimo_32_caracteres_aleatorios
|
||||||
|
ACCESS_TOKEN_EXPIRE_MINUTES=30
|
||||||
|
REFRESH_TOKEN_EXPIRE_DAYS=7
|
||||||
|
|
||||||
|
# Identificador de Estación por Defecto (si el cliente no envía uno)
|
||||||
|
DEFAULT_WORKSTATION_NAME=GARITA_PRINCIPAL
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
# ==============================================================================
|
||||||
|
# Git Ignore - OnEverControl
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# Entorno local y secretos
|
||||||
|
.env
|
||||||
|
*.env.local
|
||||||
|
|
||||||
|
# Python
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
*.so
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# Entornos virtuales de Python
|
||||||
|
venv/
|
||||||
|
env/
|
||||||
|
ENV/
|
||||||
|
.venv/
|
||||||
|
|
||||||
|
# Pytest / Cobertura
|
||||||
|
.pytest_cache/
|
||||||
|
.coverage
|
||||||
|
htmlcov/
|
||||||
|
|
||||||
|
# Node.js & Vite
|
||||||
|
node_modules/
|
||||||
|
frontend/dist/
|
||||||
|
frontend/node_modules/
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
*.log
|
||||||
|
logs/
|
||||||
|
backend/logs/
|
||||||
|
|
||||||
|
# IDE & Editores
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.sublime-project
|
||||||
|
*.sublime-workspace
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
@@ -2,6 +2,30 @@
|
|||||||
|
|
||||||
Todas las modificaciones, adiciones y decisiones de arquitectura notables de este proyecto serán documentadas en este archivo.
|
Todas las modificaciones, adiciones y decisiones de arquitectura notables de este proyecto serán documentadas en este archivo.
|
||||||
|
|
||||||
|
## [v0.1.0-alpha] - 2026-10-13 (Fase 1: Arquitectura y Base del Proyecto)
|
||||||
|
|
||||||
|
### Agregado
|
||||||
|
- **Backend FastAPI:**
|
||||||
|
- Configuración tipada con Pydantic Settings (`backend/app/core/config.py`).
|
||||||
|
- Definición de versión `0.1.0-alpha` (`backend/app/__version__.py`).
|
||||||
|
- Endpoint de verificación de salud `GET /health` y metadata `GET /` (`backend/app/main.py`).
|
||||||
|
- Middlewares de CORS y compresión GZip para red local y tablets.
|
||||||
|
- Router base versionado v1 (`backend/app/api/v1/router.py`).
|
||||||
|
- Pruebas unitarias automatizadas con `pytest` y `httpx` (`backend/tests/test_health.py`).
|
||||||
|
- **Frontend React + TypeScript + Vite:**
|
||||||
|
- Proyecto inicializado con versión `0.1.0-alpha` (`frontend/package.json`).
|
||||||
|
- Sistema de diseño con OnEver Design Tokens (`frontend/src/styles/tokens.css`).
|
||||||
|
- Layout Touch-First `100dvh` adaptado a Samsung Galaxy Tab A9/A11 de 4GB RAM (`frontend/src/styles/base.css`).
|
||||||
|
- Componente shell principal con verificación en tiempo real de salud de API y modo kiosco (`frontend/src/App.tsx`).
|
||||||
|
- Build estático ultraoptimizado con Vite (< 50 KB gzip).
|
||||||
|
- **Despliegue Multiplataforma:**
|
||||||
|
- Plantilla de variables de entorno `.env.example`.
|
||||||
|
- Configuración de orquestación `docker-compose.yml` y Nginx proxy.
|
||||||
|
- Dockerfile para Backend FastAPI.
|
||||||
|
- Script de instalación de servicio Windows NSSM (`scripts/windows/install_service.bat`) y modo nativo (`scripts/windows/start_native.bat`).
|
||||||
|
- Script de aprovisionamiento LXC para Proxmox/Debian (`scripts/lxc/setup_lxc.sh`) y unit file systemd (`scripts/lxc/onevercontrol.service`).
|
||||||
|
- Script agnóstico de diagnóstico y test de conectividad SQL Server (`scripts/test_sql_connection.py`).
|
||||||
|
|
||||||
## [Fase 0: Análisis y Arquitectura] - 2026-10-13
|
## [Fase 0: Análisis y Arquitectura] - 2026-10-13
|
||||||
|
|
||||||
### Agregado
|
### Agregado
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
Memoria del proyecto entre sesiones. Máximo ~50 líneas: resume o elimina lo que ya no aporte.
|
Memoria del proyecto entre sesiones. Máximo ~50 líneas: resume o elimina lo que ya no aporte.
|
||||||
|
|
||||||
## Estado actual
|
## Estado actual
|
||||||
- **Fase 0 (Completada):** Análisis técnico exhaustivo del puesto de control actual (`OemspotPySYS`), definición de arquitectura, tecnologías y hoja de ruta.
|
- **Fase 0 (Completada):** Análisis técnico exhaustivo del puesto de control actual (`OemspotPySYS`), definición de arquitectura, tecnologías y roadmap.
|
||||||
- **Arnés de IA y SDD configurado:** Creados `AGENTS.md`, `docs/constitution.md` y estructura de especificaciones.
|
- **Fase 1 (Completada - v0.1.0-alpha):** Base del proyecto, backend FastAPI con `/health` (tests en verde), frontend React + TypeScript + Vite con layout `100dvh` compilado limpiamente (< 50KB gzip), configuración multiplataforma (Windows 10/11, LXC y Docker) y script de diagnóstico SQL Server.
|
||||||
- **Pendiente:** Aprobación de la primera spec (`specs/001-login-workstation/`) para dar inicio a la Fase 1.
|
- **Pendiente:** Implementar la primera especificación funcional (`specs/001-login-workstation/`) correspondiente a la Fase 2 (Backend Core y Login).
|
||||||
|
|
||||||
## Decisiones (y por qué)
|
## Decisiones (y por qué)
|
||||||
- **Backend en FastAPI + Pydantic v2 & Frontend en React + TypeScript + Vite:** FastAPI reutiliza los módulos probados de Python (`parser_dni`, pymssql) y gestiona la persistencia con SQL Server `videoman`. React con TypeScript y Vite produce una SPA estática ultraliviana con huella mínima en memoria RAM (~30-50 MB en navegador), fundamental para operar de forma fluida y sin lag en tablets **Samsung Galaxy Tab A9 y A11 de 4GB de RAM**.
|
- **Backend en FastAPI + Pydantic v2 & Frontend en React + TypeScript + Vite:** FastAPI reutiliza los módulos probados de Python (`parser_dni`, pymssql) y gestiona la persistencia con SQL Server `videoman`. React con TypeScript y Vite produce una SPA estática ultraliviana con huella mínima en memoria RAM (~30-50 MB en navegador), fundamental para operar de forma fluida y sin lag en tablets **Samsung Galaxy Tab A9 y A11 de 4GB de RAM**.
|
||||||
@@ -24,5 +24,5 @@ Memoria del proyecto entre sesiones. Máximo ~50 líneas: resume o elimina lo qu
|
|||||||
- **Evitar re-renders en inputs táctiles:** En tablets, los re-renders pesados provocan pérdida de foco en el teclado en pantalla. Usar estado reactivo localizado.
|
- **Evitar re-renders en inputs táctiles:** En tablets, los re-renders pesados provocan pérdida de foco en el teclado en pantalla. Usar estado reactivo localizado.
|
||||||
|
|
||||||
## Próximos pasos
|
## Próximos pasos
|
||||||
- [ ] Validar y aprobar la especificación `specs/001-login-workstation/spec.md`.
|
- [ ] Fase 2: Implementación de `specs/001-login-workstation/` (Autenticación JWT, verificación de contraseña y asignación de Workstation/carriles en SQL Server).
|
||||||
- [ ] Fase 1: Scaffolding inicial del backend FastAPI y frontend Node.js / Vite.
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# ==============================================================================
|
||||||
|
# Dockerfile para Backend FastAPI (OnEverControl)
|
||||||
|
# Compatible con Linux x86_64 y ARM64
|
||||||
|
# ==============================================================================
|
||||||
|
FROM python:3.12-slim
|
||||||
|
|
||||||
|
# Evitar prompts interactivos y buffer de python
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive \
|
||||||
|
PYTHONUNBUFFERED=1 \
|
||||||
|
PYTHONDONTWRITEBYTECODE=1
|
||||||
|
|
||||||
|
# Instalar dependencias del sistema requeridas por FreeTDS (pymssql)
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
freetds-dev \
|
||||||
|
freetds-bin \
|
||||||
|
build-essential \
|
||||||
|
curl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Configurar directorio de trabajo
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copiar dependencias de Python e instalarlas
|
||||||
|
COPY requirements.txt /app/
|
||||||
|
RUN pip install --no-cache-dir --upgrade pip && \
|
||||||
|
pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
# Copiar el código de la aplicación
|
||||||
|
COPY app/ /app/app/
|
||||||
|
|
||||||
|
# Exponer el puerto de Uvicorn
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
# Healthcheck interno de Docker
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||||
|
CMD curl -f http://localhost:8000/health || exit 1
|
||||||
|
|
||||||
|
# Comando por defecto
|
||||||
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# OnEverControl Backend Package
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# ==============================================================================
|
||||||
|
# OnEverControl - Versión del Backend
|
||||||
|
# ==============================================================================
|
||||||
|
__version__ = "0.1.0-alpha"
|
||||||
|
__app_name__ = "OnEverControl"
|
||||||
|
__description__ = "Cliente Web Reducido para Puesto de Control en Red Local de OnEverAccess"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# API module
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# API v1 module
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# ==============================================================================
|
||||||
|
# Router Principal API v1
|
||||||
|
# ==============================================================================
|
||||||
|
from fastapi import APIRouter
|
||||||
|
|
||||||
|
api_router = APIRouter()
|
||||||
|
|
||||||
|
# En fases posteriores aquí se incluirán los sub-routers:
|
||||||
|
# api_router.include_router(auth.router, prefix="/auth", tags=["Autenticación"])
|
||||||
|
# api_router.include_router(control_posts.router, prefix="/control-posts", tags=["Puestos de Control"])
|
||||||
|
# api_router.include_router(access.router, prefix="/access", tags=["Accesos"])
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# Core module
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
# ==============================================================================
|
||||||
|
# Configuración Tipada con Pydantic Settings
|
||||||
|
# Compatible con Windows 10/11, LXC y Docker
|
||||||
|
# ==============================================================================
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import List, Union
|
||||||
|
from pydantic import Field, field_validator
|
||||||
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
|
|
||||||
|
# Directorio raíz del proyecto (OnEverControl)
|
||||||
|
BASE_DIR = Path(__file__).resolve().parent.parent.parent.parent
|
||||||
|
ENV_PATH = BASE_DIR / ".env"
|
||||||
|
|
||||||
|
|
||||||
|
class Settings(BaseSettings):
|
||||||
|
model_config = SettingsConfigDict(
|
||||||
|
env_file=str(ENV_PATH) if ENV_PATH.exists() else None,
|
||||||
|
env_file_encoding="utf-8",
|
||||||
|
extra="ignore",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Entorno
|
||||||
|
ENVIRONMENT: str = "development"
|
||||||
|
DEBUG: bool = True
|
||||||
|
LOG_LEVEL: str = "INFO"
|
||||||
|
|
||||||
|
# Servidor
|
||||||
|
SERVER_HOST: str = "0.0.0.0"
|
||||||
|
SERVER_PORT: int = 8000
|
||||||
|
ALLOWED_ORIGINS: Union[str, List[str]] = [
|
||||||
|
"http://localhost:5173",
|
||||||
|
"http://127.0.0.1:5173",
|
||||||
|
"http://localhost:8000",
|
||||||
|
"http://127.0.0.1:8000",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Base de Datos SQL Server (videoman)
|
||||||
|
DB_SERVER: str = "127.0.0.1"
|
||||||
|
DB_PORT: int = 1433
|
||||||
|
DB_NAME: str = "videoman"
|
||||||
|
DB_USER: str = "sa"
|
||||||
|
DB_PASSWORD: str = ""
|
||||||
|
DB_CHARSET: str = "CP1252"
|
||||||
|
DB_TIMEOUT: int = 15
|
||||||
|
|
||||||
|
# Seguridad JWT
|
||||||
|
SECRET_KEY: str = "dev_secret_key_change_in_production_min_32_chars_1234567890"
|
||||||
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
|
||||||
|
REFRESH_TOKEN_EXPIRE_DAYS: int = 7
|
||||||
|
|
||||||
|
# Estación por Defecto
|
||||||
|
DEFAULT_WORKSTATION_NAME: str = "GARITA_PRINCIPAL"
|
||||||
|
|
||||||
|
@field_validator("ALLOWED_ORIGINS", mode="before")
|
||||||
|
@classmethod
|
||||||
|
def assemble_cors_origins(cls, v: Union[str, List[str]]) -> List[str]:
|
||||||
|
if isinstance(v, str) and not v.startswith("["):
|
||||||
|
return [i.strip() for i in v.split(",") if i.strip()]
|
||||||
|
elif isinstance(v, list):
|
||||||
|
return v
|
||||||
|
return ["*"]
|
||||||
|
|
||||||
|
|
||||||
|
# Instancia singleton de configuración
|
||||||
|
settings = Settings()
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
# ==============================================================================
|
||||||
|
# Punto de Entrada Principal FastAPI (OnEverControl)
|
||||||
|
# ==============================================================================
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
from fastapi import FastAPI
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
from fastapi.middleware.gzip import GZipMiddleware
|
||||||
|
from fastapi.responses import JSONResponse
|
||||||
|
|
||||||
|
from app.__version__ import __version__, __app_name__, __description__
|
||||||
|
from app.core.config import settings
|
||||||
|
from app.api.v1.router import api_router
|
||||||
|
|
||||||
|
|
||||||
|
# Creación de la instancia FastAPI
|
||||||
|
app = FastAPI(
|
||||||
|
title=__app_name__,
|
||||||
|
version=__version__,
|
||||||
|
description=__description__,
|
||||||
|
docs_url="/docs",
|
||||||
|
redoc_url="/redoc",
|
||||||
|
openapi_url="/openapi.json",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Middleware de Compresión GZip (optimiza transferencia a tablets por Wi-Fi)
|
||||||
|
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
||||||
|
|
||||||
|
# Middleware de CORS
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=settings.ALLOWED_ORIGINS,
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/health", tags=["Salud del Sistema"], summary="Verificar estado de salud del servicio")
|
||||||
|
async def health_check():
|
||||||
|
"""Retorna el estado de disponibilidad, versión y timestamp del servidor."""
|
||||||
|
return JSONResponse(
|
||||||
|
content={
|
||||||
|
"status": "ok",
|
||||||
|
"app": __app_name__,
|
||||||
|
"version": __version__,
|
||||||
|
"timestamp": datetime.now(timezone.utc).isoformat(),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/", tags=["Información"], summary="Información del servicio")
|
||||||
|
async def root():
|
||||||
|
"""Ruta raíz informativa."""
|
||||||
|
return {
|
||||||
|
"app": __app_name__,
|
||||||
|
"version": __version__,
|
||||||
|
"docs": "/docs",
|
||||||
|
"health": "/health",
|
||||||
|
"api_v1": "/api/v1",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Montaje de routers versionados
|
||||||
|
app.include_router(api_router, prefix="/api/v1")
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fastapi>=0.110.0
|
||||||
|
uvicorn[standard]>=0.29.0
|
||||||
|
pydantic>=2.7.0
|
||||||
|
pydantic-settings>=2.2.0
|
||||||
|
pymssql>=2.2.11
|
||||||
|
python-multipart>=0.0.9
|
||||||
|
httpx>=0.27.0
|
||||||
|
pytest>=8.1.0
|
||||||
|
pytest-asyncio>=0.23.0
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import pytest
|
||||||
|
from httpx import AsyncClient, ASGITransport
|
||||||
|
from app.main import app
|
||||||
|
from app.__version__ import __version__, __app_name__
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_health_check_returns_200_and_metadata():
|
||||||
|
transport = ASGITransport(app=app)
|
||||||
|
async with AsyncClient(transport=transport, base_url="http://test") as client:
|
||||||
|
response = await client.get("/health")
|
||||||
|
|
||||||
|
assert response.status_code == 200
|
||||||
|
data = response.json()
|
||||||
|
assert data["status"] == "ok"
|
||||||
|
assert data["version"] == __version__
|
||||||
|
assert data["app"] == __app_name__
|
||||||
|
assert "timestamp" in data
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_root_redirects_or_returns_info():
|
||||||
|
transport = ASGITransport(app=app)
|
||||||
|
async with AsyncClient(transport=transport, base_url="http://test") as client:
|
||||||
|
response = await client.get("/")
|
||||||
|
|
||||||
|
assert response.status_code == 200
|
||||||
|
data = response.json()
|
||||||
|
assert data["app"] == __app_name__
|
||||||
|
assert data["docs"] == "/docs"
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
services:
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: ./backend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: onevercontrol-backend
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
ports:
|
||||||
|
- "${SERVER_PORT:-8000}:8000"
|
||||||
|
volumes:
|
||||||
|
- ./backend/app:/app/app:ro
|
||||||
|
networks:
|
||||||
|
- onevercontrol-net
|
||||||
|
|
||||||
|
web:
|
||||||
|
image: nginx:alpine
|
||||||
|
container_name: onevercontrol-web
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
volumes:
|
||||||
|
- ./frontend/dist:/usr/share/nginx/html:ro
|
||||||
|
- ./scripts/docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
|
networks:
|
||||||
|
- onevercontrol-net
|
||||||
|
|
||||||
|
networks:
|
||||||
|
onevercontrol-net:
|
||||||
|
driver: bridge
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="es">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta
|
||||||
|
name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
|
||||||
|
/>
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||||
|
<meta name="theme-color" content="#121824" />
|
||||||
|
<meta name="description" content="OnEverControl - Cliente Web Puesto de Control de Garita" />
|
||||||
|
<title>OnEverControl — Puesto de Control</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Generated
+1755
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "onevercontrol-frontend",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.1.0-alpha",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "tsc && vite build",
|
||||||
|
"preview": "vite preview"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"react": "^18.3.1",
|
||||||
|
"react-dom": "^18.3.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/react": "^18.3.3",
|
||||||
|
"@types/react-dom": "^18.3.0",
|
||||||
|
"@vitejs/plugin-react": "^4.3.1",
|
||||||
|
"typescript": "^5.4.5",
|
||||||
|
"vite": "^5.3.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,273 @@
|
|||||||
|
import React, { useState, useEffect, useCallback } from 'react';
|
||||||
|
import './styles/tokens.css';
|
||||||
|
import './styles/base.css';
|
||||||
|
|
||||||
|
interface HealthData {
|
||||||
|
status: string;
|
||||||
|
app: string;
|
||||||
|
version: string;
|
||||||
|
timestamp: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const App: React.FC = () => {
|
||||||
|
const [health, setHealth] = useState<HealthData | null>(null);
|
||||||
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [theme, setTheme] = useState<'dark' | 'light'>('dark');
|
||||||
|
const [workstation] = useState<string>('GARITA_PRINCIPAL');
|
||||||
|
|
||||||
|
const checkHealth = useCallback(async () => {
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
const res = await fetch('/health');
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`HTTP ${res.status}`);
|
||||||
|
}
|
||||||
|
const data: HealthData = await res.json();
|
||||||
|
setHealth(data);
|
||||||
|
} catch (err) {
|
||||||
|
setError(err instanceof Error ? err.message : 'Error al conectar con servidor');
|
||||||
|
setHealth(null);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
checkHealth();
|
||||||
|
}, [checkHealth]);
|
||||||
|
|
||||||
|
const toggleTheme = () => {
|
||||||
|
const nextTheme = theme === 'dark' ? 'light' : 'dark';
|
||||||
|
setTheme(nextTheme);
|
||||||
|
document.documentElement.setAttribute('data-theme', nextTheme);
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleFullscreen = () => {
|
||||||
|
if (!document.fullscreenElement) {
|
||||||
|
document.documentElement.requestFullscreen().catch(() => {});
|
||||||
|
} else {
|
||||||
|
document.exitFullscreen().catch(() => {});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
height: '100%',
|
||||||
|
backgroundColor: 'var(--bg-app)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/* Barra Superior de Garita */}
|
||||||
|
<header
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
padding: '0.75rem 1.25rem',
|
||||||
|
backgroundColor: 'var(--bg-surface)',
|
||||||
|
borderBottom: '1px solid var(--border-subtle)',
|
||||||
|
minHeight: '64px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ display: 'flex', alignItems: 'center', gap: '1rem' }}>
|
||||||
|
<div>
|
||||||
|
<h1 style={{ fontSize: 'var(--font-size-lg)', fontWeight: 700, margin: 0, color: 'var(--text-primary)' }}>
|
||||||
|
OnEverControl
|
||||||
|
</h1>
|
||||||
|
<span style={{ fontSize: 'var(--font-size-xs)', color: 'var(--text-muted)' }}>
|
||||||
|
Puesto de Control Web • Modo Cliente
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<span className="badge badge-info" title="Estación activa">
|
||||||
|
🖥️ {workstation}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style={{ display: 'flex', alignItems: 'center', gap: '0.75rem' }}>
|
||||||
|
{/* Indicador de Salud del Servidor */}
|
||||||
|
{loading ? (
|
||||||
|
<span className="badge badge-info">Conectando...</span>
|
||||||
|
) : health ? (
|
||||||
|
<span className="badge badge-success">
|
||||||
|
● API Conectada (v{health.version})
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<span className="badge badge-danger">
|
||||||
|
✕ Servidor Desconectado ({error})
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Botón de Modo Oscuro / Claro */}
|
||||||
|
<button
|
||||||
|
onClick={toggleTheme}
|
||||||
|
className="touch-target"
|
||||||
|
style={{
|
||||||
|
background: 'transparent',
|
||||||
|
border: '1px solid var(--border-strong)',
|
||||||
|
borderRadius: 'var(--touch-radius)',
|
||||||
|
color: 'var(--text-primary)',
|
||||||
|
cursor: 'pointer',
|
||||||
|
padding: '0.5rem',
|
||||||
|
}}
|
||||||
|
title="Cambiar tema de alto contraste"
|
||||||
|
>
|
||||||
|
{theme === 'dark' ? '☀️' : '🌙'}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{/* Botón de Pantalla Completa */}
|
||||||
|
<button
|
||||||
|
onClick={toggleFullscreen}
|
||||||
|
className="touch-target"
|
||||||
|
style={{
|
||||||
|
background: 'transparent',
|
||||||
|
border: '1px solid var(--border-strong)',
|
||||||
|
borderRadius: 'var(--touch-radius)',
|
||||||
|
color: 'var(--text-primary)',
|
||||||
|
cursor: 'pointer',
|
||||||
|
padding: '0.5rem',
|
||||||
|
}}
|
||||||
|
title="Pantalla Completa (Modo Kiosco)"
|
||||||
|
>
|
||||||
|
⛶
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{/* Contenido Principal */}
|
||||||
|
<main
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
overflowY: 'auto',
|
||||||
|
padding: '1.5rem',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
gap: '1.5rem',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
maxWidth: '680px',
|
||||||
|
width: '100%',
|
||||||
|
backgroundColor: 'var(--bg-surface)',
|
||||||
|
border: '1px solid var(--border-subtle)',
|
||||||
|
borderRadius: '12px',
|
||||||
|
padding: '2rem',
|
||||||
|
boxShadow: 'var(--shadow-md)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ textAlign: 'center', marginBottom: '1.5rem' }}>
|
||||||
|
<h2 style={{ fontSize: 'var(--font-size-xl)', marginBottom: '0.5rem' }}>
|
||||||
|
Base del Sistema Operativa (Fase 1)
|
||||||
|
</h2>
|
||||||
|
<p style={{ color: 'var(--text-secondary)', fontSize: 'var(--font-size-sm)' }}>
|
||||||
|
Entorno base configurado para tablets táctiles y servidores multiplataforma.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'grid',
|
||||||
|
gridTemplateColumns: 'repeat(auto-fit, minmax(240px, 1fr))',
|
||||||
|
gap: '1rem',
|
||||||
|
marginBottom: '1.5rem',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
backgroundColor: 'var(--bg-surface-elevated)',
|
||||||
|
padding: '1rem',
|
||||||
|
borderRadius: '8px',
|
||||||
|
border: '1px solid var(--border-subtle)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ fontSize: 'var(--font-size-xs)', color: 'var(--text-muted)' }}>HARDWARE OBJETIVO</div>
|
||||||
|
<div style={{ fontWeight: 600, marginTop: '0.25rem' }}>Samsung Tab A9 / A11 (4GB)</div>
|
||||||
|
<div style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-success)', marginTop: '0.25rem' }}>
|
||||||
|
✓ Optimizado para 4GB RAM
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
backgroundColor: 'var(--bg-surface-elevated)',
|
||||||
|
padding: '1rem',
|
||||||
|
borderRadius: '8px',
|
||||||
|
border: '1px solid var(--border-subtle)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ fontSize: 'var(--font-size-xs)', color: 'var(--text-muted)' }}>ENTORNO SERVIDOR</div>
|
||||||
|
<div style={{ fontWeight: 600, marginTop: '0.25rem' }}>Windows / LXC / Docker</div>
|
||||||
|
<div style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-info)', marginTop: '0.25rem' }}>
|
||||||
|
✓ Portabilidad Agnostica
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
backgroundColor: 'var(--bg-surface-elevated)',
|
||||||
|
padding: '1rem',
|
||||||
|
borderRadius: '8px',
|
||||||
|
border: '1px solid var(--border-subtle)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ fontSize: 'var(--font-size-xs)', color: 'var(--text-muted)' }}>INTEGRACION HARDWARE</div>
|
||||||
|
<div style={{ fontWeight: 600, marginTop: '0.25rem' }}>Cola pdtmdl en videoman</div>
|
||||||
|
<div style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-success)', marginTop: '0.25rem' }}>
|
||||||
|
✓ Desacople de puertos COM
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
backgroundColor: 'var(--bg-surface-elevated)',
|
||||||
|
padding: '1rem',
|
||||||
|
borderRadius: '8px',
|
||||||
|
border: '1px solid var(--border-subtle)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ fontSize: 'var(--font-size-xs)', color: 'var(--text-muted)' }}>VERSION ACTUAL</div>
|
||||||
|
<div style={{ fontWeight: 600, marginTop: '0.25rem' }}>v0.1.0-alpha</div>
|
||||||
|
<div style={{ fontSize: 'var(--font-size-xs)', color: 'var(--text-secondary)', marginTop: '0.25rem' }}>
|
||||||
|
Gitea Sincronizado
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style={{ display: 'flex', gap: '1rem', justifyContent: 'center' }}>
|
||||||
|
<button onClick={checkHealth} className="touch-button btn-primary">
|
||||||
|
🔄 Probar Conectividad (/health)
|
||||||
|
</button>
|
||||||
|
<button onClick={toggleFullscreen} className="touch-button btn-secondary">
|
||||||
|
📱 Modo Pantalla Completa
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
{/* Pie de Página */}
|
||||||
|
<footer
|
||||||
|
style={{
|
||||||
|
padding: '0.75rem 1.25rem',
|
||||||
|
backgroundColor: 'var(--bg-surface)',
|
||||||
|
borderTop: '1px solid var(--border-subtle)',
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'center',
|
||||||
|
fontSize: 'var(--font-size-xs)',
|
||||||
|
color: 'var(--text-muted)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span>Oemspot OnEverControl • Control de Accesos de Alta Disponibilidad</span>
|
||||||
|
<span>FastAPI + React • v0.1.0-alpha</span>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default App;
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom/client';
|
||||||
|
import App from './App';
|
||||||
|
|
||||||
|
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
||||||
|
<React.StrictMode>
|
||||||
|
<App />
|
||||||
|
</React.StrictMode>
|
||||||
|
);
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
/* ==============================================================================
|
||||||
|
Reset Base y Layout Táctil (100dvh) para Tablets
|
||||||
|
============================================================================== */
|
||||||
|
|
||||||
|
*, *::before, *::after {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
height: 100dvh;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: var(--bg-app);
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-family: var(--font-family);
|
||||||
|
font-size: 16px;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
|
||||||
|
/* Prevenir zoom accidental en tablets */
|
||||||
|
touch-action: manipulation;
|
||||||
|
/* Prevenir recarga por arrastre en Chrome Android */
|
||||||
|
overscroll-behavior-y: contain;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#root {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
height: 100dvh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clases de utilidad táctil */
|
||||||
|
.touch-target {
|
||||||
|
min-height: var(--touch-min-size);
|
||||||
|
min-width: var(--touch-min-size);
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.touch-button {
|
||||||
|
min-height: var(--touch-button-height);
|
||||||
|
padding: 0 1.25rem;
|
||||||
|
border-radius: var(--touch-radius);
|
||||||
|
font-size: var(--font-size-base);
|
||||||
|
font-weight: 600;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.15s ease, transform 0.05s ease;
|
||||||
|
touch-action: manipulation;
|
||||||
|
}
|
||||||
|
|
||||||
|
.touch-button:active {
|
||||||
|
transform: scale(0.98);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background-color: var(--color-primary);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover {
|
||||||
|
background-color: var(--color-primary-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary {
|
||||||
|
background-color: var(--bg-surface-highlight);
|
||||||
|
color: var(--text-primary);
|
||||||
|
border-color: var(--border-strong);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-danger {
|
||||||
|
background-color: var(--color-danger);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-success {
|
||||||
|
background-color: var(--color-success);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Indicadores y Badges */
|
||||||
|
.badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.375rem;
|
||||||
|
padding: 0.25rem 0.625rem;
|
||||||
|
border-radius: 9999px;
|
||||||
|
font-size: var(--font-size-xs);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-success {
|
||||||
|
background-color: var(--color-success-bg);
|
||||||
|
color: var(--color-success);
|
||||||
|
border: 1px solid var(--color-success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-danger {
|
||||||
|
background-color: var(--color-danger-bg);
|
||||||
|
color: var(--color-danger);
|
||||||
|
border: 1px solid var(--color-danger);
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-info {
|
||||||
|
background-color: rgba(56, 189, 248, 0.15);
|
||||||
|
color: var(--color-info);
|
||||||
|
border: 1px solid var(--color-info);
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/* ==============================================================================
|
||||||
|
OnEver Design Tokens (Tokens Semánticos de Diseño)
|
||||||
|
Optimizado para Garitas y Tablets de 4GB RAM (Samsung Tab A9 / A11)
|
||||||
|
============================================================================== */
|
||||||
|
|
||||||
|
:root {
|
||||||
|
/* Paleta Dark Mode (Por defecto en garitas de seguridad) */
|
||||||
|
--bg-app: #0b0f19;
|
||||||
|
--bg-surface: #121826;
|
||||||
|
--bg-surface-elevated: #1a2235;
|
||||||
|
--bg-surface-highlight: #232e48;
|
||||||
|
|
||||||
|
--border-subtle: #232d42;
|
||||||
|
--border-strong: #334155;
|
||||||
|
|
||||||
|
--text-primary: #f8fafc;
|
||||||
|
--text-secondary: #94a3b8;
|
||||||
|
--text-muted: #64748b;
|
||||||
|
|
||||||
|
/* Estados y Semántica */
|
||||||
|
--color-primary: #0284c7;
|
||||||
|
--color-primary-hover: #0369a1;
|
||||||
|
--color-success: #10b981;
|
||||||
|
--color-success-bg: rgba(16, 185, 129, 0.15);
|
||||||
|
--color-danger: #ef4444;
|
||||||
|
--color-danger-bg: rgba(239, 68, 68, 0.15);
|
||||||
|
--color-warning: #f59e0b;
|
||||||
|
--color-warning-bg: rgba(245, 158, 11, 0.15);
|
||||||
|
--color-info: #38bdf8;
|
||||||
|
|
||||||
|
/* Touch Targets y Ergonomía Táctil */
|
||||||
|
--touch-min-size: 48px;
|
||||||
|
--touch-button-height: 52px;
|
||||||
|
--touch-input-height: 50px;
|
||||||
|
--touch-radius: 8px;
|
||||||
|
|
||||||
|
/* Tipografía */
|
||||||
|
--font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||||
|
--font-size-xs: 0.75rem;
|
||||||
|
--font-size-sm: 0.875rem;
|
||||||
|
--font-size-base: 1rem;
|
||||||
|
--font-size-lg: 1.125rem;
|
||||||
|
--font-size-xl: 1.25rem;
|
||||||
|
--font-size-2xl: 1.5rem;
|
||||||
|
|
||||||
|
/* Sombras y elevación */
|
||||||
|
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
|
||||||
|
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Modo Claro Opcional (Para puestos al sol directo) */
|
||||||
|
[data-theme="light"] {
|
||||||
|
--bg-app: #f1f5f9;
|
||||||
|
--bg-surface: #ffffff;
|
||||||
|
--bg-surface-elevated: #f8fafc;
|
||||||
|
--bg-surface-highlight: #e2e8f0;
|
||||||
|
|
||||||
|
--border-subtle: #cbd5e1;
|
||||||
|
--border-strong: #94a3b8;
|
||||||
|
|
||||||
|
--text-primary: #0f172a;
|
||||||
|
--text-secondary: #475569;
|
||||||
|
--text-muted: #64748b;
|
||||||
|
|
||||||
|
--color-primary: #0284c7;
|
||||||
|
--color-primary-hover: #0369a1;
|
||||||
|
--color-success: #059669;
|
||||||
|
--color-success-bg: rgba(5, 150, 105, 0.1);
|
||||||
|
--color-danger: #dc2626;
|
||||||
|
--color-danger-bg: rgba(220, 38, 38, 0.1);
|
||||||
|
--color-warning: #d97706;
|
||||||
|
--color-warning-bg: rgba(217, 119, 6, 0.1);
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2020",
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||||
|
"module": "ESNext",
|
||||||
|
"skipLibCheck": true,
|
||||||
|
|
||||||
|
/* Bundler mode */
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowImportingTsExtensions": false,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
|
||||||
|
/* Linting */
|
||||||
|
"strict": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"noFallthroughCasesInSwitch": true
|
||||||
|
},
|
||||||
|
"include": ["src"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import { defineConfig } from 'vite';
|
||||||
|
import react from '@vitejs/plugin-react';
|
||||||
|
|
||||||
|
// https://vitejs.dev/config/
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [react()],
|
||||||
|
server: {
|
||||||
|
host: '0.0.0.0', // Permite acceso desde tablets Samsung en la LAN
|
||||||
|
port: 5173,
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: 'http://localhost:8000',
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
'/health': {
|
||||||
|
target: 'http://localhost:8000',
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
'/ws': {
|
||||||
|
target: 'ws://localhost:8000',
|
||||||
|
ws: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
build: {
|
||||||
|
target: 'es2020',
|
||||||
|
sourcemap: false,
|
||||||
|
chunkSizeWarningLimit: 600,
|
||||||
|
rollupOptions: {
|
||||||
|
output: {
|
||||||
|
manualChunks: {
|
||||||
|
vendor: ['react', 'react-dom'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
# Nginx configuration for OnEverControl reverse proxy and static assets
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
# Compresión Gzip para clientes móviles y tablets de 4GB RAM
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_min_length 1024;
|
||||||
|
gzip_proxied expired no-cache no-store private auth;
|
||||||
|
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/json;
|
||||||
|
gzip_disable "MSIE [1-6]\.";
|
||||||
|
|
||||||
|
# Estáticos de la aplicación React SPA
|
||||||
|
location / {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html index.htm;
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# API Proxy hacia FastAPI
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://backend:8000;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Endpoint de salud y Swagger
|
||||||
|
location ~ ^/(health|docs|openapi.json) {
|
||||||
|
proxy_pass http://backend:8000;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
# WebSockets en vivo para garitas
|
||||||
|
location /ws/ {
|
||||||
|
proxy_pass http://backend:8000;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_read_timeout 86400s;
|
||||||
|
proxy_send_timeout 86400s;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=OnEverControl Web API (FastAPI)
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=root
|
||||||
|
WorkingDirectory=/opt/onevercontrol/backend
|
||||||
|
EnvironmentFile=/opt/onevercontrol/.env
|
||||||
|
ExecStart=/opt/onevercontrol/backend/venv/bin/uvicorn app.main:app --host 0.0.0.0 --port 8000
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
|
KillMode=process
|
||||||
|
StandardOutput=journal
|
||||||
|
StandardError=journal
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# ==============================================================================
|
||||||
|
# Script de aprovisionamiento para Contenedores LXC (Debian / Ubuntu / Proxmox)
|
||||||
|
# ==============================================================================
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "=== [1/4] Actualizando repositorios e instalando paquetes del sistema ==="
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
python3 \
|
||||||
|
python3-venv \
|
||||||
|
python3-pip \
|
||||||
|
freetds-dev \
|
||||||
|
freetds-bin \
|
||||||
|
build-essential \
|
||||||
|
nginx \
|
||||||
|
curl \
|
||||||
|
git
|
||||||
|
|
||||||
|
APP_DIR="/opt/onevercontrol"
|
||||||
|
echo "=== [2/4] Preparando directorio de aplicacion en $APP_DIR ==="
|
||||||
|
mkdir -p "$APP_DIR"
|
||||||
|
|
||||||
|
echo "=== [3/4] Creando entorno virtual Python e instalando dependencias ==="
|
||||||
|
python3 -m venv "$APP_DIR/backend/venv"
|
||||||
|
"$APP_DIR/backend/venv/bin/pip" install --upgrade pip
|
||||||
|
if [ -f "$APP_DIR/backend/requirements.txt" ]; then
|
||||||
|
"$APP_DIR/backend/venv/bin/pip" install -r "$APP_DIR/backend/requirements.txt"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=== [4/4] Instalando servicio systemd ==="
|
||||||
|
cp "$(dirname "$0")/onevercontrol.service" /etc/systemd/system/
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable onevercontrol.service
|
||||||
|
|
||||||
|
echo "====================================================================="
|
||||||
|
echo " Aprovisionamiento de LXC completado con exito."
|
||||||
|
echo " Para iniciar: systemctl start onevercontrol"
|
||||||
|
echo " Para ver logs: journalctl -u onevercontrol -f"
|
||||||
|
echo "====================================================================="
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# ==============================================================================
|
||||||
|
# Script de Diagnóstico de Conexión a SQL Server (videoman)
|
||||||
|
# Compatible con Windows 10/11, LXC (FreeTDS) y Docker
|
||||||
|
# ==============================================================================
|
||||||
|
import sys
|
||||||
|
import platform
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Agregar directorio backend al path para importar configuración
|
||||||
|
BACKEND_DIR = Path(__file__).resolve().parent.parent / "backend"
|
||||||
|
if str(BACKEND_DIR) not in sys.path:
|
||||||
|
sys.path.insert(0, str(BACKEND_DIR))
|
||||||
|
|
||||||
|
try:
|
||||||
|
from app.core.config import settings
|
||||||
|
from app.__version__ import __version__
|
||||||
|
except ImportError as e:
|
||||||
|
print(f"[ERROR] No se pudo importar la configuracion de backend: {e}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_sql_connection():
|
||||||
|
print("=" * 70)
|
||||||
|
print(f" Diagnostico de Conexion SQL Server - OnEverControl v{__version__}")
|
||||||
|
print("=" * 70)
|
||||||
|
print(f"Sistema Operativo : {platform.system()} {platform.release()} ({platform.machine()})")
|
||||||
|
print(f"Python : {platform.python_version()}")
|
||||||
|
print(f"Servidor Destino : {settings.DB_SERVER}:{settings.DB_PORT}")
|
||||||
|
print(f"Base de Datos : {settings.DB_NAME}")
|
||||||
|
print(f"Usuario : {settings.DB_USER}")
|
||||||
|
print(f"Charset : {settings.DB_CHARSET}")
|
||||||
|
print("-" * 70)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import pymssql
|
||||||
|
except ImportError:
|
||||||
|
print("[ERROR] pymssql no esta instalado en este entorno.")
|
||||||
|
print("Instalelo con: pip install pymssql")
|
||||||
|
return False
|
||||||
|
|
||||||
|
print(f"[INFO] Intentando conectar a '{settings.DB_SERVER}'...")
|
||||||
|
|
||||||
|
try:
|
||||||
|
conn = pymssql.connect(
|
||||||
|
server=settings.DB_SERVER,
|
||||||
|
port=settings.DB_PORT,
|
||||||
|
user=settings.DB_USER,
|
||||||
|
password=settings.DB_PASSWORD,
|
||||||
|
database=settings.DB_NAME,
|
||||||
|
charset=settings.DB_CHARSET,
|
||||||
|
login_timeout=settings.DB_TIMEOUT,
|
||||||
|
timeout=settings.DB_TIMEOUT,
|
||||||
|
)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute("SELECT @@VERSION, DB_NAME(), GETDATE();")
|
||||||
|
row = cursor.fetchone()
|
||||||
|
|
||||||
|
print("[OK] CONEXION EXITOSA!")
|
||||||
|
print("-" * 70)
|
||||||
|
print(f"Base de Datos Activa: {row[1]}")
|
||||||
|
print(f"Fecha/Hora Servidor : {row[2]}")
|
||||||
|
print(f"Version SQL Server : {row[0].splitlines()[0]}")
|
||||||
|
print("=" * 70)
|
||||||
|
|
||||||
|
cursor.close()
|
||||||
|
conn.close()
|
||||||
|
return True
|
||||||
|
|
||||||
|
except pymssql.OperationalError as err:
|
||||||
|
print("[ERROR] Fallo operacional al conectar con SQL Server:")
|
||||||
|
print(f" -> {err}")
|
||||||
|
print("-" * 70)
|
||||||
|
print("POSIBLES CAUSAS Y SOLUCIONES:")
|
||||||
|
print(" 1. Verifique que el servicio SQL Server este en ejecucion.")
|
||||||
|
print(" 2. En SQL Server Configuration Manager, confirme que TCP/IP este HABILITADO.")
|
||||||
|
print(" 3. Verifique que el firewall de Windows permita el puerto 1433 TCP.")
|
||||||
|
print(" 4. Si usa nombre de instancia (ej: localhost\\SQLEXPRESS), verifique que SQL Browser este activo.")
|
||||||
|
print(" 5. Revise que las credenciales en .env sean correctas.")
|
||||||
|
print("=" * 70)
|
||||||
|
return False
|
||||||
|
except Exception as ex:
|
||||||
|
print(f"[ERROR] Error inesperado: {ex}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
success = test_sql_connection()
|
||||||
|
sys.exit(0 if success else 1)
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
echo =====================================================================
|
||||||
|
echo OnEverControl - Instalador de Servicio de Windows (NSSM)
|
||||||
|
echo =====================================================================
|
||||||
|
|
||||||
|
net session >nul 2>&1
|
||||||
|
if %errorLevel% neq 0 (
|
||||||
|
echo [ERROR] Este script requiere privilegios de Administrador.
|
||||||
|
echo Por favor ejecute como Administrador.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
set SERVICE_NAME=OnEverControl
|
||||||
|
set APP_DIR=%~dp0..\..\backend
|
||||||
|
set PYTHON_EXE=%APP_DIR%\venv\Scripts\python.exe
|
||||||
|
set UVICORN_EXE=%APP_DIR%\venv\Scripts\uvicorn.exe
|
||||||
|
|
||||||
|
if not exist "%UVICORN_EXE%" (
|
||||||
|
echo [ERROR] No se encontro el entorno virtual en: %APP_DIR%\venv
|
||||||
|
echo Cree el venv ejecutando en backend: python -m venv venv ^&^& pip install -r requirements.txt
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
where nssm >nul 2>&1
|
||||||
|
if %errorLevel% neq 0 (
|
||||||
|
echo [AVISO] NSSM no fue encontrado en PATH. Descarguelo de https://nssm.cc/ y coloquelo en PATH o en esta carpeta.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo [INFO] Instalando servicio %SERVICE_NAME%...
|
||||||
|
nssm install %SERVICE_NAME% "%UVICORN_EXE%" "app.main:app --host 0.0.0.0 --port 8000"
|
||||||
|
nssm set %SERVICE_NAME% AppDirectory "%APP_DIR%"
|
||||||
|
nssm set %SERVICE_NAME% Description "Servidor Web OnEverControl Puesto de Control"
|
||||||
|
nssm set %SERVICE_NAME% Start SERVICE_AUTO_START
|
||||||
|
nssm set %SERVICE_NAME% AppStdout "%APP_DIR%\logs\service.log"
|
||||||
|
nssm set %SERVICE_NAME% AppStderr "%APP_DIR%\logs\service_error.log"
|
||||||
|
|
||||||
|
echo [INFO] Iniciando servicio...
|
||||||
|
nssm start %SERVICE_NAME%
|
||||||
|
|
||||||
|
echo =====================================================================
|
||||||
|
echo Servicio instalado con exito. Estado actual:
|
||||||
|
echo =====================================================================
|
||||||
|
nssm status %SERVICE_NAME%
|
||||||
|
pause
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
echo =====================================================================
|
||||||
|
echo Iniciando OnEverControl en modo nativo Windows
|
||||||
|
echo =====================================================================
|
||||||
|
|
||||||
|
cd /d "%~dp0..\..\backend"
|
||||||
|
|
||||||
|
if not exist "venv\Scripts\activate.bat" (
|
||||||
|
echo [INFO] Creando entorno virtual Python...
|
||||||
|
python -m venv venv
|
||||||
|
call venv\Scripts\activate.bat
|
||||||
|
pip install -r requirements.txt
|
||||||
|
) else (
|
||||||
|
call venv\Scripts\activate.bat
|
||||||
|
)
|
||||||
|
|
||||||
|
echo [INFO] Levantando servidor Uvicorn en http://0.0.0.0:8000 ...
|
||||||
|
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
|
||||||
|
pause
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
# Plan Técnico — Spec 000: Arquitectura Base y Scaffolding (Fase 1)
|
||||||
|
|
||||||
|
## 1. Archivos y Responsabilidades
|
||||||
|
|
||||||
|
### Configuración Raíz y Despliegue Multiplataforma
|
||||||
|
- `OnEverControl/.env.example`: Plantilla unificada de variables de entorno (SQL Server, JWT, CORS, puertos).
|
||||||
|
- `OnEverControl/docker-compose.yml`: Orquestación multicontenedor (FastAPI + Nginx reverse proxy y estáticos de React).
|
||||||
|
- `OnEverControl/scripts/test_sql_connection.py`: Script de diagnóstico y conectividad hacia SQL Server `videoman`.
|
||||||
|
- `OnEverControl/scripts/windows/install_service.bat`: Script de registro del servicio en Windows 10/11 vía NSSM.
|
||||||
|
- `OnEverControl/scripts/windows/start_native.bat`: Script de inicio rápido bare-metal en garita.
|
||||||
|
- `OnEverControl/scripts/lxc/setup_lxc.sh`: Instalador de dependencias Linux (Python, FreeTDS, Nginx) para Proxmox/Debian.
|
||||||
|
- `OnEverControl/scripts/lxc/onevercontrol.service`: Unit file para `systemd`.
|
||||||
|
|
||||||
|
### Backend (FastAPI / Python)
|
||||||
|
- `backend/pyproject.toml` / `backend/requirements.txt`: Dependencias (`fastapi`, `uvicorn[standard]`, `pydantic>=2.0`, `pydantic-settings`, `pymssql`, `pytest`, `httpx`).
|
||||||
|
- `backend/app/__version__.py`: Definición de versión `0.1.0-alpha`.
|
||||||
|
- `backend/app/core/config.py`: Clase `Settings` de Pydantic Settings para cargar `.env` de forma tipada.
|
||||||
|
- `backend/app/main.py`: Instancia FastAPI, configuración de CORS, compresión GZip y router base con `/health`.
|
||||||
|
- `backend/app/api/v1/router.py`: Agregador de rutas v1.
|
||||||
|
- `backend/tests/test_health.py`: Pruebas de endpoint `/health` y metadatos de versión.
|
||||||
|
|
||||||
|
### Frontend (React + TypeScript + Vite)
|
||||||
|
- `frontend/package.json`: Dependencias (`react`, `react-dom`, `@types/react`, `@types/react-dom`, `vite`, `typescript`). Versión `0.1.0-alpha`.
|
||||||
|
- `frontend/tsconfig.json`: Configuración estricta de TypeScript.
|
||||||
|
- `frontend/vite.config.ts`: Configuración de Vite con base, proxy dev hacia backend `http://localhost:8000` y build optimizado.
|
||||||
|
- `frontend/index.html`: Entrypoint HTML5 táctil con meta tags para PWA, viewport dinámico y prevención de zoom accidental.
|
||||||
|
- `frontend/src/main.tsx`: Punto de montaje de React.
|
||||||
|
- `frontend/src/App.tsx`: Shell base táctil con indicador de estado del sistema y selector de modo oscuro.
|
||||||
|
- `frontend/src/styles/tokens.css`: Variables CSS del OnEver Design System (colores semánticos Dark/Light, contrastes garita).
|
||||||
|
- `frontend/src/styles/base.css`: Reset, `100dvh`, utilidades táctiles (touch targets >= 48px).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Decisiones Técnicas Justificadas
|
||||||
|
|
||||||
|
1. **Uso de `pydantic-settings` para la Configuración:**
|
||||||
|
- *Alternativa descartada:* `os.getenv` directo en múltiples módulos.
|
||||||
|
- *Motivo:* `pydantic-settings` valida tipos, formatos de host/puerto y valores por defecto en tiempo de arranque, fallando rápido si falta una variable crítica.
|
||||||
|
2. **Estructura Estática de React servida vía Nginx o FastAPI:**
|
||||||
|
- *Alternativa descartada:* Servidor Node.js SSR en tiempo de ejecución.
|
||||||
|
- *Motivo:* La compilación estática SPA consume cero CPU en el servidor de estáticos y mantiene el consumo de memoria en la tablet Samsung Galaxy Tab A9/A11 en menos de 50 MB de RAM.
|
||||||
|
3. **Manejo Centralizado de Conectividad con FreeTDS / `pymssql`:**
|
||||||
|
- *Alternativa descartada:* Usar pyodbc con drivers ODBC propietarios de Microsoft.
|
||||||
|
- *Motivo:* FreeTDS y `pymssql` son de código abierto, ultralivianos y se instalan limpiamente en Windows, Alpine, Debian y Proxmox LXC sin dependencias binarias pesadas.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Estrategia de Pruebas y Validación
|
||||||
|
- **Backend:**
|
||||||
|
- Ejecutar `pytest backend/tests/test_health.py` comprobando código 200 y JSON estructurado.
|
||||||
|
- **Frontend:**
|
||||||
|
- Ejecutar `npm run build` comprobando generación de bundle limpio en `dist/` sin advertencias de tipos.
|
||||||
|
- **Herramientas de Diagnóstico:**
|
||||||
|
- Ejecutar `python scripts/test_sql_connection.py` para validar parsing de `.env`.
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
# Especificación — Spec 000: Arquitectura Base y Scaffolding (Fase 1)
|
||||||
|
|
||||||
|
## 1. Contexto y Objetivo
|
||||||
|
Establecer la estructura fundacional, dependencias, entornos de ejecución y esqueletos funcionales del **Backend (FastAPI + Pydantic v2)** y **Frontend (React + TypeScript + Vite)** para `OnEverControl`.
|
||||||
|
El objetivo es contar con un entorno de desarrollo reproducible, verificable y agnóstico al sistema operativo (Windows 10/11, LXC y Docker), con verificación de salud (`/health`), conectividad a SQL Server `videoman` y diseño base Touch-First para tablets Samsung Galaxy Tab A9/A11 (4GB RAM), versionado en `v0.1.0-alpha`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Usuarios / Actores
|
||||||
|
- **Desarrollador / Agente de IA:** Necesita un entorno estructurado, comandos reproducibles de tests y compilación limpia sin errores de dependencias.
|
||||||
|
- **Administrador de Infraestructura:** Requiere opciones de despliegue directo en Windows (servicio), contenedores ligeros LXC en Proxmox o Docker Compose.
|
||||||
|
- **Operador de Garita (Cliente Web):** Accede a la interfaz web táctil base desde la tablet en la red local.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Historias de Usuario
|
||||||
|
- **HU-0.1:** *Como desarrollador*, quiero levantar el backend con FastAPI y verificar que `/health` responda `status: ok` y `/docs` exponga la documentación OpenAPI para validar que la API está operativa.
|
||||||
|
- **HU-0.2:** *Como desarrollador*, quiero ejecutar un script de verificación de base de datos (`test_sql_connection.py`) para confirmar la conectividad con SQL Server `videoman` tanto en Windows como en Linux.
|
||||||
|
- **HU-0.3:** *Como desarrollador*, quiero levantar la aplicación frontend con Vite y visualizar el shell táctil responsive a pantalla completa (`100dvh`) en emulador de tablet.
|
||||||
|
- **HU-0.4:** *Como administrador de infraestructura*, quiero disponer de configuración Docker Compose y scripts para Windows y LXC para desplegar el sistema según los recursos del predio.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Requisitos Funcionales (Sintaxis EARS)
|
||||||
|
|
||||||
|
### Ubicuo (Comportamiento Permanente)
|
||||||
|
- **RF-0.1:** EL SISTEMA mantendrá la versión semántica sincronizada (`v0.1.0-alpha`) en `backend/app/__version__.py` y `frontend/package.json`.
|
||||||
|
- **RF-0.2:** EL SISTEMA utilizará rutas relativas o resueltas mediante `pathlib.Path`, prohibiendo contrabarras hardcodeadas para garantizar portabilidad en Windows, LXC y Docker.
|
||||||
|
|
||||||
|
### Con Evento
|
||||||
|
- **CUANDO** el cliente realice una petición `GET /health`, EL SISTEMA retornará código `200 OK` con un JSON que incluya `{"status": "ok", "version": "0.1.0-alpha", "timestamp": "<ISO-8601>"}`.
|
||||||
|
- **CUANDO** el cliente acceda a `GET /docs`, EL SISTEMA servirá la interfaz interactiva de Swagger UI de OpenAPI.
|
||||||
|
- **CUANDO** se ejecute `scripts/test_sql_connection.py`, EL SISTEMA intentará conectarse a SQL Server `videoman` usando las variables de entorno de `.env` y reportará si la conexión fue exitosa o el motivo exacto del fallo.
|
||||||
|
|
||||||
|
### Con Condición No Deseada
|
||||||
|
- **SI** las credenciales o el host de SQL Server en `.env` son inalcanzables, ENTONCES EL SISTEMA reportará un mensaje claro de diagnóstico sin generar caídas silenciosas ni excepciones no controladas.
|
||||||
|
- **SI** se produce una petición con un endpoint no existente, ENTONCES EL SISTEMA responderá un error 404 estandarizado en formato JSON.
|
||||||
|
|
||||||
|
### Con Estado
|
||||||
|
- **MIENTRAS** la aplicación frontend de React esté abierta en una tablet táctil, EL SISTEMA mantendrá un contenedor raíz con altura fija de viewport dinámico `100dvh`, impidiendo que el teclado virtual tape las acciones principales.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Requisitos No Funcionales
|
||||||
|
- **Rendimiento Backend:** Tiempo de respuesta de `/health` inferior a 5 ms en red local.
|
||||||
|
- **Huella de Memoria Frontend:** Compilación estática optimizada de React con Vite con bundle gzip < 150 KB para operar fluidamente en tablets con 4 GB de RAM.
|
||||||
|
- **Portabilidad:** Compatibilidad verificada con Python 3.11/3.12 y Node.js 20+.
|
||||||
|
- **Touch-First:** Hoja de estilos con variables semánticas (Design Tokens de OnEver), clases base para controles >= 48px y soporte para gestos táctiles sin zoom accidental.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. Fuera de Alcance (Para esta fase)
|
||||||
|
- Endpoints de autenticación JWT de negocio y login (pertenecen a Spec 001).
|
||||||
|
- Lectura de cámara de DNI y decodificación de código de barras (pertenece a Spec 002).
|
||||||
|
- Encolado de tramas a barreras físicas en `pdtmdl` (pertenece a Fase 4).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 7. Criterios de Finalización (DoD)
|
||||||
|
1. `pytest` en `backend/` ejecuta tests unitarios de `/health` y configuración en verde.
|
||||||
|
2. `npm run build` en `frontend/` compila la SPA de React con TypeScript sin errores ni advertencias.
|
||||||
|
3. `.env.example`, `docker-compose.yml`, scripts para Windows (`scripts/windows/`) y LXC (`scripts/lxc/`) creados y documentados.
|
||||||
|
4. Versión sincronizada `v0.1.0-alpha` en backend, frontend y registrada en `CHANGELOG.md`.
|
||||||
|
5. `MEMORY.md` actualizado con el cierre de las tareas.
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# Tareas — Spec 000: Arquitectura Base y Scaffolding (Fase 1)
|
||||||
|
|
||||||
|
- [x] **T1. Configuración de Entorno y Scripts Multiplataforma (Windows, LXC, Docker).** RF-0.1, RF-0.2
|
||||||
|
- Hecho cuando: Existan `.env.example`, `docker-compose.yml`, `scripts/windows/` y `scripts/lxc/` listos para ser configurados.
|
||||||
|
- [x] **T2. Dependencias de Backend y Configuración Tipada (Pydantic Settings).** RF-0.1, RF-0.2
|
||||||
|
- Hecho cuando: `backend/requirements.txt`, `backend/app/__version__.py` (v0.1.0-alpha) y `backend/app/core/config.py` carguen variables de forma tipada sin fallos.
|
||||||
|
- [x] **T3. Endpoint de Salud `/health` y Middleware FastAPI con Pruebas Unitarias.** RF-0.1
|
||||||
|
- Hecho cuando: `backend/app/main.py` levante la aplicación FastAPI con CORS y `pytest backend/tests/test_health.py` pase en verde con respuesta 200 OK y metadatos de versión.
|
||||||
|
- [x] **T4. Script de Verificación de Conectividad SQL Server (`test_sql_connection.py`).** RF-0.2
|
||||||
|
- Hecho cuando: El script intente conectarse usando los parámetros de configuración y muestre diagnóstico claro tanto en Windows como en Linux.
|
||||||
|
- [x] **T5. Scaffolding del Frontend en React + TypeScript + Vite con Layout Touch-First.** RF-0.1, RF-0.2
|
||||||
|
- Hecho cuando: `frontend/` contenga `package.json` (v0.1.0-alpha), `vite.config.ts`, `tokens.css`, `base.css` (`100dvh`), `App.tsx` y compile limpiamente con `npm run build`.
|
||||||
|
- [x] **T6. Validación Integral de Fase 1 y Actualización de Memoria.** RF-0.1, RF-0.2
|
||||||
|
- Hecho cuando: Se ejecuten los tests del backend, el build del frontend, se verifique la versión en `CHANGELOG.md` y se actualice `MEMORY.md` para el usuario.
|
||||||
Reference in New Issue
Block a user