Merge pull request 'feat: implement gateway service and add font extraction validation tests' (#79) from azeem into docker

Reviewed-on: https://gitea.maskantech.in/gitea_admin/pdf/pulls/79
This commit is contained in:
azeem
2026-07-23 11:33:16 +00:00
10 changed files with 17 additions and 16 deletions
Binary file not shown.
+4 -4
View File
@@ -9,13 +9,13 @@ services:
environment: environment:
PDFENGINE_ENVIRONMENT: dev PDFENGINE_ENVIRONMENT: dev
PDFENGINE_ENGINE_AVAILABLE: "true" PDFENGINE_ENGINE_AVAILABLE: "true"
PORT: 8000 PORT: 8765
ports: ports:
- "8000:8000" - "8765:8765"
volumes: volumes:
- ./gateway:/home/app - ./gateway:/home/app
healthcheck: healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health').read()" ] test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8765/health').read()" ]
interval: 20s interval: 20s
timeout: 5s timeout: 5s
retries: 5 retries: 5
@@ -30,7 +30,7 @@ services:
image: pdf-engine-frontend:dev image: pdf-engine-frontend:dev
container_name: pdf-engine-frontend container_name: pdf-engine-frontend
environment: environment:
VITE_GATEWAY_URL: http://localhost:8000 VITE_GATEWAY_URL: http://localhost:8765
ports: ports:
- "5173:5173" - "5173:5173"
volumes: volumes:
+1
View File
@@ -0,0 +1 @@
VITE_GATEWAY_URL=http://127.0.0.1:8765
+1 -1
View File
@@ -333,7 +333,7 @@ class GatewayService {
public baseUrl: string; public baseUrl: string;
constructor() { constructor() {
this.baseUrl = import.meta.env.VITE_GATEWAY_URL || 'http://127.0.0.1:8000'; this.baseUrl = import.meta.env.VITE_GATEWAY_URL as string;
} }
async getHealth(): Promise<{ status: string; version: string; engine_available: boolean }> { async getHealth(): Promise<{ status: string; version: string; engine_available: boolean }> {
+3 -3
View File
@@ -85,7 +85,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \ PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \ PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \
PORT=8000 PORT=8765
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
@@ -114,6 +114,6 @@ COPY gateway/tests ./tests
RUN chown -R app:app /home/app RUN chown -R app:app /home/app
USER app USER app
EXPOSE 8000 EXPOSE 8765
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8765"]
+4 -4
View File
@@ -59,7 +59,7 @@ Run the service:
Using the startup script (Windows): Using the startup script (Windows):
```powershell ```powershell
# Default port (8000) # Default port (8765)
powershell -File scripts/start_gateway.ps1 powershell -File scripts/start_gateway.ps1
# Custom port (e.g. 8080) # Custom port (e.g. 8080)
@@ -68,7 +68,7 @@ powershell -File scripts/start_gateway.ps1 -Port 8080
Or run directly via uvicorn (cross-platform): Or run directly via uvicorn (cross-platform):
```sh ```sh
# Default port (8000) # Default port (8765)
uvicorn app.main:app --reload uvicorn app.main:app --reload
# Custom port (e.g. 8080) # Custom port (e.g. 8080)
@@ -100,8 +100,8 @@ Additionally, the gateway startup scripts and frontend configuration support:
| Var | Default | Meaning | | Var | Default | Meaning |
|--------------------|-------------------------|--------------------------------------------------| |--------------------|-------------------------|--------------------------------------------------|
| `PORT` | `8000` | Gateway listening port (used by `start_gateway.ps1`). | | `PORT` | `8765` | Gateway listening port (used by `start_gateway.ps1`). |
| `VITE_GATEWAY_URL` | `http://127.0.0.1:8000` | URL of the gateway API (used by the frontend). | | `VITE_GATEWAY_URL` | `http://127.0.0.1:8765` | URL of the gateway API (used by the frontend). |
A `.env` file in `gateway/` is auto-loaded if present (it is git-ignored A `.env` file in `gateway/` is auto-loaded if present (it is git-ignored
via the repo-wide `.venv/` and Python rules — add `.env` to your local via the repo-wide `.venv/` and Python rules — add `.env` to your local
+1 -1
View File
@@ -8,7 +8,7 @@ import urllib.request
sys.path.insert(0, "gateway") sys.path.insert(0, "gateway")
BASE = os.environ.get("GATEWAY_URL", "http://localhost:8000") BASE = os.environ.get("GATEWAY_URL", "http://localhost:8765")
def http_get(url): def http_get(url):
+1 -1
View File
@@ -12,7 +12,7 @@ import time
import httpx import httpx
BASE_URL = os.environ.get("GATEWAY_URL", "http://localhost:8000") BASE_URL = os.environ.get("GATEWAY_URL", "http://localhost:8765")
CORPUS_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "corpus", "fonts")) CORPUS_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "corpus", "fonts"))
TARGET_PDFS = [ TARGET_PDFS = [
+1 -1
View File
@@ -1,6 +1,6 @@
================================================================================ ================================================================================
FONT EXTRACTION API VALIDATION FONT EXTRACTION API VALIDATION
Server: http://localhost:8000 Server: http://localhost:8765
Corpus: C:\Users\Maskan\Desktop\pdf_editor\pdf\corpus\fonts Corpus: C:\Users\Maskan\Desktop\pdf_editor\pdf\corpus\fonts
Timestamp: 2026-06-02 12:36:47 Timestamp: 2026-06-02 12:36:47
================================================================================ ================================================================================
+1 -1
View File
@@ -10,7 +10,7 @@ if ($Port -le 0) {
if ($envPort) { if ($envPort) {
$Port = $envPort $Port = $envPort
} else { } else {
$Port = 8000 $Port = 8765
} }
} }