docs: add docs/ARCHITECTURE.md and explain the scar tissue in client.ts - #53
Open
Waynting wants to merge 1 commit into
Open
docs: add docs/ARCHITECTURE.md and explain the scar tissue in client.ts#53Waynting wants to merge 1 commit into
Waynting wants to merge 1 commit into
Conversation
Closes aloth#49. Split by distance, as agreed: the document carries what someone needs before opening a file, the comments carry what is only understandable at the line. docs/ARCHITECTURE.md states the premise everything follows from - there is no public Overleaf API, so the client authenticates as a logged-in browser session and calls the endpoints the web editor calls - then works through authentication, the HTML scraping and the Socket.IO fallback for the file tree, the write endpoints, the transport, and which modules can be tested without an account. In client.ts: - The file header claimed to provide "programmatic access to Overleaf's REST APIs", which is the exact misconception the document exists to correct. - extractCsrfToken and listProjects each carried numbered fallbacks with no hint that they are successive Overleaf redesigns rather than defensive habit, or that dropping the older ones breaks self-hosted instances without breaking overleaf.com - so the failure would not show up for whoever removed them. - getProjectFromSocket now says it is a hand-written Socket.IO 0.9 client, that it exists because the file tree left the meta tags with no HTTP route returning it, and that it is the first thing to suspect when the tree breaks. - uploadFile now says it overwrites rather than edits, and connects that to why push has no merge semantics and why diff exists.
Waynting
force-pushed
the
docs/architecture
branch
from
September 4, 2026 14:58
95ac589 to
29a1c16
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second of the two PRs for #49, and the half you said deserves more
discussion. Independent of #52 — either can land first, though #52's intro
references this file by name.
Split by distance exactly as you framed it: the document carries what someone
needs before opening a file, the comments carry what is only understandable
at the line.
docs/ARCHITECTURE.md
Leads with the premise rather than a module tour, because every other decision
in
client.tsis downstream of it: there is no public Overleaf API, so theclient authenticates as a logged-in browser session and calls the endpoints the
web editor's own JavaScript calls. Cookie plus scraped CSRF token, meta-tag
parsing, Socket.IO for the file tree, and the write endpoints — none of it
versioned or documented, which is what makes the fallbacks meaningful instead
of merely cautious.
Two things I gave more room than the issue proposed, because they were the
things I got wrong reading the code cold:
uploadFileoverwrites, it does not edit. The web editor sendscharacter-level operations over the collaboration socket; the upload endpoint
replaces a whole file. I assumed
pushmerged in some fashion until I read itproperly. Stating it explains
pushhaving no merge semantics anddiffexisting at all, so it is in the document and on the function.
The module map is framed as "does this need an account". That is the
question that decides where new logic goes, and the pure/impure split is
already the repository's answer —
scan.ts,rename-plan.tsanddiff.tseach exist because of it. Worth stating rather than leaving to be inferred.
Also a short "when Overleaf breaks it" section:
--verbosefirst, then themeta tag, then suspect the socket, keep old fallbacks for self-hosted.
The comments in client.ts
Four places. The first is a correction rather than an addition:
The file header claimed to provide "programmatic access to Overleaf's REST
APIs". That is precisely the misconception the document exists to correct,
sitting at the top of the file someone opens first.
extractCsrfTokenandlistProjectseach had numbered fallbacks withnothing saying they are successive Overleaf redesigns. Your "scar tissue"
phrase is the right one, and I added the part that makes it actionable:
dropping the older branches breaks self-hosted instances without breaking
overleaf.com, so whoever tidies them away will not see the failure.
getProjectFromSocketnow says what it is — a hand-written Socket.IO 0.9client — why it exists (the tree left the meta tags and no HTTP route returns
it), and that it is the first suspect when the tree breaks.
uploadFilegets the overwrite semantics, as above.npm run lint,npm run buildandnpm testpass; the only code change iscomments, so nothing behavioural moved.