How minhduc1706/pawlish-admin works
Project Type and Purpose
• This is a single-page application (SPA) built with React, TypeScript, and Vite.
• It serves as an admin/staff dashboard for a pet care or pet retail management system, providing UIs for appointments, inventory, user management, feedback, reporting, chat, and notifications.
• All “backend” behavior (authentication, data CRUD, real‐time chat) is consumed via HTTP/REST and WebSocket from external services or microservices.
High-Level File Structure Analysis
• src/
• App.tsx, main.tsx, index.html: entry points and HTML shell
• api/: Axios-based clients for each domain (appointment, user, inventory, etc.)
• auth/: route protection components
• components/: UI components organized by domain (admin, staff, auth) and low-level UI primitives
• config/: HTTP client & React Query client configuration
• hooks/: custom React hooks wrapping queries & mutations
• queries/: React Query wrapper hooks
• redux/: slice-based global state for auth, chat, search
• store/: root reducer and typed hooks
• interfaces/: TypeScript types for domain entities
• public/: static assets
• config files: vite.config.ts, tsconfig.json, eslint.config.js
Key Architectural Patterns & Technologies
• Component-based UI (React TSX)
• Client-side routing with protected routes
• State management:
• React Query for server state (data fetching + caching)
• Redux Toolkit for real-time chat & cross-slice search state
• Network layer: Axios client abstraction + domain service modules in src/api
• Real-time communication: WebSocket (via redux/chat/socket.ts)
• Styling & design system: custom UI primitives under components/ui
• Build & HMR: Vite + @vitejs/plugin-react
a. Frontend (Browser)
• React App
• Component Tree: Top-level Layout → Admin/Staff/UIs
• Router: Auth routes vs. Protected Dashboard routes
• State Layers: React Query & Redux Store
• API Client Layer: axiosClient → domain services
• WebSocket Client (chat)
b. Backend Services (External)
• Auth Service (login/register, JWT)
• REST API Service exposing endpoints for appointments, products, users, etc.
• WebSocket / Chat Service for real-time messaging
• Notification Service (push or polling)
• Possibly third-party services (e.g., payment gateway, email/SMS)
c. Data Stores
• Main relational/NoSQL database behind the REST API
• In-memory cache via React Query
• Redux store slice for chat and search
Interactions & Data Flow
• On page load, React App
→ initializes React Query & Redux store
→ renders AuthLayout or DashboardLayout based on JWT presence
• For data views (e.g., Inventory, Dashboard stats):
React Component → custom hook in src/hooks → React Query → Axios client → REST API → JSON → React Query cache → component render
• For chat: WebSocket → redux/chat/socket → dispatch chatSlice updates → Chat UI
• For stateful actions (e.g., login, logout): Redux Thunk → Axios → Auth slice → redirect
Essential Elements
• Clear labels: “Browser”, “React App”, “Redux Store”, “React Query Cache”, “REST API”, “WebSocket Server”.