How thaitamtzer/daitongquan_fe works
Project Type & Purpose
• This is a Next.js + React + TypeScript front-end application (“SGOD-DAITONGQUAN-FE”) that implements a rich admin/dashboard interface (“đại tổng quản”).
• It uses Material-UI (MUI) for styling, Next.js for SSR/SSG and routing, Axios for REST calls, and a custom state management layer under /store.
File Structure Analysis
• Top-level “client” directory holds everything:
• /public: static assets (images, locales)
• /src: source code, divided into
– @core: shared UI components, layouts, theming, utilities
– @fake-db: mock data for local dev
– app & pages: Next.js routing (app directory or pages directory)
– configs: global configuration (ACL, auth, theme, i18n)
– context & custom hooks: React Contexts (AuthContext), settings, clipboard, debounce
– layouts & views: higher-level page skeletons and detailed views for apps, dashboards, forms, etc.
– service: Axios-based API clients for each domain (users, invoices, chat, categories, stats…)
– store: application state (per feature) using a custom store pattern
– types: TypeScript interfaces for props, data models, APIs
• Config files: next.config.{js,mjs}, tsconfig.json, tailwind.config.ts, ESLint, Prettier, etc.
a. Next.js Application (SSR/CSR)
• Entry points: pages/_app.tsx, app/layout.tsx
• Routing: pages/* or app/* directory
b. UI Layer
• Views: /src/views – compose UI building blocks
• Pages: /src/pages – route-driven entry
• Core Components: /src/@core/components – generic controls (cards, checkboxes, navguards)
• Theming: /src/@core/theme, /src/styles, MUI overrides
c. State Management
• /src/store: per-feature stores (calendar, chat, email, invoice…)
• Context: /src/context/AuthContext.tsx for authentication state
d. Service Layer
• /src/service/*: Axios clients calling external REST API
• /src/lib/axios.ts: central Axios instance (baseURL, interceptors)
e. Data Flow & External Dependencies
• External API Server (backend endpoints for auth, data fetch, mutations)
• i18n JSON files under /public/locales
• CDN or hosting static assets (/public/images)
Relationships & Interactions
• Pages → Views → Core Components: UI composition
• Pages & Views dispatch actions to Store → update global state
• Service Layer called by Store or directly in hooks → HTTP calls to backend
• Context Providers wrap App → supply Auth and Settings to all components
• Next.js SSR/SSG pipeline fetches data (getServerSideProps, getStaticProps) → hydrates UI
Architectural Patterns & Principles
• Component-based architecture (Atomic to Composite)
• Separation of Concerns:
• UI (views/components) vs. Business logic (service) vs. State (store/context)
• DRY + Theming: centralized theme config and overrides
• Type safety with TypeScript (/src/types)
Essential Elements to Capture
• Next.js routing layer and entry points
• Core component library vs. feature-specific view components
• State management topology (per-feature stores + global context)
• API integration via Axios services
• Static hosting for public assets and localization files