Skip to main content

Kiến Trúc Golden Lotus App

Định Hướng

Expo Router vẫn nằm trong app/ và chỉ đóng vai trò route layer. Code production nên được chuyển vào các domain module trong features/, còn route trong app/ chỉ import screen component từ các module đó.

Các Layer

core/
api/ HTTP client cấp thấp, API errors
auth/ session store, auth/session types, token storage
config/ đọc và chuẩn hóa environment
query/ React Query client và query keys
storage/ adapter cho storage

shared/
design/ token bám theo Figma
ui/ UI primitives dùng lại
utils/ helper dùng chung nhiều feature

features/
auth/
home/
membership/
points/
vouchers/
booking/
branches/
services/
profile/
notifications/
social/

Quy Tắc

  • File trong app/ nên compose screen, không sở hữu domain logic.
  • Feature module sở hữu api.ts, hooks.ts, types.ts, mocks.ts, screens/, và components/.
  • Shared UI không được import code từ feature.
  • API call của feature đi qua core/api/client.
  • React Query keys lấy từ core/query/keys.
  • Session state lấy từ core/auth/session.store.
  • Mock mode được điều khiển bằng EXPO_PUBLIC_USE_MOCK, không hard-code trong từng service.

Tương Thích Hiện Tại

Các import legacy vẫn dùng được:

  • @/api/client re-export @/core/api/client
  • @/store/authStore re-export @/core/auth/session.store
  • @/constants/* vẫn tồn tại, nhưng đã được chống lưng bởi token trong shared/design