Files
IPSExtractor/docs/plan_pruebas/sections/02_arquitectura.tex
T

57 lines
2.4 KiB
TeX

\chapter{Arquitectura bajo prueba}
\label{ch:arquitectura}
\section{Vista de componentes}
El host solo expone el Gateway en el puerto \textbf{8189}. El resto de APIs viven en la red Docker. El agent del bot corre en PCs externas y se comunica por HTTP + PutObject a MinIO.
\input{diagrams/arquitectura}
\section{Inventario de componentes}
\begin{table}[ht]
\centering
\begin{tabular}{@{}llp{5.8cm}@{}}
\toprule
\textbf{Componente} & \textbf{Puerto} & \textbf{Responsabilidad} \\
\midrule
\texttt{api\_gateway} & Host 8189 & Proxy HTTP, health agregado, CORS \\
\texttt{extraction} & 8001 & Jobs/tasks, LLM, ingest PDFs \\
\texttt{worker} (ARQ) & --- & Procesamiento async v\'ia Redis \\
\texttt{cleaning} & 8002 & Limpieza CSV / reglas \\
\texttt{count-api} & 8080 & OCR + ONNX, stateless \\
\texttt{bot-descarga} & 8200 & Control remoto de bots \\
PostgreSQL 16 & 5432 & Persistencia compartida \\
Redis 7 & 6379 & Cola ARQ + rate limiter \\
Desktop & local & Cliente Electron/React \\
Agent bot & local PC & Selenium + MinIO upload \\
MinIO/S3 & externo & Excel y PDFs del bot \\
\bottomrule
\end{tabular}
\caption{Componentes del sistema bajo prueba.}
\end{table}
\section{Flujo cr\'itico: bot de descarga}
\input{diagrams/flujo_bot}
Secuencia resumida:
\begin{enumerate}
\item Agent: \texttt{register} + loop \texttt{heartbeat} / \texttt{claim\_pending} ($\sim$8\,s).
\item Desktop: \texttt{POST /bot-descarga/jobs} (Excel, \texttt{worker\_id}, \texttt{job\_id}).
\item API: valida job padre y worker online; sube Excel a MinIO; estado \texttt{pending}.
\item Agent: claim $\rightarrow$ \texttt{RUNNING}; descarga Excel; Selenium/Imaging; PutObject PDFs.
\item Eventos \texttt{POST /events}; cierre \texttt{PATCH /jobs/\{id\}} (\texttt{completed}/\texttt{failed}).
\end{enumerate}
Layout MinIO:
\begin{lstlisting}[language={},caption={Prefijos MinIO del bot}]
uploads/{download_job_id}/input.xlsx
downloads/{download_job_id}/{nit}/{radicado}.pdf
downloads/{download_job_id}/_manifest.json
\end{lstlisting}
\section{Otros flujos de negocio}
\begin{description}
\item[Conteo] Desktop $\rightarrow$ \texttt{POST /count/v1/count} $\rightarrow$ \texttt{POST /count-jobs} $\rightarrow$ validaci\'on humana.
\item[Extracci\'on] \texttt{from-count} o ingest de PDFs $\rightarrow$ workers ARQ $\rightarrow$ filas en BD.
\item[Limpieza] Job cleaning desde \texttt{extraction\_batch\_id} o CSV upload.
\end{description}