A small Student Exam Marks / Report Card system, built to exercise every piece an Epinio "complex application" needs to touch:
| Piece | Where |
|---|---|
| Frontend | frontend/ - React SPA (teachers enter marks, students view results) |
| Backend | backend/ - Node/Express REST API + PostgreSQL |
| Microservice | report-service/ - Node/Puppeteer PDF report-card renderer |
| Custom Service (Service Catalog) | service-catalog/ - registers a Bitnami-PostgreSQL-backed catalog entry |
| Custom Buildpack | builder/ - installs Chromium's runtime libraries so Puppeteer can launch |
.epinio-sync.yaml |
frontend/.epinio-sync.yaml - live-reload dev loop via epinio app watch |
| Epinio manifests | epinio.yml in each app directory |
┌──────────┐ /api/* ┌──────────┐ POST /render ┌────────────────┐
│ frontend │ ───────────────▶ │ backend │ ──────────────────▶│ report-service │
│ (React) │ ◀─ PDF / JSON ── │ (Express)│ ◀── PDF buffer ──── │ (Puppeteer) │
└──────────┘ └────┬─────┘ └─────────────────┘
│ bound Configuration
▼
┌──────────────────┐
│ examresults-db │
│ (PostgreSQL, from │
│ the Service Catalog)│
└──────────────────┘
The frontend never talks to report-service directly - the backend proxies
the PDF request. That keeps the microservice an internal implementation
detail and means only one app's route needs to be public-facing from the
frontend's point of view.
docker compose up --buildThen open http://localhost:8080. The backend runs its own migration
(backend/src/db/migrate.js) on container start, and seeds five subjects.
Add a student and some marks on the Teacher tab, then switch to Student to
view results and download a PDF report card.
This uses Dockerfile.dev files in each app directory, which exist only
for this local loop - they are not used when deploying to Epinio, which
builds each app from source with a buildpack instead (see below).
This full loop has been run and verified: students/subjects/marks CRUD,
the grading/percentage math, the frontend UI (including the runtime
API_URL config injection), and report-service actually rendering a real
PDF (%PDF-1.4 magic bytes confirmed) both directly and proxied through the
backend. One real bug was caught and fixed in the process: Puppeteer v23's
page.pdf() returns a Uint8Array, not a Node Buffer - res.send() only
writes raw bytes for an actual Buffer, otherwise it JSON-serializes the
typed array one byte at a time. report-service/src/index.js now wraps the
result in Buffer.from(...) before sending it.
Requires a running Epinio installation and epinio target <namespace>
already set. None of the steps below were run against a live cluster while
building this example (none was available) - treat them as a correct,
carefully-researched starting point, not a verified one, and see the
caveats in builder/README.md and
service-catalog/README.md.
-
Register and create the database service (once per cluster, then once per deployment):
cd service-catalog bash create-catalog-entry.sh # operator step, run once per cluster epinio service create examresults-postgresql examresults-db
-
Build the custom builder image for the report-service (see
builder/README.mdfor the fullpackcommand and the Paketo version you need to pin first). -
Push the backend and bind the database to it:
cd backend epinio push -f epinio.yml epinio service bind examresults-db examresults-backend
-
Push the report-service, with the custom builder image set in its
epinio.yml:cd report-service epinio push -f epinio.yml
Then wire the backend to it:
epinio app show examresults-report-service # note its route epinio app update examresults-backend -e REPORT_SERVICE_URL=https://<that-route>
-
Push the frontend, then point it at the backend's route the same way:
cd frontend epinio push -f epinio.yml epinio app show examresults-backend # note its route epinio app update examresults-frontend -e API_URL=https://<that-route>
-
Iterate on the frontend without a full rebuild using the sync file:
epinio app watch examresults-frontend(
epinio app watchis marked experimental upstream and validated on a limited set of builders - seefrontend/.epinio-sync.yamlfor the exact config and docs link.)
A step-by-step version of this, written for someone following along rather than skimming a README, is the subject of the companion docs PR (see below).
backend/src/db/pool.jsreads the bound Postgres Configuration's values from/configurations/examresults-db/<key>with a guessed set of common key-name aliases (host,username,password, ...), since the exact secret keys the Bitnami PostgreSQL chart produces couldn't be confirmed without a live cluster. Runepinio app exec examresults-backend -- ls /configurations/examresults-dbafter binding and adjustFIELD_ALIASESin that file (or just setPGHOST/PGUSER/etc. directly withepinio app update -e ...) if none of the guesses match.builder/builder.tomlneeds the currentpaketo-buildpacks/nodejsversion/image filled in beforepack builder createwill work.service-catalog/create-catalog-entry.sh'sCHART_VERSIONdefault should be checked againsthelm search repo bitnami/postgresql --versions.- Inter-app URLs (
REPORT_SERVICE_URL,API_URL) are wired manually viaepinio app update -eafter each app's public route is known, since Epinio's in-cluster Service name for an app is a hashed, non-obvious string rather than something derivable from the app name.