Python API Service Integration
To handle heavy file parsing, complex Python libraries (like python-docx or ML utilities), and document generation, the Spring Boot application delegates specific tasks to an external FastAPI Python service.
Integration Architecture
- Service:
PythonApiService - Method: HTTP POST via Spring's
RestTemplateorWebClient. - Target: The endpoint configured via
PYTHON_API_URL(e.g.,http://python-service:7002).
Communication Flow
- Request Formulation:
AiServiceImplcallsPythonApiService.generate(), constructing aPythonGenerateRequestDTO containing files, parameters, and the base prompt. - Execution: The HTTP call is made with a strict 5-minute timeout.
- Response Handling: The Python service replies with a
PythonGenerateResponsecontaining the structured JSON or base64 encoded document files, which Spring Boot then relays to the frontend.
Network Routing in Docker
In local development, PYTHON_API_URL might be http://localhost:7002. In production via docker-compose, Docker's internal DNS routing applies, so the URL must be explicitly set to http://python-service:7002.