Lee ChanyangBackend Engineer

Language

← Back to project list

Content Commerce Backend

LiveGlobal

Educational Content & Community Service

I connected video course purchases, small community rewards, and point grants based on offline package payments in a single educational service backend, incorporating language, country, and currency rules into the models.

Company
Korea Institute of Psychological Education
Service
Goodbye Blue
Period
2025.09–2026.05 · 9 months
Role
Backend Engineer
Responsibility
User/Admin API · DB · Async/Batch · AWS Ops
Team
BE 1 · FE 2 · Designer 1 · PM/Ops 1
  • NestJS
  • TypeScript
  • PostgreSQL
  • Prisma
  • BullMQ
  • Redis
  • AWS
  • NICEPAY · PayPal (PG)
  • Claude · Codex

Project Overview

I consolidated distributed content and member activity into one educational service backend

The initial task was to consolidate scattered video, review, and member data into one service, connecting course discovery, purchases, entitlement issuance, and community participation in the same user journey.

As the project progressed, this flow expanded to payments and refunds, point accounting, referrals and tiers, events and notifications, and operational infrastructure. I treated it as a backend integration effort that redefined responsibilities and state criteria for content, access, orders, rewards, and notifications, rather than as a single feature addition.

Community activity provided small point rewards, while administrative grants based on offline package payments were the primary source of large point grants. I unified their settlement structure so that grants, spending, and refunds followed the same recording rules instead of scattering the two flows across separate logic.

I owned the backend overall, designing and implementing boundaries for registration, email verification, social account linking, consent to terms, courses, entitlements, community features, payments, rewards, notifications, settlement, and administrative APIs. I built a structure that connected purchase and activity events to operational policies and point accounting while supporting reprocessing after failure.

Ownership

My direct responsibilities

  • Refined point, referral, tier, and refund policies with product planning and operations, and shared Swagger/OpenAPI-based API contracts with the frontend team
  • Implemented unified membership, email/social authentication, consent to terms, user/admin access boundaries, and administrative APIs
  • Implemented course discovery, purchases, entitlements, community features, and NICEPAY card, virtual account, point payment, and refund flows
  • Unified small post/comment rewards and large point grants based on offline package payments in one settlement structure, managing grant, spending, and refund histories
  • Built language, country, and currency policy models and PostgreSQL, Redis, and AWS deployment and operations environments

Constraints

Constraints to address first

  • While consolidating existing members, email/social authentication, service-specific access, and consent to terms needed separate responsibilities, with admin approval and role boundaries maintained independently.
  • Community rewards and administrator-issued points differed in their basis and amount, requiring separate scheduled grants, finalized change histories, and current balances.
  • Repeated events or batch runs and overlapping accruals, spending, and refunds had to avoid duplicate postings and ledger/balance discrepancies.
  • Reward, tier, referral, catalog, language, country, and currency policies changed at different rates, requiring preservation of change histories and the rules in effect at each transaction.
  • Failures in external integrations such as payments and notifications had to preserve finalized monetary records and allow only the failed follow-up work to be rerun.

Implementation Timeline

How course and community requirements expanded into payments, rewards, and operations

I organized the requirements arising from course purchases and community participation into phases, based on design and architecture documentation and retrospectives. Select a phase to see the problem identified at that stage and how it led to the architecture and verification criteria.

Phase 01 · Membership and Authentication

Membership and Authentication

Phase 01

I unified distributed member data around authentication, consent, and service access

Consolidating member data meant more than merging user tables: it required aligning email verification, local/social login, service-specific registration states, terms and optional consent, and token refresh strategies within one user identification flow. Because course purchases, community activity, referral rewards, and notifications would all rely on this identity foundation, I first established who was acting in which service, with what consent and authentication state.

  • Email registration first checks a verified token; social registration adds the OAuth identity and verified token within the registration transaction.
  • Required terms are validated by version ID and optional consent is saved by purpose ID, separating changes to terms wording from signup history.
  • Separating the core member record, authentication methods, and service-specific accounts allows one user to have multiple login methods and service access states.
  • Refresh tokens are stored only as hashes, never as raw tokens, and are replaced with a new token and hash on reissue.
Registration, Authentication, and Consent BoundariesMermaid

Rendering the diagram.

  1. 01

    Requirements Analysis

    While migrating existing members to unified service users, I distinguished eligibility to register from eligibility to log in.

    • Email verification attempts and email delivery were separate states that could fail, expire, or be requested again; member creation had to be finalized only once.
    • Social login had to distinguish linked accounts, existing members with the same email address, and new social signups to prevent duplicate members and fragmented histories.
    • Because a user could enter through multiple service contexts, I needed separate responsibilities for the core member record, signup source/migration state, and service-specific account models.
    • Terms and optional marketing consent had to preserve the version, consent choice, channel, region, and request context at signup, rather than just the current wording.
    • Refresh tokens required a rotation strategy that compared them against stored hashes and replaced them with new tokens, rather than simply reissuing them.
    • Admin accounts could share authentication mechanisms, but their approval states and role permissions required lifecycles separate from user accounts.
  2. 02

    Domain Modeling

    I separated the core member record, authentication methods, service-specific accounts, consent to terms, and optional consent into distinct responsibilities within registration.

    • The core member record preserves email, profile, signup source, and default language, while authentication methods separately track email/social providers and active states.
    • The authentication model stores email authentication and OAuth providers as separate links under the same user, with identifiers and active states tracked per provider.
    • Service-specific account models preserve the service code, active state, and authentication method used at signup, separating credential verification from service access eligibility.
    • I validated consent to terms against required terms versions and optional consent against its purpose, preserving the request context at registration.
  3. 03

    Architecture Decisions

    I completed pre-registration validation outside the transaction, then grouped member, identity, service account, and consent history into one registration commit.

    • I first checked the email verification token type, duplicate emails and nicknames, required terms versions, and optional consent purposes.
    • Within the registration transaction, I committed member creation, email identity creation, additional OAuth identity and verified signup token records for social registration, the service account, terms, and consent together.
    • For social login with no linked identity but an existing user with the same email, I returned LINK_REQUIRED and a link token instead of immediately creating an account, adding the social identity only after explicit linking.
    • Users and admins share JWT and Guard mechanisms, but have separate actors, secrets, repositories, admin approval states, and role guards.
    • Login responses include access tokens, refresh tokens, and profile data only after service access eligibility and completed email verification have been checked.
    • Access tokens are validated by actor from the Bearer header. Refresh tokens are received through cookies or a dedicated header; after checking token type, actor-specific signature, and stored hash, they are rotated to a new token and hash.
  4. 04

    Implementation & Verification

    I implemented distinct failure states for registration, login, social login, social linking, email verification, and refresh token flows, returning only the next action the user needed to take.

    • Email verification tokens distinguish purposes such as registration, password reset, and social account linking through token types.
    • I separated authentication methods into provider-specific identities so that email registration, social registration, and linking a social provider to an existing account shared the same user identification rules.
    • I checked service-specific account states separately to distinguish cases where login credentials were valid but access to that service was unavailable.
    • I separated login failures by the next required action: user not found, social-only account, password mismatch, or unverified email.
    • Social account linking checks link token expiration, masking of the existing email address, provider active state, and duplicate identities before connecting the existing account and social provider.
  5. 05

    Operations & Recovery

    Member inquiries and login issues can be investigated through authentication tokens, identities, service-specific accounts, consent to terms, and refresh token hashes in sequence.

    • Registration failures can be narrowed down by checking email verification, duplicate email/nickname, required terms consent, and service-specific account creation, in that order.
    • Login failures are checked separately for identity linkage, service access eligibility, and completed email verification.
    • Social login failures are treated as distinct operational states: no linked identity, an existing member with the same email address, or an expired link token.
    • Admin authentication issues are investigated through actor, approval state, role permissions, and refresh token hash separately from user authentication.
    • Token refresh failures are checked separately for token type, actor-specific signature, stored hash mismatch, and user state.

Project Infrastructure

I migrated from a single EC2 instance and shared ALB to a dedicated ALB and ASG

I migrated from a shared ALB, single EC2 instance, and SSH deployment to a dedicated ALB, ASG, and CodeDeploy structure, separating replacement, verification, and recovery criteria.

  • I used Outbox and NotificationDelivery states to determine which operations were finalized and where processing had stopped.
  • I classified DEAD, FAILED, and stalled entries for reprocessing by type, cause, and idempotency criteria, rather than rerunning everything.
  • I diagnosed queue backlogs, external provider outages, and FCM outages using operational criteria distinct from domain transaction failures.
  • I did not report inaccessible p95 response latency, error rate, or uptime data as performance results; I retained only evidence from states, logs, and operational documentation.
Transition process

Shared ALB and Single EC2 → CodeDeploy → Dedicated ALB and ASG

I first moved SSH deployment into a CodeDeploy pipeline, then organized execution, replacement, and verification units around a service-dedicated ALB and ASG.

Selecting a stage updates both the explanation on the right and the infrastructure diagram below.

Starting point

Shared ALB, Single EC2 Instance, and SSH Deployment

Before the migration, services were separated by Host Header rules on a shared ALB and deployed to a single EC2 instance through SSH.

  • Multiple services shared ALB Host Header rules, creating strong coupling between services
  • A single EC2 instance required manual recovery after failure because it was not automatically replaced
  • The remaining SSH deployment flow limited tracking of deployment targets and execution results
  • Direct changes inside an instance could be lost on replacement, requiring defined sources for configuration changes
Initial InfrastructureMermaid

Rendering the diagram.

Outcome & Review

I documented both an operational consistency structure and its remaining risks

  • During four months from 2026.04?07, I personally reviewed and verified settlement results each month, closing monthly settlement without duplicate payouts, ledger/balance discrepancies, or manual corrections.
  • I operated the flow from small community rewards and point grants based on offline package payments through settlement, spending, refunds, and expiration, with recovery criteria separated into states, logs, and operational documentation.
  • The causes and change histories of accruals, spending, refunds, and expiration can be traced through finalized records and spending sources.
  • Both service code and database constraints defend against reruns, duplicate events, and concurrent balance changes.
  • Separating domain events from notification failures reduced the failure scope of monetary processing.

Outcome

Verifiable outcomes

  • Operated grant, settlement, spending, refund, and expiration flows connecting small community rewards with point grants based on offline package payments
  • Protected against duplicate payouts and balance discrepancies through conditional claiming, Wallet row locks, and Ledger idempotency keys
  • Defined model and service boundaries so categories, terms, notifications, and payment currencies share language/country rules
  • Tracked point spending, refunds, and expiration through Lots from original transactions
  • Connected policy-based tier/referral rewards to Outbox and notification pipelines

Limitations

Limitations and unimplemented scope

  • I do not publish exact monthly processed record counts, TPS, or P95 figures because I could not verify them from preserved operational data.
  • State validation in some cancellation APIs could be made more atomic through conditional updates.
  • Retry policies by notification delivery class and WebSocket channels remain future extensions.
  • Multi-region routing and a multi-entity point platform are presented only as ADRs and a long-term transition strategy, not as completed implementation.