← All case studies

Transactional backends · 2 min read

True Dapp: purchase rules, referral commissions, and user activity

True Dapp is a Telegram mini-app backend with purchase, referral, reward, and user-activity workflows. I contributed to this shared codebase alongside other developers, with work concentrated on purchase rules, referral commissions, activity tracking, and supporting backend services.

My role
Backend contributor · shared client project
Project scope
Client-owned backend · private source
System walkthrough

The main responsibilities in this workflow.

  1. Telegram mini-app requests
  2. NestJS user and purchase services
  3. Purchase-type and referral eligibility rules
  4. TypeORM purchase / user records
  5. Commission reporting and recent-activity updates

A purchase affects more than one record

My changes include purchase-type handling, inviter lookup, commission calculations, marketer eligibility, and commission reporting. These concerns meet in the same workflow: the purchaser, inviter, and marketer can each have a different relationship to one purchase.

The implementation separates supporting operations such as finding a user, finding an inviter, validating purchase type and amount, and calculating commission. The interesting part is keeping those business conditions understandable as referral and marketer rules change.

Activity tracking has its own meaning

I also worked on last-active queries and socket tracking. The gateway retains socket entries for a time window, so its count describes recent connection activity rather than a strict count of unique users connected at that instant.

That distinction affects how an activity figure should be used. Socket identity, user identity, and the reporting time window are separate concepts. My changes included checking for existing socket entries and updating the last-active API behavior.

Support the application around its core workflows

Additional contributions cover request logging, file-service handling, and Docker Compose updates. These are smaller parts of the product, but they help developers operate and troubleshoot the backend around its purchase and user flows.

I delivered these changes in a shared codebase alongside other backend engineers.

Project notes

Collaborative backend contribution; client code remains private. The activity count describes recent socket activity rather than unique currently connected users.

Related work