-
Install dependencies
npm install
-
Start the development server
npm run dev
-
Run all tests
npm test -
Build for production
npm run build
-
Lint and format code
npm run lint npm run format
You can use the following test accounts to log in and experience different permission levels:
| Role | Username | Password | Permissions |
|---|---|---|---|
| Admin | admin@test.com | admin123 | view, edit, delete, manage |
| Operator | operator@test.com | operator123 | view, edit |
| Viewer | viewer@test.com | viewer123 | view |
Pump Master is a web-based platform that provides pump asset management functionality for agricultural customers. These pump devices are installed on farms with automated CI/CD pipelines already established.
- π Secure Tenancy Login
- π€ User Permission Management - Supports role-based and fine-grained permission allocation with comprehensive front-end permission validation
- π Pump Overview
- π Search & Filtering
- βοΈ Pump Management - Partially completed (delete functionality)
- π§ Pump Inspection - Not implemented
- Assumes the existence of a complete and fully functional microservice as the backend. During front-end integration, API specifications are more important than implementation language.
- Assumes backend is based on RESTful API specifications, providing complete CRUD interfaces for related resources (also supports GraphQL and other specifications).
- Assumes backend supports pagination, search, and indexing functionality to enable front-end interactions based on these features.
- Assumes JWT-based authentication API, where standard JWT implementation includes basic user information in tokens.
- Assumes backend data contains complete fields required by the front-end, such as pump ID, geographical location, etc.
- Agile Development: Adopts agile development methodology, following KISS/DRY principles, gradually iterating from simple design to complete functionality.
- Progressive Development: Starting with a simple React project, supporting future horizontal and vertical scaling.
- CI/CD Pipeline: Following industry-standard CI/CD practices, implementing continuous integration through GitHub Actions, ultimately deploying to Azure Static Web Apps.
- Route-based Folder Structure: Adopts route-driven file organization, with globally shared utils, components, etc. placed in the src root directory.
- Feature Aggregation: Organized by routes in src/app, aggregating features of the same route to improve file discoverability, code readability, maintainability, and reusability.
- Avoid Over-abstraction: Avoid structural over-development, with file structure centered around components, conforming to React's component-first design philosophy.
- Fractal Design: Apply fractal concepts to improve code reusability, supporting flexible component lifting and reuse.
src/
βββ app/ # Application core code
β βββ components/ # Page-level components
β β βββ LoginPage/ # Login page
β β β βββ components/ # Login page sub-components
β β β β βββ LoginForm/ # Login form
β β β β βββ LoginHeader/ # Login page header
β β β β βββ LoginFooter/ # Login page footer
β β β βββ LoginPage.tsx
β β βββ PumpsPage/ # Pump device management page
β β βββ components/ # Pump page sub-components
β β β βββ PageHeader/ # Page header
β β β βββ PumpsTable/ # Pump device table
β β β βββ PumpsToolbar/# Toolbar
β β β βββ SearchModal/ # Search modal
β β βββ PumpsPage.tsx
β βββ contexts/ # React Context
β β βββ AuthContext.tsx # Authentication context
β βββ hooks/ # Custom Hooks
β β βββ usePermissions.ts # Permission management Hook
β β βββ useSearch.ts # Search functionality Hook
β β βββ usePagination.ts # Pagination functionality Hook
β β βββ useFilter.ts # Filter functionality Hook
β β βββ useSelection.ts # Selection functionality Hook
β βββ services/ # API service layer
β β βββ mockAuthService.ts # Authentication service Mock
β β βββ mockPumpService.ts # Pump device service Mock
β β βββ data/ # Mock data
β βββ types/ # TypeScript type definitions
β β βββ Auth.ts # Authentication-related types
β β βββ PumpDevice.ts # Pump device types
β β βββ User.ts # User types
β β βββ Permissions.ts # Permission types
β βββ utils/ # Utility functions
β βββ tokenStorage.ts # Token storage utilities
β βββ mockDatabase.ts # Mock database
βββ shared/ # Shared components and utilities
β βββ components/ # Common components
β β βββ AppLayout/ # Application layout
β β βββ FormInput/ # Form input component
β β βββ LoadingButton/ # Loading button
β β βββ ErrorAlert/ # Error alert
β β βββ ProtectedRoute/ # Route protection
β β βββ NavBar/ # Navigation bar
β βββ schemas/ # Zod validation schemas
βββ tests/ # Test-related configuration
- "Trust Nobody" Principle: Although assuming backend services are complete and available, development follows the "Trust Nobody" principle, conducting comprehensive testing of backend integration to ensure interface contracts run correctly.
- Pipeline Integration: Integrate integration testing into GitHub Actions pipeline to ensure project availability.
- Multi-client Support: Consider introducing Backend for Frontend (BFF) architecture based on backend service scale. Large microservices may need to serve multiple clients (mobile, desktop, IoT devices, etc.).
- Generic API Issues: When APIs need to satisfy multiple business requirements, they may be designed too generically.
- Web-specific Optimization: In such cases, consider introducing BFF to handle web-specific business logic, improving code security and availability.
- KISS Principle: Starting with a simple React application, following KISS principles, developing through agile iteration. Maintain caution in initial tool selection to avoid over-development and tight coupling issues, improving project scalability.
- TypeScript: Provides type safety, enhancing code maintainability.
- Context API: Used for state management. Based on current design and requirements analysis, the project currently has no complex data changes and association requirements. Starting with Context API, can seamlessly migrate to Redux and other state management frameworks in the future.
- Bootstrap: Choose Bootstrap for rapid development. Based on design and requirements analysis, this is a To-B project with no need for overly complex UI effects. For To-C beautiful UI, can maintain custom UI component library using Tailwind CSS or CSS Modules.
- Axios: Used for backend interaction, utilizing axios instantiation functionality to optimize logging and alerting features in backend interactions.
- React Hook Form: Based on design and requirements analysis, the project involves form-related functionality, using React Hook Form to manage form state.
- Zod: Used for form validation
- GitHub Actions: Use GitHub Actions to implement real-time code validation pipeline, including static code analysis and unit testing.
- Code Style: Use Prettier to ensure code style consistency, improving code readability and maintainability.
- Code Format: Use ESLint to ensure code format consistency, helping early problem detection.
- Commit Checks: Use commit hooks for mandatory checks on every commit, ensuring code quality.
- Commit Standards: Use commitlint to check commit message format standards.
- Unit Testing: Use Jest/Vitest with React Testing Library for unit logic testing, aiming for 100% test coverage to achieve high-confidence continuous delivery.
- E2E Testing: Use Playwright for end-to-end testing when conditions allow, serving as the final line of defense for code delivery.
(Mock - actual progress is faster, the following plan is just to simulate real development scenarios)
- Sprint Cycle: Adopt 2-week Sprint development cycle, following MVP (Minimum Viable Product) delivery principles.
Goal: Build project architecture, create pipeline and deployment environment
- Initialize GitHub repository
- Configure ESLint and Prettier static checking tools
- Set up GitHub Actions
Goal: Deliver minimum viable product for login functionality
- Implement Header component
- Create login page form UI
- Integrate React Hook Form
Goal: Complete login functionality and deliver registration feature MVP
- Complete login logic
- Implement user registration functionality
- Integrate JWT authentication
Goal: Deliver pump device list page MVP
- Implement pump overview page basic functionality
- Implement basic data display
Goal: Complete pump device list page functionality
- Implement search and filtering functionality
- Implement pagination functionality
- Optimize responsive design
Goal: Implement detailed pump device management functionality
- Implement pump detail page
- Implement pump editing functionality
- Implement pump inspection functionality