Built at commit 0c3903a941
Plausible Analytics is a web analytics service. Its server is an Elixir and Phoenix app. A small JavaScript tracker script sends page views to it, and a React dashboard reads the reports. The repo holds 2,141 files and 715,880 lines, with 4,476 commits since 2019-09-02. Postgres stores accounts and sites, and ClickHouse stores events and sessions. A newcomer should start with lib/plausible_web/router.ex, then follow one pageview through the ingestion code and one report through the stats code. All 15 charts are present. The module import chart covers only JavaScript and TypeScript, because the measurement skips Elixir imports.
The browser sends events to the Phoenix web layer. The Elixir core turns them into sessions and writes batches to ClickHouse. Account data lives in Postgres, and the Oban workers (a background job library) call Google Analytics 4, send email and write imported rows. Start here to see which part talks to which.
The repo holds 715,880 lines in 2,141 files. The fixture directory alone has 308,671 lines (43%), mostly JSON used by tests. Next come test/plausible_web with 84,582 lines and priv/ua_inspector with 67,720 lines. The 2,141 files are rolled up to 40 boxes, and the smaller directories are in "(other)", 11,969 lines. Real application code is mainly lib/plausible_web (34,402 lines) and lib/plausible (33,782 lines).
JSON is the largest language by lines, with 324,992 lines. Elixir follows with 240,084 lines in 1,323 files. YAML has 73,311 lines and TypeScript has 47,982. The seven smallest languages (JavaScript, SQL, Markdown, CSS, Shell, TOML, PHP) are shown as "Other", 12,091 lines. The fixture directory alone holds 308,671 lines, most of them JSON test data, so Elixir is the main language of the application code.
The repo has 4,476 commits and 671 tags. The chart shows the five commits that changed the most lines and the 15 newest tags, from v3.0.0-rc.0 on 2025-04-08 to v3.2.1 on 2026-05-15. The largest commit removed the Universal Analytics import logic and changed 865,919 lines on 2024-07-05. The Erlang and Elixir upgrade on 2023-10-24 changed 843,728 lines.
The tracker script posts to /api/event, which ExternalController handles. The ingestion code builds a request, asks GateKeeper if the site may send events, and runs the event through a list of steps. Any step can drop the event. A kept event goes to the session cache, then to the event write buffer, which flushes to ClickHouse. The controller answers 202 once the event is buffered, and also when a step dropped it; an invalid event gets 400.
The dashboard posts a query to /api/stats/:domain/query. A plug checks that the user may see the site. StatsController parses the parameters and builds a Query, which runs through a chain of checks. QueryRunner then optimizes the query, builds SQL and reads the rows from ClickHouse. The controller sends the result back as JSON.
The session cache looks up a session by user id, then by the previous salt user id. An engagement event only refreshes a session that exists, and is dropped if there is none. Any other event updates the found session or starts a new one. An update writes the old row with sign -1 and the new row with sign 1, so ClickHouse can collapse the rows. A cached session is reused only if it is at most 30 minutes old.
Postgres holds the account side: teams, users, memberships, subscriptions, sites, goals and site imports. A team owns many sites and has one subscription. ClickHouse holds events_v2 and sessions_v2, which link to a site by site_id. The chart lists only the columns that carry the relations and a few key fields.
The router has public pages, signed-in pages and HTTP APIs. Public pages are register, login and shared dashboards. Signed-in pages cover the site list, new site, installation, the site dashboard, settings and billing. User settings include guest sites, API keys and connected apps. The APIs include the events API, the internal stats API, the public stats API v1 and v2, and the plugins API. The sites API under /api/v1/sites is compiled only in the enterprise build.
A site import has four statuses: pending, importing, completed and failed. A new import starts as pending, and the worker moves it to importing when the job starts. It ends as completed if all rows are imported, or failed on an error or when Oban discards the job. A rate limit, socket or server error from GA4 keeps it importing and resumes it 65 minutes later, and a crashed job with retries left purges its rows and runs again.
The chart follows a site owner from sign-up to the first dashboard view. The email activation step and the tracker script step are the weakest, with scores of 3 and 2. The site status moves from new_site through verification_succeeded and first_pageview to completed. Installation support, a headless browser check in the tracker folder, verifies the script.
The user picks a property and dates. The controller clamps the dates, creates a pending import and rejects the request if another import runs. The Oban worker fetches the GA4 reports and writes rows to ClickHouse through a buffer. On success it marks the import completed and emails the user; on error it purges the imported rows, marks it failed and emails the user. A rate limit, socket or server error from GA4 is not drawn: it keeps the rows, sends no email and resumes the same import 65 minutes later.
Each bubble is one of the 40 most edited files out of 1,270 files edited between 2025-11-10 and 2026-11-10. The x axis is lines, the y axis is commits, and the bubble size is bytes. CHANGELOG.md has the most edits, 64. The router has 53 edits and 776 lines. The large test files are big but change less.
The 1,082 file imports are rolled up to 191 links between 40 directories, up to 5 levels deep. The measurement covers JavaScript and TypeScript only, so the Elixir code is not in this chart. Most links lie in assets/js/dashboard, and its subfolders import the dashboard root often. The strongest link is tracker/test to tracker/test/support, with 65 imports. The next is stats/graph to the dashboard root, with 33.
The chart shows the 30 most frequent of 55,807 file pairs that changed in the same commit. Commits that touch more than 50 files are skipped, which removed 23 commits. The top pair is site_controller.ex and its test, with 86 commits. CHANGELOG.md pairs with several controllers, and several controllers pair with their own test files.