VN📚 Chỉ Mục Codebase

📚 CHỈ MỤC CODEBASE THINCADMIN ERP

Tổng quan kiến trúc hệ thống và cấu trúc mã nguồn


🏗️ Kiến trúc tổng thể

1.1. Stack công nghệ

  • Frontend: Next.js + React + TypeScript
  • Documentation: Nextra (Next.js-based documentation framework)
  • Authentication: Firebase Authentication
  • Database: Firebase Firestore (NoSQL)
  • Deployment: Vercel/Cloud hosting
  • Styling: CSS Modules + Material-UI components

1.2. Cấu trúc thư mục

SOC-DOCS/
├── components/           # React components tái sử dụng
├── pages/               # Nextra documentation pages
│   ├── VN/             # Vietnamese documentation
│   └── *.mdx           # English documentation
├── public/              # Static assets
├── theme.config.tsx     # Nextra theme configuration
└── package.json         # Dependencies & scripts

📁 Chi tiết từng module

2.1. Components (/components/)

  • counters.tsx - Component hiển thị số liệu thống kê
  • counters.module.css - Styling cho component counters

2.2. Pages (/pages/)

Tiếng Anh

  • index.mdx - Trang chủ giới thiệu
  • overview.mdx - Tổng quan hệ thống
  • benefits.mdx - Lợi ích của hệ thống
  • guide.mdx - Hướng dẫn sử dụng
  • signup.mdx - Đăng ký và onboarding
  • workflow.mdx - Quy trình làm việc
  • advanced.mdx - Tính năng nâng cao
  • spa-onboarding.mdx - Onboarding cho Spa ERP + IoT

Tiếng Việt (/pages/VN/)

  • index.mdx - Trang chủ tiếng Việt
  • overview.mdx - Tổng quan hệ thống
  • benefits.mdx - Lợi ích của hệ thống
  • guide.mdx - Hướng dẫn sử dụng
  • signup.mdx - Đăng ký và onboarding
  • workflow.mdx - Quy trình làm việc
  • advanced.mdx - Tính năng nâng cao
  • spa-onboarding.mdx - Onboarding cho Spa ERP + IoT

2.3. Configuration Files

  • theme.config.tsx - Cấu hình Nextra theme
  • next.config.js - Cấu hình Next.js
  • tsconfig.json - Cấu hình TypeScript
  • package.json - Dependencies và scripts

🔧 Tính năng hệ thống

3.1. Authentication & Authorization

  • Firebase Authentication - Xác thực người dùng
  • Role-based Access Control - Phân quyền theo vai trò
  • Token Management - Quản lý token xác thực

3.2. Core Modules

  • Dashboard - Bảng điều khiển tổng quan
  • User Management - Quản lý người dùng
  • Inventory Management - Quản lý kho hàng
  • Appointment Scheduling - Lịch hẹn
  • POS System - Hệ thống bán hàng
  • Reporting - Báo cáo và thống kê

3.3. IoT Integration

  • MQTT Protocol - Giao thức kết nối IoT
  • REST API - API tích hợp bên thứ ba
  • Real-time Data Sync - Đồng bộ dữ liệu thời gian thực

🚀 Deployment & Hosting

4.1. Production Environment

  • Domain: erp.thinctech.org
  • Documentation: docs.soc.thinctech.org
  • CDN: Vercel Edge Network
  • SSL: Automatic HTTPS

4.2. Development Environment

  • Local Development: pnpm dev
  • Build Process: pnpm build
  • Static Export: Nextra static generation

📊 Database Schema (Firebase Firestore)

5.1. Collections

// Users Collection
users: {
  uid: {
    email: string,
    role: 'admin' | 'manager' | 'front-desk' | 'therapist',
    displayName: string,
    createdAt: timestamp,
    lastLogin: timestamp
  }
}
 
// Appointments Collection
appointments: {
  appointmentId: {
    customerId: string,
    therapistId: string,
    serviceId: string,
    roomId: string,
    startTime: timestamp,
    endTime: timestamp,
    status: 'scheduled' | 'in-progress' | 'completed' | 'cancelled',
    paymentStatus: 'pending' | 'paid' | 'refunded'
  }
}
 
// Services Collection
services: {
  serviceId: {
    name: string,
    description: string,
    duration: number, // minutes
    price: number,
    category: string,
    isActive: boolean
  }
}
 
// Inventory Collection
inventory: {
  productId: {
    name: string,
    description: string,
    category: string,
    quantity: number,
    minQuantity: number,
    price: number,
    supplier: string,
    lastUpdated: timestamp
  }
}

🔌 API Endpoints

6.1. Authentication

  • POST /api/auth/login - Đăng nhập
  • POST /api/auth/logout - Đăng xuất
  • POST /api/auth/register - Đăng ký
  • GET /api/auth/user - Lấy thông tin user

6.2. Appointments

  • GET /api/appointments - Lấy danh sách lịch hẹn
  • POST /api/appointments - Tạo lịch hẹn mới
  • PUT /api/appointments/:id - Cập nhật lịch hẹn
  • DELETE /api/appointments/:id - Xóa lịch hẹn

6.3. Inventory

  • GET /api/inventory - Lấy danh sách sản phẩm
  • POST /api/inventory - Thêm sản phẩm mới
  • PUT /api/inventory/:id - Cập nhật sản phẩm
  • DELETE /api/inventory/:id - Xóa sản phẩm

6.4. IoT Integration

  • POST /api/iot/sensor-data - Nhận dữ liệu cảm biến
  • GET /api/iot/room-status - Lấy trạng thái phòng
  • POST /api/iot/control-device - Điều khiển thiết bị IoT

🛡️ Security Features

7.1. Authentication Security

  • JWT Tokens - JSON Web Tokens cho session management
  • Refresh Tokens - Auto-refresh authentication
  • Password Hashing - bcrypt encryption
  • Rate Limiting - Prevent brute force attacks

7.2. Data Security

  • Firebase Security Rules - Database access control
  • CORS Configuration - Cross-origin resource sharing
  • Input Validation - Sanitize user inputs
  • SQL Injection Prevention - Parameterized queries

📈 Performance Optimization

8.1. Frontend Optimization

  • Code Splitting - Lazy loading components
  • Image Optimization - Next.js image optimization
  • Caching Strategy - Browser and CDN caching
  • Bundle Analysis - Webpack bundle analyzer

8.2. Backend Optimization

  • Database Indexing - Optimize Firestore queries
  • Connection Pooling - Efficient database connections
  • Caching Layer - Redis caching for frequently accessed data
  • CDN Integration - Global content delivery

🔄 Version Control & CI/CD

9.1. Git Workflow

  • Main Branch - Production-ready code
  • Feature Branches - New feature development
  • Pull Requests - Code review process
  • Automated Testing - Unit and integration tests

9.2. Deployment Pipeline

  • Development - Local development environment
  • Staging - Pre-production testing
  • Production - Live application deployment
  • Rollback Strategy - Quick deployment rollback

📞 Support & Maintenance

10.1. Monitoring

  • Error Tracking - Sentry integration
  • Performance Monitoring - Vercel Analytics
  • Uptime Monitoring - Health check endpoints
  • Log Management - Centralized logging

10.2. Backup Strategy

  • Database Backups - Daily automated backups
  • Code Repository - GitHub version control
  • Configuration Backups - Environment variables backup
  • Disaster Recovery - Multi-region deployment

ThincAdmin ERP được xây dựng với kiến trúc hiện đại, đảm bảo tính ổn định, bảo mật và khả năng mở rộng. Tài liệu này cung cấp cái nhìn tổng quan về cấu trúc hệ thống và hướng dẫn cho các nhà phát triển.