Administration
Installation and hosting
For the IT team or data centre running BastraLekha: what it is made of, what it needs, and how to run it safely.
What it is made of
| Part | What it is |
|---|---|
| Web app | A static single-page app, served from any web server or CDN. The till caches the catalogue in the browser to bill offline. |
| API | A Node.js service, delivered as a container image (Linux amd64, about 80 MB, runs as a non-root user). It holds no state of its own. |
| Database | PostgreSQL. All data lives here. |
Database requirements
BastraLekha depends on PostgreSQL features that other databases do not have: row-level security, exclusion constraints, deferred constraint triggers and exact NUMERIC arithmetic. A managed PostgreSQL (in an Indian region) or your own server both work; SQLite-style stores do not.
- Migrations are forward-only and are run as the database owner:
npm run migrate. - The API connects as a separate application role,
bastralekha_app, which has no permission to delete anything and cannot bypass row-level security. It checks this when it starts and refuses to run if it could. - Use TLS with certificate verification (
sslmode=verify-full) in production. - Back up daily, and test a restore. A restore into a fresh database has been verified to reproduce every row.
Configuration
The API reads its settings from environment variables and refuses to start, naming the missing field, if any is absent. Secrets belong in a secret manager, never in an image or a file on disk.
| Variable | Meaning |
|---|---|
NODE_ENV | production for a live installation |
PORT | Port the API listens on |
RUNTIME_MODE | server for a container or VM; serverless for a function platform. Sizes the connection pool. |
LOG_LEVEL | Logging detail |
DATABASE_URL | Connection string for the application role |
DATABASE_POOL_MAX | Largest connection pool |
JWT_SECRET | Signing secret for sessions, at least 32 characters; unique to the installation |
ACCESS_TOKEN_TTL_MINUTES, REFRESH_TOKEN_TTL_DAYS | How long a sign-in lasts |
LICENCE_PUBLIC_KEY | Public key that licences and rule packs are checked against |
LICENCE_SERVICE_URL | Where the licence is activated and renewed |
DEPLOYMENT_ID | Unique to the installation; part of the licence activation |
CORS_ORIGINS | Address the web app is served from |
The web app's API address is fixed when the web app is built, so changing where the API lives means rebuilding the web app, not just editing a setting.
Where to run it
- Your own servers or a state data centre — the container and PostgreSQL on machines you control. The cleanest answer to data-residency requirements.
- Cloud — the web app on a CDN, the container on a container platform, and a managed PostgreSQL in an Indian region.
The public demo runs on free cloud tiers and is for evaluation only.
Running it
- Health:
/readyreports when the API can serve, including its database and security checks. - Monitoring: watch
/readywith an uptime check, and collect the API's structured logs. - Updates: a new build replaces the container; migrations run first. Rule packs update without a new build.
- Hardware at the outlet: any modern browser; USB or Bluetooth barcode scanners that type like a keyboard; an A4 printer and an 80 mm thermal receipt printer.