6 Architecture
Nate edited this page 2026-11-22 17:57:19 -08:00

Architecture

How EveSynapse is put together: how data moves, the code's layers, and the optional modules. Code Layout lists every directory and package.

EveSynapse is one Go program, a server that renders its pages itself (html/template) over PostgreSQL 16 or newer (the live deployment runs 18.6) and CCP's ESI API. Everything is in one Go module, evesynapse, of 74 packages.

How data moves

The background worker gathers and computes data, then stores the result. Pages read what is stored, so a page load does not wait on ESI.

flowchart TD
  subgraph SRC["Outside sources"]
    direction TB
    sso["EVE SSO<br/>tokens"]
    esi["ESI<br/>game data"]
    zkill["zKillboard<br/>new kills"]
    everef["EVE Ref<br/>past kills"]
    fuzz["Fuzzwork<br/>static data,<br/>fallback prices"]
    swarm["Swarm peers<br/>optional"]
    model["Model provider<br/>optional"]
  end

  worker["Background worker<br/>fetches, computes and stores"]

  subgraph STORE["Stored results"]
    direction TB
    db[("PostgreSQL<br/>snapshots and tables")]
    ram["Memory<br/>search, prices, recent kills"]
  end

  pages["Page handlers<br/>short, bounded reads"]
  browser["Browser"]
  notify["Discord and<br/>push notifications"]
  cdn["Asset CDN (optional)"]

  SRC --> worker
  worker --> STORE
  worker --> notify
  STORE --> pages
  pages -->|finished HTML| browser
  cdn -.->|wallpapers and landing media| browser
Source What it provides Where it goes
EVE SSO sign-in and character tokens tokens are encrypted and stored
ESI character, corporation, market and public data stored snapshots and tables
zKillboard stream new public kills killboard tables and pilot activity
EVE Ref archive past kills restores kill detail
Fuzzwork the static data export and fallback prices sde_* tables, labeled price fallback
Swarm peers (optional) public ESI data shared between instances the same stored tables
Model provider (optional) trade idea text the stored Trade Ideas answer
Asset CDN (optional) wallpapers and landing media loaded directly by the browser

Prices follow one order: EveSynapse's own swept market orders, its stored estimates, a labeled outside aggregate, and then an honest gap. Performance Principles covers the rules behind this design.

The four layers

Layer Where What it is
Entry points cmd/ thin main packages: the server, the dev server, and the maintainer tools
Core internal/app the application: sign-in, routing, page rendering, the background worker, and every page that is not an optional module
Modules internal/app/<module>/ 25 optional features, each a package that registers itself through one contract
Foundation internal/* the database, the ESI client, and the engines and helpers that core and modules share

Imports only point down the table. Three rules keep it that way:

  • A module never imports core or another module. It reaches the application only through internal/app/module, and what core hands it at run time (module.Deps: the database, the ESI client, the current character's standing, readers for what core owns). When one module needs another, its manifest says so and the build tool brings the other one in.
  • Foundation never imports core or a module. The ESI client, for example, is handed access tokens through a callback rather than reaching into the sign-in code.
  • Anything core and a module both show lives in foundation. The stored trade-ideas answer (internal/ideas) and the fit document (internal/fitview) are there so that neither side depends on the other.

Entry points

Program What it is
evesynapse the release server. It does not contain the dev-login code at all
evesynapse-dev the same server plus /dev-login, for local testing only. Never deploy it
modbuild chooses which modules a build contains (see below)
releasesign the maintainer's release-signing tool (Updating)
residue-corpus builds training examples for the intel reader from verified outcomes
mkicons redraws the raster icons from the logo SVGs

The server also runs the maintenance modes listed in Command-Line Modes; -update is the self-updater in internal/selfupdate, which knows nothing about the rest of the application.

Core

internal/app is one large package. Files are named by the part of the app they belong to (auth_, char_, market_, intel_, worker_, …), so a directory listing groups them; Code Layout has the full table of prefixes.

Core owns sign-in and sessions, token refresh and encryption, the router and page rendering, the background worker that fetches from ESI, the static-data (SDE) importer, notifications and push, and all the pages that are always present: home, the character pages, the market browser, the map, intel pages, industry, structures, search, admin.

Modules

Every optional feature is a module. A build contains exactly the modules listed in internal/app/modules_enabled.go; Go leaves out whatever is never imported, so a module that is not chosen is not in the binary at all. By default every module is in. To build a smaller server, the build tool writes that file for your selection and adds whatever the chosen modules require:

make modules                                      # list modules, requirements and scopes
go run ./cmd/modbuild -modules fitting,doctrines -write
go build -o bin/evesynapse ./cmd/evesynapse

A module also declares the ESI scopes it needs and the ones it can use but does not need ("enhances"). Which modules an account has follows the scopes it granted; see "Choosing what to link" on the Configuration page.

Module What it is Requires Engines it uses
Build Planner the industry build planner page buildplan, piplan, tags
Fitting workbench, saved loadouts, import/export, save to the game, shopping list fit, fitview
Public Fits the public loadouts browser and ratings Fitting
Skill Plans plan pages, plan-from-fit, plan editing skillplan, fitview
Wallet the character wallet
Mail in-game mail htmlsanitize
Calendar the in-game calendar
Contacts the character's contacts
Spread Scanner a market page over the swept order books
Trade Finder a market page over the swept order books
Top Stations a market page over the swept order books
Restock Planner a market page over the swept order books
Market orders the character's market orders
Contracts the character's contracts
Appraisal / Multi-Sell price a pasted list of items fitview
Corporation Data member, wallet, order, asset and structure pages balancechart, standing
Doctrines doctrines and corporate loadouts Fitting fitview
Ship Replacement the corporation's ship replacement program standing
Groups special-interest groups standing
Communities groups of players outside the game's corporations standing, humanize
Discord account linking and the bot (Discord) discord, standing
Shared Cache instance-to-instance sharing (Swarm Cache)
Intel killboard, d-scan, intel channels, feed, dossiers, wars
PI Planner planetary-industry chain layouts piplan
Trade Ideas stored trade-idea answers ideas

Every module also uses the contract and logging; all but Intel use the database, and all but Public Fits, Groups, Communities and Discord use the ESI client.

Public Fits and Doctrines list Fitting as a requirement in their manifests. The build tool adds Fitting, and the two modules reach it only through core.

Foundation

Group Packages
Data store (opens Postgres through a pgx pool, applies the numbered schema steps, and keeps a database/sql handle for migration), db/sqlc (queries generated by sqlc against pgx and run on that pool), esi (the ESI client, its cache and name resolution), marketwire (the versioned /api/market/v1 format)
Engines fit (the dogma stat engine), fitview (the fit document and simulation view), skillplan, buildplan, piplan, markethistory, balancechart, standing (who belongs to and holds roles in a corporation or alliance), ideas
Intel parsing scan (d-scan, local, fleet and probe pastes), intelchat (intel channel lines), intelanalyze (what a report says), inteltag (the word tagger)
Helpers htmlsanitize, humanize, tags, logging, webpush (browser push), discord (the Discord API client), ocikms (wraps the token key with an OCI Vault key; see Security), card, eveimg, gamelog, itemsheet, memsize, netguard, tradefees
Install and update selfupdate, releasesig, pidfile, dotenv

Most engines are pure: they read no database, call no network and hold no configuration; the caller hands them what they need. That is what keeps them testable and shareable between core and modules.

Tests

go test ./... needs no database of its own: internal/pgtest starts an embedded PostgreSQL 16 and gives each test a fresh database. Page tests that drive the whole application live in internal/app/tests with their fixtures in internal/apptest; tests of one file's internals sit beside that file. make check runs what CI runs.

The internals in full

The running system's internals have their own pages: