How kuju29/textphantomocr_overlay works
TextPhantomOCR Overlay is a browser extension backed by a Python API for translating text in manga images. The documented user flow starts with right-clicking one image or an empty page area; translation then returns an overlay. The repository also contains AI-provider routing, Lens OCR, detector-independent grouping, and image-processing stages. The README establishes the user-facing flow, while the source index confirms selected internal relationships; unsampled route and extension wiring is represented only where documented or indexed.
Main entry points: lens_service.py Lens service · main.py FastAPI app · message-controller.js Image actions · image-routing.js Background pipeline
Components 20
Browser extension
- Image actions
src/content/overlay/message-controller.js - Reader runtime
src/content/reader/runtime.js - Background pipeline
src/background/pipeline/image-routing.js - API transport
src/background/ai/transports/server.js - AI profiles
src/shared/ai-profiles.js - Extension storage
src/shared/storage.js
API and jobs
- FastAPI app
api/backend/main.py - Translation routes
api/backend/api/routes/translate.py - Lens routes
api/backend/api/routes/lens_v1.py - Job orchestration
api/backend/jobs/pipeline.py
AI translation
- AI request handling
api/backend/application/ai_translation/orchestration.py - OpenRouter provider
api/backend/ai/providers/cloud_openrouter.py - OpenRouter transport
api/backend/ai/transports/openrouter_chat.py
OCR and rendering
- Lens service
api/backend/application/lens_service.py - Lens OCR client
api/backend/lens/client.py - Text grouping
api/backend/grouping/detector_free_service.py - Graph partition
api/backend/render/lens_graph_partition/pipeline.py - Overlay rendering
api/backend/render/html/translated.py
Other components
- Reader
- AI provider
Connections 16
- Reader → Image actions: selects image
README.md - Reader → Reader runtime: starts page translation
README.md - FastAPI app → Translation routes: registers route
api/backend/main.py - FastAPI app → Lens routes: registers route
api/backend/main.py - Job orchestration → Lens service: imports service
- Lens service → Lens OCR client: uses OCR client
api/backend/application/lens_service.py - Lens service → Text grouping: uses grouping
api/backend/application/lens_service.py - Text grouping → Graph partition: partitions graph
api/backend/grouping/detector_free_service.py - AI request handling → OpenRouter provider: resolves provider
- OpenRouter provider → OpenRouter transport: uses transport
api/backend/ai/providers/cloud_openrouter.py - OpenRouter transport → AI provider: sends request
- AI profiles → Extension storage: reads and writes
src/shared/ai-profile-storage.js - API transport → AI provider: sends API request
- Image actions → Background pipeline: requests translation
- Background pipeline → API transport: dispatches request
- Overlay rendering → Reader runtime: returns overlay