How tuienn/kma-one works
Project type and purpose
• This is a single‐page application (SPA) built with React, TypeScript, and Vite.
• It provides two user roles:
• Admin: course management, student and score management.
• User: real‐time chat, schedule/calendar viewing, point lookup.
• It uses Firebase (messaging, possibly Firestore/auth) and an external REST API (via APIService).
File structure
• Top-level:
• public/ – static assets, Firebase messaging service worker.
• src/ – all application code.
• src subdivisions:
• api/ – APIService.ts and endpoint wrappers (REST).
• firebase/ – Firebase setup (user, messaging).
• components/ – presentational and container components, organized by feature (admin / user / common).
• pages/ – route‐level components (AdminPages, UserPages).
• routes/ – React Router definitions (AdminRoutes, UserRoutes, ProtectedRoute).
• context/ – React Context providers (ChatProvider, ScheduleProvider, PathProvider).
• assets/, styles/, locales/ – images, CSS, i18n JSON.
• utils/ – shared helpers (format, storage).
• Config files: vite.config.ts, tsconfig*.json, eslint.config.js, tailwind.config.js.
Key insights from the README
• Minimal React+TypeScript+Vite setup with Fast Refresh.
• ESLint is configured; recommends type‐aware rules for production.
• No backend code here—consumption of external services is through APIService and Firebase.
Components
a. Main components
• Browser / Client Application (React SPA)
– UI Layer (Pages, Components, Layouts)
– Routing Layer (Routes, ProtectedRoute)
– State Layer (Context Providers: Chat, Schedule, Path)
– Service Layer (APIService, Firebase modules)
– Utility Layer (helpers, i18n, assets)
• External Services
– REST API endpoints (apiProvince, course/score/student management)
– Firebase (Messaging SW, Auth/Database or Firestore real‐time chat)
b. Relationships & data flow
• UI Components ←→ Context Providers ←→ Service Layer
• Service Layer → HTTP REST calls → External API
• Service Layer → Firebase SDK → Firebase backend
• Routing Layer maps URL → Page Components
c. Architectural patterns
• Feature-based folder structure
• Separation of concerns: UI, state (Context), data (Service)
• Client-side routing (React Router)
• Service abstraction (APIService wrapper over fetch/axios)
• Internationalization (i18n JSON files + content injection)
d. Key technologies
• Vite (build & dev server)
• React 18 + TypeScript
• React Router v6
• Firebase SDK (messaging, real-time features)
• ESLint, Prettier, Tailwind CSS, PostCSS