How zalo-miniapp/zaui-doctor works
Project type and purpose
• This is a single–page, front-end application (a Zalo Mini App) built with Vite, React, ZMP-UI, ZMP-SDK, Jotai, and Tailwind CSS.
• It serves as a healthcare-oriented mini program (“ZaUI Doctor”) that runs inside the Zalo client, providing booking, inquiry, feedback, search, profile, scheduling, and chat features.
File structure
• Top-level config & build files: package.json, vite.config.mts, tsconfig.json, tailwind.config.js, postcss.config.js, zmp-cli.json, app-config.json
• src/app.ts: app bootstrap and ZMP SDK initialization
• src/router.tsx: page routing definitions
• src/state.ts: Jotai atoms (state management)
• src/pages: feature pages organized by route (home, ask, booking, categories, detail, explore, feedback, profile, invoices, schedule, search, services, 404)
• src/utils: helper functions (errors, formatting, mocks)
• src/static: static assets (images for doctors, services, explore)
• CSS: multiple SCSS entrypoints (app.scss, tailwind.scss)
README for additional insights
• Architecture is purely client-side; data come from Jotai atoms which can wrap fetch calls to external APIs
• ZMP SDK is used for interacting with the Zalo host (e.g., chat with OA)
• Deployment happens via zmp-cli or VSCode extension to Zalo’s Mini App platform
• No bundled backend code in this repo
Main components & how they interact
a. Zalo Mini App Host (Zalo client)
– Provides webview container, lifecycle events, native APIs via ZMP-SDK.
b. SPA Application (delivered by Vite build)
1. Bootstrapping (src/app.ts)
• Initializes ZMP SDK and global config (app-config.json).
2. Router Layer (src/router.tsx)
• Maps URL paths → React pages, handles back button, titles.
3. Page Components (src/pages/*)
• Compose domain screens (booking, ask, feedback, etc.)
4. UI Components (src/components/*)
5. State Layer (src/state.ts with Jotai)
• Atoms represent asynchronous data (doctors, services, news, schedules, invoices).
• Components subscribe to atoms; trigger fetch/update logic.
6. Data / Network Layer (fetch calls via utils, wrapped in atoms)
• src/utils/mock.ts for local dev; replace with real fetch in atoms.
7. Styling Layer
• Tailwind + SCSS → global and component-level styling.
c. External Services
– REST APIs (hospital backend, news service, scheduling service, payments, etc.)
– Zalo OA Chat via ZMP-SDK and configured oaID in app-config.json
Architectural patterns & design principles
• Component-based UI (atomic design)
• State decoupling with Jotai atoms: separates data fetching from rendering
• Route-driven pages with metadata for back/title
• Theming via CSS variables + Tailwind utilities
• Mock data abstraction: easily replaceable with real API
• Host integration via ZMP-SDK
Final checklist
– Layers clearly separated and labeled
– Modules/components named exactly as in the code (e.g., src/state.ts, src/router.tsx, src/app.ts)
– Optional: note that Vite build produces a static bundle hosted within the Zalo Mini App