How assai-id/nemesis works
1. System shape
- Nemesis is a two-tier application: a static frontend and a Node.js backend API.
- The product goal is an investigative dashboard over a large procurement dataset, with anomalies surfaced for public consumption.
2. Frontend boundary
- frontend/index.html plus plain CSS/JS under frontend/assets/ form a no-build static client.
- There is no frontend framework or bundler in the repo; the browser UI is served separately and talks to the backend over HTTP.
3. Backend runtime
- The backend is a Node.js service in backend/src/.
- Key files suggest a typical server split:
- server.js for process startup/listening
- app.js for application wiring
- config.js for environment/config loading
- db.js for database access
- dashboard-repository.js for query/data-access logic
- seed.js and db-transfer.js for data loading/migration concerns
4. Primary request flow
- Browser UI requests data from the backend at http://127.0.0.1:3000/api per the README.
- The backend likely translates those requests into SQLite queries through the repository layer, then returns JSON to the frontend.
- This is the core runtime path: UI → API → repository/db → JSON response.
5. Data store
- The backend depends on a local SQLite database at backend/data/dashboard.sqlite.
- The README emphasizes that the application is data-first: the DB is prepopulated from a dataset rather than backed by an external live system.
6. Dataset ingestion / offline preparation
- The repo includes operational scripts in backend/scripts/:
- import-db.js
- export-db.js
- reset-db.js
- These indicate the database is managed as an offline artifact, with import/export/reset workflows for rebuilding or exchanging the SQLite file.
7. Geospatial subsystem
- backend/seed/geo/ contains many GeoJSON files organized by administrative level:
- 02-provinces/province-only
- 02-provinces/with-districts
- 03-districts
- This is a separate data boundary from procurement records: it provides reference geography for mapping, joins, or region-aware visualization.
8. Seeding and reference data
- The presence of backend/src/seed.js and the GeoJSON hierarchy suggests backend initialization may load or validate reference geographic layers.
- The repo also has a None.geojson file among districts, which suggests the data pipeline handles incomplete or unmapped records explicitly.
9. Configuration and environment
- Backend configuration comes from backend/.env with defaults for:
- PORT
- CORS_ORIGIN
- SQLITE_PATH
- AUDIT_DATASET_DIR
- GEO_ROOT_PATH
- This shows the backend is designed to be portable and to locate both the database and seed data via environment variables.
10. Deployment/runtime topology
- Development uses two processes:
- backend on http://127.0.0.1:3000
- frontend served separately on http://127.0.0.1:8080
- The frontend is not embedded into the backend build, so the architecture keeps static presentation and API/data processing cleanly separated.
11. External dependencies and serving model
- The README links to downloadable dataset artifacts hosted externally, but the running application itself does not appear to depend on an external live API.
- That means the main production dependency is the local SQLite file, not a remote database service.
12. What to draw in an architecture diagram
- Draw four main boxes:
- Browser UI
- Static frontend files
- Node.js backend API
- SQLite database + GeoJSON seed/reference data
- Show one primary data path from browser to API to SQLite.
- Show a secondary offline path from dataset artifacts and seed files into the database via the import/seed scripts.
Main entry points: app.js App wiring · dashboard-repository.js Dashboard repo · db-transfer.js DB transfer · seed.js Seeding
Components 16
Frontend
No-build static browser client
- Browser UI · Investigative dashboard used to consume procurement data
- HTML shell · Frontend entry page
frontend/index.html - Static assets · No-build browser logic and styling
frontend/assets
Backend
Node.js API and data access
- Server start · Process startup and HTTP listening
backend/src/server.js - App wiring · Middleware, routes, and application setup
backend/src/app.js - Config · Loads runtime settings such as port, CORS, and paths
backend/src/config.js - DB layer · Opens and manages the local database connection
backend/src/db.js - Dashboard repo · Encapsulates dashboard-specific queries and data shaping
backend/src/dashboard-repository.js - Seeding · Initializes or validates reference and dataset-loaded state
backend/src/seed.js - DB transfer · Moves data between database artifacts and source datasets
backend/src/db-transfer.js
Data
SQLite store and reference geography
- SQLite DB · Prepopulated dashboard database artifact
- GeoJSON refs · Province and district reference geometries, including unmapped records
backend/seed/geo - Dataset artifacts · Downloaded procurement source data used to build the local DB
Offline prep
Import, export, reset, and seeding workflows
Connections 16
- Browser UI → HTML shell: loads · Browser opens the static client entry point
- HTML shell → Static assets: uses · HTML pulls in browser scripts and styling
- Browser UI → App wiring: requests JSON · UI calls the backend API over HTTP
- App wiring → Server start: bootstrapped by · App wiring is started by the server process
- App wiring → Config: reads · Runtime behavior depends on environment configuration
- App wiring → Dashboard repo: delegates to · Request handlers use the repository layer for query logic
- Dashboard repo → DB layer: queries · Repository executes database operations through the DB layer
- DB layer → SQLite DB: opens · Local SQLite file is the primary runtime datastore
- Dashboard repo → GeoJSON refs: enriches with · Query results can be joined or interpreted with reference geography
- Seeding → GeoJSON refs: loads · Seeding uses GeoJSON reference layers
- Seeding → SQLite DB: initializes · Seed step prepares the local database contents
- DB transfer → Dataset artifacts: imports from · Offline transfer starts from downloaded source datasets
- DB transfer → SQLite DB: writes to · Transfer scripts populate or refresh the SQLite artifact
- Import DB → DB transfer: invokes · Import script drives the database transfer workflow
- Export DB → SQLite DB: exports · Export script reads the local database artifact
- Reset DB → SQLite DB: resets · Reset script clears or recreates the database state