Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 13 additions & 1 deletion .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ name: Sync question bank
# hour so this is not competing with everything else scheduled at :00.
on:
schedule:
- cron: "23 * * * *"
# Every hour but 03:23 UTC, which is the second entry: the same sync plus
# the daily link check, told apart by `github.event.schedule` below.
- cron: "23 0-2,4-23 * * *"
- cron: "23 3 * * *"
workflow_dispatch:

permissions:
Expand Down Expand Up @@ -56,6 +59,15 @@ jobs:
python3 scripts/sync.py --snapshot-out /tmp/snapshot.json --quiet
python3 scripts/sync.py --catalog-file /tmp/snapshot.json --check

- name: Check that the links on the landing page resolve
# Once a day, and on a manual run: one HEAD per distinct site link in
# README.md (about sixty). The renderers are tested offline and prove a
# row links at the URL the catalog gave; only this proves the page is
# there. A dead link fails the run before anything is committed. A
# refusal (401/403/429) is printed as unverified and fails nothing.
if: github.event_name == 'workflow_dispatch' || github.event.schedule == '23 3 * * *'
run: python3 scripts/check_links.py

- name: Commit
run: |
if git diff --quiet; then
Expand Down
45 changes: 34 additions & 11 deletions DESIGN.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Design

This repository is generated. `scripts/sync.py` reads the public metadata API at
<https://trueinterview.io/api/v1> and writes every file under `companies/`, `data/` and
`questions/`, plus two marked blocks of `README.md`.
<https://trueinterview.io/api/v1> and writes every file under `companies/`, `data/`, `formats/`,
`latest/` and `questions/`, plus the marked blocks of `README.md`.

## Layout

```
README.md landing page: snapshot line, how to use, column legend, A-Z index
README.md landing page: season title, stats line, new this week, recently
reported, AI coding rounds, format links, company table
latest/README.md, page-N.md every question reported in the past year, newest first
formats/<format>.md the same table for one format
companies/<key>/README.md the company's questions as one table, most recently reported first
companies/<key>/thirty-days.csv questions last reported in the past 30 days
companies/<key>/three-months.csv ... in the past 90 days
Expand All @@ -20,13 +23,15 @@ data/paths.json the folder each published question was given
scripts/ the generator and its tests
```

One axis only: the company. A question reported at several companies is in each of their
folders, so per-company counts sum to more than the size of the bank.
Two ways in. By company: a question reported at several companies is in each of their folders, so
per-company counts sum to more than the size of the bank. By date: `README.md`, `latest/` and
`formats/` list each question once, newest first, whichever companies reported it.

## Rules the generator holds

- **Titles, metadata and links only.** No statement, hint, solution or guide text is written
under `companies/` or `data/`.
under `companies/`, `data/`, `formats/` or `latest/`, or into `README.md`. Every row of the date
index links to the question's page on the site.
- **Statements are published for an allowlist only.** `scripts/common_questions.txt` lists the
well-known questions. Their statement and hints are read from a separate export that needs the
`CONTENT_EXPORT_SECRET` secret; `catalog.common_only` discards everything else in that export,
Expand All @@ -37,9 +42,21 @@ folders, so per-company counts sum to more than the size of the bank.
- **An unknown date is never printed as a date.** A question with no reported date is in
`all.csv` only. So is one dated after the snapshot, which is a mistyped date upstream.
A month-only date counts from the first of that month.
- **The count column is one the data supports.** The API has no per-question report count, so
the CSV column is `Companies Reporting`: the number of distinct companies the question was
reported at.
- **The last reported date is the site's.** The API sends `reported` (the question's own
sighting, to the day when known) and `lastReported` (a month: the later of that and the newest
interview write-up naming the question). The later month wins and is printed as a month; inside
the same month the day is kept (`catalog.latest_sighting`).
- **Reported and added are different dates.** *New this week* and the "+N added" figure count rows
by the day they entered the bank and say so; every other date is a reported date.
- **The count columns are ones the data supports.** `Companies Reporting` is the number of distinct
companies the question was reported at. `Reports` is the API's `reportCount`: interview write-ups
from the past 12 months that name the question, the counter the site's own lists rank on. A
snapshot with no counts renders no Reports column in any table, and an unknown count is never
printed as 0.
- **Site links from tables carry a source tag.** `render.site_link` appends
`utm_source=github&utm_medium=repo&utm_campaign=tech-interview-questions`. The CSV and JSONL
exports keep the bare canonical URL.
- **A window with nothing in it says so.** *New this week* prints a sentence, not older rows.
- **Rendering is pure and deterministic.** `build.build` takes records and a date and returns a
path-to-text map. The same snapshot renders to the same bytes, so a second pass changes nothing.

Expand All @@ -51,7 +68,11 @@ Everything is rendered and checked in memory before the filesystem is touched.
(`companies`, `data`, `questions`). Pruning is limited to the same directories.
- **Size budgets.** `README.md` must stay under `README_MAX_BYTES` and every other page under
`PAGE_MAX_BYTES`, both far below the 512,000 bytes GitHub will render. A company table is
capped at `TABLE_MAX_ROWS` rows; `all.csv` has no cap.
capped at `TABLE_MAX_ROWS` rows; `all.csv` has no cap. The README tables, the `latest/` pages
and the format pages are capped in rows in `season.py`.
- **Links.** `scripts/check_links.py` sends one `HEAD` per distinct site link in `README.md`
once a day and fails the run on a dead one. A refusal (401, 403, 429) is reported as
unverified, neither dead nor ok.
- **Question pages.** A run without the secret refuses to start if question pages are already
published, rather than deleting them. A run that would remove more than a fifth of them stops.
- **Failed reads.** Any API failure aborts the run with nothing written.
Expand All @@ -60,9 +81,11 @@ Everything is rendered and checked in memory before the filesystem is touched.

| Module | Role |
| :-- | :-- |
| `catalog.py` | The only network code. Reads the API into plain records and validates them. |
| `catalog.py` | The only network code in the sync. Reads the API into plain records and validates them. |
| `build.py` | Assembles every generated file from one snapshot. |
| `company.py` | The company folder: the table and the four CSV files. |
| `season.py` | The date index: the README blocks, `latest/` and `formats/`. |
| `check_links.py` | The daily link check. The only other network code. |
| `content.py` | Question pages, their index, stable paths, link rewriting. |
| `render.py` | Shared helpers: escaping, ordering, tables, the `data/` exports. |
| `labels.py` | Display names and folder keys for companies, formats, difficulties, rounds. |
Expand Down
Loading
Loading