selfapi-v2 / docs /architecture.md
akashyadav758
Harden monitor (gate all routes), swap ChatGPT backend to free-Chatgpt-api, clean repo
5c7f4b5
|
Raw
History Blame Contribute Delete
2.35 kB

Architecture β€” one container, everything inside

Everything runs in one container built from the root Dockerfile. The extensions inside Chrome dial their servers on hardcoded 127.0.0.1 ports, so the servers must share Chrome's localhost β€” a separate machine/Space can never reach them. That's why there's a single image, not microservices.

            https://…hf.space   (only port 3001 is public)
                     β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ monitor :3001     β”‚  UI + API gateway (one Go binary)
            β”‚  /  /chrome.log   β”‚  (open, no key)
            β”‚  /gpt /gemini /flowβ”‚  (API-key gated β†’ localhost)
            β””β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”˜
       9225 β”€β”€β”€β”˜   8000β”‚      └─── 8101
   (chatgpt)      (gemini)        (flow)
        β”‚             β”‚             β”‚
   ws 9225       ws 9226       ws 9227     ◄── extensions dial in (localhost)
        └──────── Chrome (headless) + 3 unpacked extensions β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              CDP 9222  Β·  socat proxy 9223  Β·  profile in /home/chrome/data

Port map (all on the container's 127.0.0.1)

Port Who Purpose
3001 monitor UI + API gateway (only published port)
9222 Chrome DevTools Protocol (CDP)
9223 socat CDP proxied for external tools
9225 chatgpt server HTTP API and extension WS (same port)
8000 / 9226 gemini server HTTP API / extension cookie-WS
8101 / 8100 / 9227 flow server HTTP API / ext-callback / extension WS

What starts it

start_hf.sh (the container entrypoint) in order: restore profile from Postgres β†’ clean profile β†’ start monitor (3001) β†’ CDP proxy β†’ start the 3 backend servers (step 6a) β†’ launch Chrome with the 3 extensions. Each server logs to /home/chrome/{chatgpt,gemini,flow}.log.

Components added on top of the base image

  • monitor/ β€” Go UI, now also the reverse-proxy gateway (gatewayHandler, authOK).
  • profilesync/ β€” Go tool, Chrome profile ⇄ Postgres snapshot.
  • free-Chatgpt-api/, free-gemini-api/ (Go) + flow-agent/ (Python/FastAPI) β€” the 3 servers, built/installed into the image by the Dockerfile.