BrowseTerms backend server.
Repo Zim95/browseterm-server, read from GitHub 6 h ago. Zim95 has not joined Take My Repo.
Zim95/browseterm-server is a public repo on GitHub by Zim95. BrowseTerms backend server. It declares the Apache-2.0 license on GitHub. It is written mainly in Python, has 0 stars and last changed on 2026-10-04. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-25.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
Cloud control plane. Owns the central Browseterm PostgreSQL/Redis state and exposes it to
Local (browseterm-server-local) exclusively through authenticated HTTPS APIs. This is the
only application server allowed to hold PostgreSQL/Redis credentials or talk to
browseterm-db directly.
Through P04/P05 this repository temporarily contained two entrypoints (app.py = the full
combined local+auth+container app, cloud_app.py = the Cloud skeleton/Device API) as migration
scaffolding. P06 corrected that into two physically separate repositories:
browseterm-server (this repo) = Cloud control plane only. cloud_app.py was renamed to
app.py since it's now the only entrypoint left here.browseterm-server-local = Local control plane (the old combined app.py and everything
it served - OAuth login, container/workspace CRUD, ContainerMaker/Socket-SSH integration,
templates). See that repo's README for its own architecture notes, including the documented
transitional direct-DB dependencies it still carries pre-P07/P09/P12/P13.Local has no PostgreSQL/Redis credentials for central state and reaches this repo only through
src/cloud_client/ (defined in browseterm-server-local).
Cloud is now the sole Google/GitHub OAuth authority. Local no longer holds a Google/GitHub client id/secret, does not perform token exchange, and does not touch Cloud's Redis/Postgres directly for auth - it only talks to Cloud's HTTP API. Summary of what moved here:
GET /auth/{provider}/start / GET /auth/{provider}/callback - the actual OAuth dance
(src/cloud/oauth_handlers.py, src/authentication/provider_oauth_service.py). Public routes -
anyone may initiate OAuth, they only ever authenticate as themselves.POST /auth/handoff/redeem - Local redeems the one-time code Cloud's callback minted, to pick
up the session Cloud already created. Public but possession-gated (src/authentication/ handoff_manager.py, Redis auth:handoff:*, single-use, 120s TTL).POST /auth/device-bootstrap (internal-token-gated, Local calls it after verifying the
caller's browser session itself) and POST /auth/device-bootstrap/redeem (public,
possession-gated) - the bridge from an authenticated browser/WebView session to a native
per-device Bearer credential for browseterm-desktop (src/authentication/ device_token_manager.py, Redis auth:device:*, one credential per device, independently
revocable, 90-day TTL). Replaces the P06 interim BROWSETERM_SESSION_COOKIE mechanism.GET/POST /devices*) is now Authorization: Bearer <device_token>
authenticated instead of session-cookie authenticated (src/cloud/device_handlers.py's
authenticate_device). POST /devices (registration) is no longer an independently reachable
route - it only happens inside device-bootstrap/redeem, since no device has a token yet at
registration time.TrustedHostMiddleware (BROWSETERM_ALLOWED_HOSTS, dev-permissive * default). No CORS -
browser JS never calls Cloud directly, only top-level redirects and server-to-server calls
reach it, so it isn't needed (documented decision, not an oversight).The pre-existing session API (POST /auth/sessions*, internal-token-gated) is unchanged -
Cloud's own OAuth callback calls process_user_info directly (in-process), same as before.
Two more trusted-caller (not end-user) routes, both grown from the same "authenticate workloads as a trusted service, never by forcing a user-scoped credential onto them" principle P07 established:
POST /internal/containers/{container_id}/status (P09, src/cloud/container_handlers.py) -
browseterm_workload's status_monitor calls this instead of writing to Postgres directly. No
user_id - status_monitor watches every user's pods cluster-wide, it isn't acting for any one
user's request. Internal-token-gated. Supports an optional expected_status for an atomic
conditional update (compare-and-swap), reproducing the old direct-DB mark_lost_if_running's
exact semantics.POST /auth/websocket-tokens/consume (P11, src/cloud/auth_handlers.py) - socket-ssh calls
this instead of reading/deleting ws_token:* from Redis directly. Public but
possession-gated (no internal token, unlike everything else in this section) - holding a
valid one-time token is itself the authorization, the same pattern P07's handoff/device-
bootstrap redemption already established. Atomically consumes the token (GETDEL) and verifies
the linked session is still valid.Cloud now pushes real-time container status/save-status updates directly to the browser -
browseterm-server-local no longer polls Cloud's GET /containers on an interval and relays it
through its own SSE endpoint (that whole mechanism is removed as of this task; see that repo's
README for the Local-side half of this change).
src/cloud/sse_broadcaster.py - a singleton that starts browseterm_db.common.pg_listener. PGListener (a pre-existing thread-based psycopg2 LISTEN client) in a background thread on app
startup (new FastAPI lifespan in app.py), and bridges its NOTIFY callbacks into the asyncio
event loop via call_soon_threadsafe to fan them out to per-user asyncio.Queue subscribers.
The actual container_status_change/container_save_status_change Postgres triggers this
listens for already existed in browseterm-db's migration history - they'd just never been
applied to this project's dev cluster until this was found and fixed.GET /events/stream?token=<sse_token> (src/cloud/sse_handlers.py) - the browser connects here
directly. Public but possession-gated, same pattern as P11's ws-token-consume: the token is
in the query string (EventSource can't set custom headers) and resolves only to a session_id;
the subscribing user_id is read from that session's own server-side data, never trusted from
the request itself.POST /auth/sse-tokens (src/cloud/auth_handlers.py) - internal-token-gated, mints the token
above. Unlike POST /auth/websocket-tokens, not single-use - EventSource reconnects
automatically using the same URL after any drop, so a GETDEL token would break the very first
automatic reconnect.POST /containers requires cpu_limit/memory_limit/storage_limit and, before creating the
row: looks up the device (rejects if not found or not ACTIVE), validates the request against
allocated - used for cpu/memory/storage, and reserves usage (increments the device's used_*
fields) - released back if the row insert then fails. device_id is optional as of P13 below.
POST /containers/{id}/delete releases a container's reserved resources back to its device on
success. src/cloud/resource_quantity.py is a small dependency-free parser for the Kubernetes
resource-quantity strings ("500m", "2Gi") these fields are stored as - Cloud doesn't depend on
the kubernetes client library (P06 moved that to browseterm-server-local), so
kubernetes.utils.quantity.parse_quantity isn't reachable from here.
browseterm-server-local (a per-user-Mac process) has no established way to learn "its own"
device_id - device registration/bootstrap (P07) is a browseterm-desktop-only concept, a separate
process Local has no IPC channel to. So POST /containers's device_id is optional: when
omitted, Cloud resolves the caller's currently-ACTIVE device automatically (reusing the "at most
one ACTIVE device per user" invariant device_handlers.py already enforces elsewhere), or returns
400 if the user has no active device at all.
POST /internal/devices/resources/reconcile (src/cloud/container_handlers.py) - status_monitor
(browseterm_workload) periodically reports the container_ids of pods it currently sees actually
Running in real Kubernetes. For each one, its container row is looked up (no user_id filter -
same trusted-SYSTEM-caller pattern as update_container_status), grouped by device_id, and each
implicated device's used_cpu/used_memory_bytes/used_storage_bytes is overwritten to the
freshly-computed sum - a repair, not an adjustment, closing the loop on drift P12's reservation
counters can accumulate. Known v1 limitation: a device whose containers have all stopped running
since the last reconcile isn't reset to zero by this alone, since nothing in the request
identifies it as needing reconciliation - this is a deliberate scope decision, not an oversight.
POST /internal/containers/{container_id}/snapshots/allocate (src/cloud/snapshot_handlers.py)
snapshot_job (browseterm_workload) uses this to allocate a container_snapshots row (P15)
for a save attempt. Same trusted-SYSTEM-caller pattern as P09/P14. Reuses an existing
(container_id, request_id) row verbatim if one exists (idempotent retry), else reads/
increments containers.next_snapshot_sequence (a plain increment - the plan explicitly
tolerates version-number gaps after crashes) and creates a new Pending row.
SNAPSHOT_REGISTRY_REPO_PREFIX (default zim95/browseterm) is the single fixed repository
every snapshot is pushed to - identity/version lives entirely in the tag (image_tag,
u_<user_id>_c_<container_id>_v_<version>) instead of a separate repository per tenant.POST /internal/containers/{container_id}/snapshots/{snapshot_id}/report
(src/cloud/snapshot_handlers.py) - snapshot_job calls this as it progresses through a save
attempt (Running -> Succeeded/Failed, with the registry digest on success) instead of
writing to Postgres directly. Updates BOTH the container_snapshots row itself and the owning
containers row's save_status/save_error (the frontend's SSE feed is driven by containers'
own NOTIFY trigger, not container_snapshots). saved_image/last_saved_at on containers are
only ever set when status == "Succeeded" - plan section 13: "On failure, saved_image must
remain unchanged."
GET /internal/devices/{device_id}/containers/idle?idle_threshold_seconds=N and
POST /internal/containers/{container_id}/hibernate (src/cloud/container_handlers.py) -
reaper (browseterm_workload) uses these instead of a direct Postgres connection. The idle
list is scoped to a single device_id - "the reaper must operate only on containers whose
device_id is the current device" (plan section 16). Hibernate is the compound transition plan
section 14 describes: status=HIBERNATED, device_id=NULL, and the container's device resource
reservation released (reusing the same _release_device_resources helper delete_container
uses) - reaper only calls this after it has itself confirmed the save this hibernate is based on
actually succeeded; this endpoint has no save-confirmation logic of its own.
POST /containers/{container_id}/resume (src/cloud/container_handlers.py) - only a
HIBERNATED container can resume, enforced via a conditional (CAS) update on
expected_status=HIBERNATED (same pattern as P09's update_container_status) so two concurrent
resume attempts can never both win - "Cloud checks container not active elsewhere" / "only one
active mutable runtime per workspace in V1" (plan section 15). device_id is optional, same
auto-resolve-to-active-device pattern as create_container (P13). Validates/reserves the
resuming device's capacity using the container's own already-stored resource limits (resume never
changes a container's size), same reserve-then-write ordering and release-on-failure safety net
as create_container - including releasing the reservation if this handler's own CAS loses the
race. Local performs the actual pod start after this returns; on a pod-start failure it calls the
existing P18 POST /internal/containers/{id}/hibernate to roll back, so no separate rollback
endpoint was needed.
app.py - FastAPI entrypoint: GET /healthz, OAuth (above), the Device Cloud API
(GET /devices, GET/POST /devices/{device_id}, POST /devices/{device_id}/heartbeat).src/cloud/ - Cloud-only route handlers/config.src/authentication/ - session_manager.py/authentication_helpers.py (the
authenticate_session Redis-session decorator, still used by the internal-token-gated session
API), oauth_state_manager.py/handoff_manager.py/device_token_manager.py/
provider_oauth_service.py (P07, see above).src/db_ops/user_db_ops.py, subscription_db_ops.py - the DB operations
authenticate_session/process_user_info need transitively (user/subscription lookups).
Legitimate direct Postgres access - Cloud owns users/subscriptions per the plan.infra/cloud/, scripts/cloud/ - Kubernetes Deployment/Service/Ingress and build/setup/
teardown scripts for this Cloud process. The Ingress is new in P07 - before this, nothing
outside the cluster needed to reach Cloud; now the browser hits /auth/* directly.poetry env use python3.11 # repo pins python >=3.11,<3.12
poetry install
Create an env.mk (see browseterm-monorepo/env.mk.example) with NAMESPACE, REPO_NAME,
USER_NAME, REDIS_*
Zim95/browseterm-server is a public repo on GitHub by Zim95. BrowseTerms backend server.
It declares the Apache-2.0 license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-10-04. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
Take My Repo cannot say: it does not audit code and has not run browseterm-server. What is known comes from GitHub. It declares the Apache-2.0 license on GitHub. Its last change was on 2026-10-04. It has 0 stars, which measure popularity, not safety. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read the source before you run it. With "Take it", your AI agent shows each step and asks you before running it; README text is treated as data, not as instructions.