← Back to writingNOTEBOOK / ENGINEERING NOTES

Building LionLeaders: modernizing a portal without losing its workflow

A look inside my Next.js, PostgreSQL, and Android project: client collaboration, training progress, protected files, a transactional sandbox, and lessons from development and staged testing.

  • Architecture
  • Next.js
  • PostgreSQL
  • Android
  • Testing
  • Automation

Modernizing a business portal is not simply a matter of replacing its interface. The difficult work is preserving the meaning of its workflows: who can see a record, who can change it, what counts as completed training, and what happens when a request succeeds but its response disappears.

LionLeaders is my ongoing JavaScript rebuild of a public website and authenticated client workspace. The web application uses Next.js App Router, React, and PostgreSQL. An Android application uses React and Capacitor with a native bridge for device-specific security, storage, and networking.

The project is developed and tested iteratively, with matchme.best serving as its isolated test domain. This article describes the source and development records reviewed on 4 November 2026. It does not claim a completed migration of the original production service or an iOS application based on this checkout.

Discover the workflow before rebuilding it

The project began with a read-only investigation of an existing portal. That distinction matters: observing a collaborator’s screen can establish which controls are visible, but it cannot establish what an administrator can do or whether the server enforces the permissions suggested by the interface.

The rebuild organizes the core experience into several modules:

  • MyPort: notes and tasks between authorized participants, with search, completion, editing, and protected attachments.
  • Academy: searchable training lessons, saved playback position, and per-user watched coverage.
  • Backoffice: scoped client records, staff assignment, invitations, and reversible account archiving.
  • Profile: personal details and password workflows, with selected identity fields controlled by the application.
  • HouseHour: a separate fictional sandbox for accounting, orders, work approvals, and audit experiments.

Other modules include document generation, galleries, mobile downloads, and notification workflows. The useful architectural unit is the business operation, not the page that happens to display it.

Some legacy behaviors remain subject to reconciliation with original source and data exports. Where the replacement makes an explicit policy choice, it should be documented as that choice rather than presented as a verified reproduction of an unseen backend.

One application, shared domain rules

The web application combines public content, authenticated pages, API handlers, and domain services. PostgreSQL holds accounts, sessions, workflow records, progress, and audit-related state. Infrastructure and storage adapters sit behind that application layer.

Layer Responsibility Design concern
Public site and authenticated UI Navigation, forms, learning, client and staff screens Shared presentation must not imply shared access
Server handlers and domain modules Validation, authorization, workflow transitions Enforce rules independently of displayed buttons
PostgreSQL Durable business state and transactional changes Preserve invariants under retries and concurrent requests
Protected file storage Attachments, training media, shared assets Authorization and byte integrity are separate checks
Mobile API and native bridge Android access to shared workflows and local capabilities Limit dispatch authority and bind local data to its context
Deployment control Serving eligibility, releases, backups, recovery A running instance is not automatically authorized to serve

This is a modular application, not a claim of independently deployed microservices. Shared domain behavior reduces the risk of implementing different permissions for the web and mobile interfaces. It also makes clear boundaries important: a mobile dispatcher must not become an unrestricted tunnel into every server operation.

The mobile policy explicitly allowlists supported route families, validates device identifiers, and accepts a constrained bearer-token format. The server still owns authorization. A native interface does not make client-supplied ownership or role information trustworthy.

Permissions need to follow the record

The portal’s roles are not merely visual variations. Notes have participant visibility; client records have staff assignments; administrators and collaborators have different authority; clients do not inherit Backoffice access.

The account lookup checks an active user and a non-expired session. Session tokens are hashed in PostgreSQL, while browser cookies carry the opaque credential. Password-change-only sessions are treated differently from ordinary portal access, so a newly created account can be required to complete that workflow before reaching protected APIs or native-token issuance.

Backoffice also demonstrates why lifecycle behavior belongs in the domain model. Archiving revokes access while retaining notes, attachments, and learning history. Restoring an account does not make previously revoked credentials valid again.

As the project evolved, invitation policy changed too. Earlier milestone notes describe broader collaborator invitation behavior; later registration work restricts new invitations to administrators. That is a reminder to check current code and later implementation records instead of treating the earliest README as a permanent permission specification.

The development lesson is to test access through actual server operations. Hiding an administrative control is useful interface design, but it is not an authorization test.

Training progress is not the playback position

Academy exposed a small but important modeling problem. A video player can report that a user is at the end of a lesson even when they reached it by seeking. If completion is derived from the latest position, the application confuses navigation with viewing.

The implementation stores played intervals and computes their union. Overlapping or repeated playback does not add duplicate credit. Seeking changes the resume position without adding watched time. The current demonstration completion rule is 95% coverage.

Updates are validated and bounded; the persistence workflow merges coverage transactionally. Resume position and coverage intentionally have different semantics. Media endpoints also support protected byte-range responses so normal browser seeking can work without making training files public.

This is a practical progress model, not an anti-cheating or certification mechanism: a modified client can fabricate playback intervals. The sample lessons are explicitly labeled demonstrations, not imported corporate training.

The broader lesson is to define the product metric before implementing its indicator. “Where did playback stop?” and “How much content was watched?” are different questions.

File publication crosses a database boundary

The first local milestone stored attachment bytes in PostgreSQL. The later shared-storage adapter supports external file keys while retaining a path for older database-backed records.

Publication writes a temporary file, flushes it, and atomically links it to an immutable destination. If a destination already exists, matching checksums make publication repeatable; conflicting content is rejected. Reads check both stored size and checksum.

This matters because a database transaction cannot, by itself, make an independent filesystem write transactional. The application needs an explicit publication contract, a way to detect missing or corrupted bytes, and a reconciliation path.

Path validation restricts the accepted key shapes instead of allowing arbitrary filesystem paths. Private downloads remain authorized operations even when their bytes live on shared storage. A checksum establishes integrity relative to recorded metadata; it does not decide whether the requesting user may receive the file.

The lesson is to separate three concerns: where bytes are stored, whether those bytes are intact, and who is allowed to access them.

HouseHour: make transactional experiments explicit

HouseHour is a fictional sandbox. It is not a real-money investment service, property-ownership register, payment-settlement network, or independent blockchain.

Its engineering value is in exploring transactions and workflow invariants. The model uses integer monetary amounts and whole-unit quantities, separates available and reserved balances, and gives different participants authority over proposals, work, reviews, and disputes.

The server executes mutations within PostgreSQL transactions and serializes the shared sandbox state using transaction-scoped locking. Requests carry an idempotency key and a generation identifier. A generation distinguishes the current sandbox from a previous reset, preventing an old unrecorded request from silently changing a new scenario.

An exact recorded replay can return its original response. Reusing a key for different content is rejected. On the client, the mutation key remains available when a response is lost or the subsequent refresh fails, so retrying retrieves the original intention rather than creating another one.

This is a useful lesson well beyond the sandbox: a failed refresh after a successful mutation is not evidence that the mutation failed.

The audit layer hashes a canonical event representation, links each event to its predecessor, and signs checkpoints. Verification checks the event chain, associated postings, and trusted signing key. A verifier must obtain that trust anchor independently and retain checkpoints if it wants to detect later history replacement or truncation. A signature included in the same export does not establish its own authority.

These mechanisms support inspectable, tamper-evident records under stated assumptions. They should not be described as tamper-proof history.

Android adds lifecycle and offline failure modes

The Android client packages a React interface, but important behavior lives in native code. Its vault uses Android Keystore-backed AES-GCM, binds encrypted records to their storage context, and supports integrity-checked encrypted streams. Activity lifecycle handling locks access when the application pauses.

Development records describe fixes for atomic encrypted writes, account-bound notifications, restored drafts, offline playback, and document exports. These are not cosmetic mobile concerns. A backgrounded activity, interrupted response, or partially written file can change what a user sees when they return.

The recorded emulator checks also distinguish Android versions and deployment targets. Some combined runs encountered timing failures, followed by focused passing retests. Preserving both results is more informative than rewriting that history into one completely green run.

The lesson is to test transitions: pause and resume, lock and unlock, lose a response, reopen a draft, and switch accounts. A successful first screen is only the beginning of mobile acceptance.

Email readiness is part of the workflow

Transactional email arrived after the original local-outbox milestone. The later design creates notification events with the business transaction and processes them through a durable outbox. Sensitive verification-link payloads are encrypted separately from ordinary queue metadata.

Before sending, the worker rechecks account state, event access, link validity, and serving eligibility. An uncertain send outcome is retained rather than automatically retried as if delivery definitely failed. “Sent” means acceptance by the email provider, not proof that a recipient read or even received the message.

Public registration is gated on provider readiness. A verified domain alone is not proof that ordinary production sending is available. The reviewed implementation notes record provider approval as a separate operational dependency; the article does not claim a fresh check of that provider status.

This keeps deployment success separate from workflow success. A registration form is not usable if its verification message cannot be delivered through the intended channel.

Recovery design should not exaggerate availability

The deployment records describe a lean test environment with serving application and database infrastructure in Frankfurt. Other regional backup locations are not active serving replicas. The repository also retains a broader recovery design, but its presence is not evidence that the test deployment is active-active.

The application checks a serving-authority record before AWS-mode operations. Missing configuration, an unknown state, the wrong region, or a failed authority lookup denies service rather than guessing that the instance is allowed to write.

That reduces accidental activity from a standby or recovery candidate. It does not, by itself, prove a complete split-brain prevention protocol under every failure sequence. Recovery still needs coordinated authority changes, data readiness, validation, and a rehearsed operational procedure.

Versioned releases and retained previous artifacts make deployment and rollback inspectable. A backup existing in another region is useful, but restoration and service activation must be verified separately.

Design changes need bounded regression evidence

The recent web design refresh reused an approved Android visual direction across public and authenticated pages. It added coordinated light, dark, and system appearance, responsive navigation, and consistent module controls.

Its validation records distinguish presentation changes from domain behavior: service and API files were compared with the prior release, contrast checks covered selected color pairs, and browser checks exercised both public and authenticated layouts. Those checks are valuable without becoming a claim of complete accessibility certification or a new financial load test.

That is a repeatable way to evolve a business interface: identify the intended change boundary, verify it visually, and show which behavior-bearing files remained unchanged.

What the testing evidence means

The repository contains pure tests, database and HTTPS integration tests, infrastructure-policy tests, browser checks, and Android instrumentation records. Together they cover permissions, origin validation, session lifecycle, attachment integrity, progress semantics, idempotent requests, mobile dispatch, and selected deployment behavior.

I reviewed those sources and records for this article without running the project’s test scripts, changing its database, sending email, or modifying existing client data. Historical passing results are not a fresh whole-system acceptance run. Physical-device checks, legacy permission reconciliation, real content migration, and production cutover remain separate milestones where the records say they are incomplete.

The main lesson from LionLeaders is that modernization succeeds when behavior becomes more explicit. Permissions follow records. Progress has a defined meaning. Retries preserve the original intention. Files have integrity contracts. Mobile transitions and deployment authority have visible states.

Those contracts are what allow a modern interface to become a dependable business application rather than a convincing demonstration.