- Frontend: React (Create React App v5) with Material UI. Ships as static assets served by nginx in production.
- Backend: FastAPI application with JWT authentication, Postgres persistence (SQLAlchemy ORM), and PDF processing that renders each page to PNG (Poppler/pdf2image) before prompting an Ollama vision-capable model for structured LaTeX output.
- Database: PostgreSQL 13 running in a container.
- Background Processing: Synchronous for now; upload requests perform PDF extraction inline.
- Storage: Converted page outputs stored in Postgres. Uploaded PDFs are streamed to temporary files during processing and removed immediately afterwards.
- User signs in and obtains a short-lived JWT stored in
localStorage. - Dashboard loads conversion sessions via authenticated requests to
/conversions. - Uploading a PDF streams the file to a temporary location, renders each page to PNG, sends the image plus contextual instructions to Ollama, and persists the structured LaTeX response alongside the raw extracted text.
- The frontend caches session metadata locally while fetching conversion outputs from the API on demand.
- Deleting a conversion removes the database record and all associated page outputs.
POST /register— create a new user (requires admin activation).POST /token— obtain an access token.GET /conversions— list conversion sessions for the current user.GET /conversions/{session_id}— detailed view with page outputs.POST /upload-pdf/— upload a PDF for conversion (requiresfileandmodel_nameform-data fields).DELETE /conversions/{session_id}— remove a session and its page outputs.GET /ollama/models— list available Ollama models.
Detailed schema definitions live in backend/app/schemas.py.
DATABASE_URL— SQLAlchemy connection string (docker-compose provides one).SECRET_KEY— JWT signing secret (set in docker-compose for production).OLLAMA_API_URL— base URL for the Ollama service.
Uploaded files are stored only temporarily in backend/uploads/ during processing and removed immediately afterwards. Each conversion now stores the following per-page payload in Postgres:
{
"page_title": "...",
"sub_heading": "...",
"page_text": "...",
"equations": {
"1": {"latex": "...", "text": "..."}
},
"source_text": "..."
}OLLAMA_TIMEOUT_SECONDSgoverns how long the backend waits for each Ollama request. Values<= 0disable the timeout to accommodate large PDFs; otherwise use seconds.- nginx (
frontend/nginx.conf) mirrors the timeout window so the reverse proxy doesn’t cut off long-running requests first.
- Frontend:
npm test(Jest). Note that Create React App's Jest configuration needs a transformer forreact-router-dom@7ESM modules before tests can run successfully under Node 18/19. - Frontend Build:
npm run build(used by Docker image). - Backend:
python -m compileall appprovides a quick syntax check. Add pytest-based suites as the service grows.
clarityconvertor-backend— FastAPI app + gunicorn/uvicorn (dev server). Mounts the source tree for live reload during development.clarityconvertor-frontend— nginx serving compiled React assets.postgres:13— database with persistent volumepostgres_data.
Rebuild images when dependencies change:
docker-compose build- The backend seeds an admin user (
lakshay/1312) on first startup if none exists. - If you relocate the backend service, update the frontend API base URLs (currently default to
http://localhost:8000). Parameterize them using environment variables or.envfiles for multi-environment deployments. - Poppler is required locally for pdf2image; when running in Docker the backend image installs
poppler-utilsautomatically.