中文版

Rental Tenant Profile — Design

Tenants get an optional profile (photo plus twelve fields such as age, race, nationality, occupation, occupants and pets) that landlords see on viewing requests, offers and message threads from that tenant. Every field is optional and clearable, only the request's own landlord can read it, and the tenant sees exactly what landlords see.

  • Status Approved

View source markdown ↗ generated by claude-opus-5-5 · diagrams mermaid

Summary

Tenants get an optional profile — photo plus twelve fields such as age, race, occupation and pets — that landlords see on viewing requests, offers and message threads from that tenant. Nothing is required, every answer can be cleared, and the tenant sees exactly what landlords see.

  • Status Draft for review
  • Area backend/go/internal/modules/rental, frontend/solidstart/apps/rental
  • Audience Tenants (author) · landlords with a viewing request (reader)
  • Storage New Go table rental_tenant_profiles
  • Surfaces /tenant/profile · landlord request, offer, thread
  • Out of scope Partner /v1 API, verification, filtering

Goal

Malaysian landlords screen tenants before agreeing to a viewing. Tenants get an optional profile they can fill in from their profile page; landlords see it on viewing requests, offers and message threads from that tenant.

Success criteria

  • A tenant can fill in, change, and clear any profile field and the photo; nothing is required, and booking a viewing never depends on the profile.
  • A landlord sees the profile of a tenant who sent them a viewing request (and therefore any offer or thread from it), at any request status, before confirming, countering or declining.
  • No other landlord can read the profile.
  • The tenant sees exactly what landlords see.

Decisions taken in brainstorming

Field set
Photo, gender, age, race, nationality, occupation, employment type, occupants, planned move-in, smoker, pets, languages, about me. All optional.
Race
Included as an optional field at the product owner's direction, after the discrimination/brand risk was raised.
Excluded fields
Religion (PDPA 2010 sensitive personal data) and monthly income (unverifiable; invites payslip requests).
Visibility
Landlord who owns a viewing request from the tenant, at any status. Not public; not browseable.
Storage
New Go-owned table rental_tenant_profiles; Better Auth users table is not changed.
Partner / landlord API (/v1)
Out of scope. Web app only.
Selected

1 · Go-owned table

Typed columns per field in rental_tenant_profiles. Storage, validation and the visibility check stay together in the rental module, which already owns the tenant–landlord relationship.

Rejected

2 · Columns on Better Auth users

Via additionalFields. Couples the auth schema to marketplace fields; writes would go through bun while visibility is enforced in Go.

Rejected

3 · JSONB on users

Least schema work, but no database typing or constraints, the same auth coupling, and duplicated validation in two languages.

Data model

New table, added to the CreateRentalTables-family migrations in internal/shared/infrastructure/database/postgresql/migrations/migrator_rental.go:

CREATE TABLE IF NOT EXISTS rental_tenant_profiles (
  user_id          TEXT PRIMARY KEY,
  photo_key        TEXT,
  gender           TEXT,
  birth_year       SMALLINT,
  race             TEXT,
  nationality      TEXT,
  occupation       TEXT,
  employment_type  TEXT,
  occupants        SMALLINT,
  move_in_month    DATE,
  smoker           BOOLEAN,
  pets             TEXT[],
  languages        TEXT[],
  about            TEXT,
  created_at       TIMESTAMPTZ NOT NULL DEFAULT now(),
  updated_at       TIMESTAMPTZ NOT NULL DEFAULT now()
);

user_id is the Better Auth user id, same type as rental_viewing_requests.tenant_user_id. The row is created on first save (upsert).

Field rules

Validation lives in the domain entity entity/tenant_profile.go; the database has no enum CHECKs (matching rental_viewing_requests.status handling of evolving value sets). Every column is nullable; NULL means "not answered".

FieldAllowed valuesNotes
gendermale, female
birth_yearcurrent year − 100 ≤ y ≤ current year − 18Never sent to landlords.
racemalay, chinese, indian, bumiputera_sabah_sarawak, others
nationalitytwo uppercase letters (^[A-Z]{2}$); MY = MalaysianUI: Malaysian / Non-Malaysian → country picker over a fixed ISO 3166-1 alpha-2 list; the server checks format only.
occupation1–60 chars after trimEmpty after trim → NULL.
employment_typeemployed, self_employed, student, other
occupants1–10
move_in_monthfirst day of a month; not before the current month (Asia/Kuala_Lumpur) at save timeStored past dates stay valid when read; only rejected on save.
smokertrue / falsefalse = explicit non-smoker.
petssubset of cat, dog, other, no duplicates{} = explicit "no pets"; NULL = unanswered.
languagesnon-empty subset of ms, en, zh, ta, yue, other, no duplicatesEmpty selection → NULL.
about1–300 chars after trimEmpty after trim → NULL.

Age range

Derived at read time for landlords from birth_year and the current year (age = current year − birth year):

Age brackets landlords see, bar width proportional to years covered: 18–24 spans seven years, then 5-year brackets from 25–29 to 55–59, then an open-ended 60+. 18–24 25–29 30–34 35–39 40–44 45–49 50–54 55–59 60+
Brackets landlords see, bar width proportional to the years each covers: 18–24 spans seven years, the rest five, and 60+ is open-ended.

Backend

Ports and adapters

port.TenantProfileRepository
Get(ctx, userID) (*entity.TenantProfile, error) (returns nil, nil when no row), Upsert(ctx, *entity.TenantProfile) error, SetPhotoKey(ctx, userID string, key *string) (previous *string, err error).
port.TenantPhotoStore
New narrow port: PutTenantProfilePhoto(ctx, userID, contentType string, data []byte) (key string, err error); PublicURL(key string) string; Remove(ctx, key string) error. Implemented by the existing storage PhotoStore adapter. Keys go under rental/tenant-profiles/{userID}/{uuid}.{ext} with .jpg / .png / .webp from the content type. port.PhotoStore and its test fakes stay unchanged; the module obtains the tenant store by type-asserting the configured photo store.
Postgres adapter
tenant_profile_repository.go beside the other rental repositories.

Use case TenantProfileUseCase

  • GetOwn Own profile; all-null value when no row. self
  • Save Validate via entity, upsert, return saved profile. self
  • UploadPhoto Type image/jpeg|png|webp (else port.ErrUnsupportedProfilePhotoType), size ≤ port.MaxPhotoBytes (else port.ErrPhotoTooLarge), PutTenantProfilePhoto, SetPhotoKey, best-effort Remove of the previous key (failure logged, not returned). Nil store → port.ErrMediaUnavailable. self
  • DeletePhoto SetPhotoKey(nil), best-effort Remove. self
  • GetForOwner Load request via ViewingRequestRepository.GetByID; if req.OwnerUserID != ownerID return port.ErrRequestNotFound; otherwise load the tenant's profile and map to the landlord view. owner

Square cropping happens client-side before upload; the server stores bytes as received.

HTTP (protected group, same as /me/offers)

MethodPathResponse
GET/me/tenant-profiletenantProfileSelfJSON (all fields incl. birth_year, photo_url; nulls when unanswered)
PUT/me/tenant-profileBody: all non-photo fields; 200 tenantProfileSelfJSON; 400 ValidationError{Fields}
POST/me/tenant-profile/photoMultipart part photo (same as property photos); 200 tenantProfileSelfJSON; 400 type/size; 503 ErrMediaUnavailable
DELETE/me/tenant-profile/photo200 tenantProfileSelfJSON
GET/requests/:id/tenant-profile200 tenantProfileOwnerJSON; 404 when caller is not the request owner or the request does not exist

The owner route lives on the existing /requests group (ViewingRequestHandler routes, module.go reqGroup), so the web path is /api/rental/requests/:id/tenant-profile, matching how the frontend already addresses requests.

Landlord access gate: "not yours" and "does not exist" are indistinguishable (both 404)
Landlord access gate: "not yours" and "does not exist" are indistinguishable (both 404).
tenantProfileSelfJSON — tenant
  • Every key present, null when unanswered
  • Includes exact birth_year
  • Includes photo_url
tenantProfileOwnerJSON — landlord
  • Unanswered fields omitted (omitempty; pointers for smoker, occupants); empty profile is {}
  • age_range instead of birth_year
  • No user id, no name, no email

Known limits

Frontend (apps/rental)

Data access

src/features/rental/api/tenantProfile.ts, following api/requests (plain async functions plus tenantProfileQueryKeys; hooks stay inline in components): getOwnTenantProfile, saveTenantProfile, uploadTenantProfilePhoto, deleteTenantProfilePhoto, getRequestTenantProfile(requestId). ApiErrorEnvelope gains fields?: string[] so the form can read server field errors.

TenantProfileCard

features/rental/TenantProfileCard.tsx is a pure display of the owner-view shape, in two variants:

  • full: photo (initials avatar fallback), first name (prop), a line of answered facts (25–29 · Chinese · Malaysian · Software engineer), badges (non-smoker / smoker, occupants, move-in month, pets or "no pets", employment type, languages), about text.
  • compact: photo, first name (prop), age range and occupation; expands to full on tap.

Empty profile: "This tenant hasn't added profile details."

M

Mei

25–29 · Chinese · Malaysian · Software engineer

Non-smoker 2 moving in Move-in Nov 2026 No pets Employed English, Mandarin

Quiet and tidy, works from the office on weekdays.

Landlord-facing TenantProfileCard (full variant) — the same card renders as the tenant's "What landlords see" preview.

Tenant page /tenant/profile

  • Add { id: 'profile', href: '/tenant/profile' } as the last TENANT_RENTAL_NAVIGATION entry (rentalNavigation.ts).
  • Intro copy: "Everything here is optional. Landlords you've requested a viewing from can see what you fill in."
  • One form, four groups: About you (photo, gender, birth year, race, nationality), Work (occupation, employment type), Move-in plans (occupants, move-in month, smoker, pets), More (languages, about). Every select defaults to "Not specified"; text fields show counters; one Save button. Photo upload/remove act immediately.
  • "What landlords see" preview renders TenantProfileCard (full) from the saved self profile mapped through the same owner-view mapping in TypeScript (age range computed with the same brackets).
  • Server 400 fields highlight the matching inputs; typed values are kept.

Landlord surfaces

Viewing request

full
  • routes/landlord/viewings/[id].tsx
  • Card above LandlordRequestActions

Offer

full
  • routes/landlord/offers/[id].tsx
  • Via the offer's request_id

Message thread

compact
  • InboxView, only when userRole === 'landlord'
  • Under the conversation header, named from counterparty_name

Booking nudge

On routes/tenant/requests/[id], show a dismissible hint "Landlords respond faster when they know a bit about you → Complete profile" only while the own profile has no answered fields and no photo. Dismissal is stored in localStorage. Booking never waits on or checks the profile.

i18n

All copy and every enum label (gender, race, nationality group, employment type, pets, languages, age brackets) as paraglide messages in i18n/en.json, ms.json, zh.json. Country names via Intl.DisplayNames in the active locale.

Testing

Go

  • Entity: each field's boundaries (birth year at 18 and 100 years, occupants 0/1/10/11, text limits after trim, past move-in month rejected, unknown enum values and duplicates rejected); smoker=false and pets={} preserved distinctly from NULL.
  • Handler integration (pg-test on :55432): owner of a request from the tenant gets the profile at pending, declined and withdrawn statuses; another landlord and the tenant themselves get 404 on the owner endpoint; owner response has age_range and no birth_year; PUT with null clears a field; GET with no row returns all nulls; photo replace removes the previous object.
  • No OpenAPI drift change: openapi_drift_test.go covers only /api/v1/rental routes.

Frontend (vitest)

  • Profile form saves, clears a field, and shows server field errors.
  • Preview and landlord card render identically for the same data.
  • Landlord request page shows the empty-profile message for {} and renders actions when the profile fetch fails.
  • Nudge shows only for an empty profile and stays dismissed.
  • rentalNavigation.test.ts updated for the new entry.

Smoke (UAT, GO_ENV=development)

  1. Sign up a tenant, fill some fields and upload a photo.
  2. Book a viewing.
  3. As the landlord, see the card on the viewing request, offer and thread.
  4. As a second landlord, confirm the endpoint returns 404.

Out of scope

Partner API

not exposed

Exposing the profile through the partner / landlord /v1 API.

Verification

none

Verification of any field (ID, employment, income).

Filtering

none

Landlord-side filtering or sorting of requests by profile fields.

Deletion cleanup

all rental tables

Account-deletion cleanup across rental tables.