How allenxuxu/mogutouerp works
Main Components
• Backend Service:
• Main.go as the entry point.
• Packages such as:
∘ api (handling RESTful endpoints for commodity, customer orders, finance, purchase orders, and user operations)
∘ middleware (e.g., auth for JWT or other authentication mechanisms)
∘ models (representing data models: commodity, customer order, finance, purchase order, and user)
∘ pkg/token (for token generation and handling)
∘ utils (for response handling, validation, etc.)
• Router.go that likely connects the endpoints with controllers and middleware.
• That configuration files in the conf directory (conf.json and jwt.json) are used to set up database connections and JWT keys.
• Frontend Application:
• Web folder, noting its Vue-based structure.
• Subcomponents like:
∘ src/base components (e.g., layout components, views such as commodity, finance, order, staff pages)
∘ src/api directory which communicates with the backend endpoints.
∘ The build configuration and development tools (Webpack, Babel, ESLint, etc.) demonstrating a standard Vue.js SPA.
• Database:
• MySQL as the chosen data storage, with Gorm auto-mapping models to tables.
• Deployment and Containerization:
• Dockerfile and related deployment instructions (Docker container deployment with mounted configuration, Nginx reverse proxy on the frontend side, etc.)
Relationships and Data Flow
• Frontend ↔ Backend Interaction:
• Vue.js client making HTTP API calls to the backend endpoints.
• Where Vue’s API (in web/src/api) calls align with endpoints defined in the api folder.
• Backend Components Interaction:
• That the API layer invokes business logic in models and uses middleware for authentication (JWT based from pkg/token and middleware/auth).
• Configuration reading from the conf folder.
• Backend ↔ Database:
• That Gorm is used to automatically generate table schemas.
Architectural Patterns and Design Principles
• Separation of Concerns:
• The project is clearly divided into frontend and backend, emphasizing loose coupling between presentation and business logic.
• RESTful API Design:
• The backend API endpoints in the api directory imply a RESTful design.
• Modularization:
• The clear separation into directories (models, middleware, utils, pkg, router) suggests modular design.
• Security:
• Use of JWT authentication (with configuration in jwt.json and token package) should be highlighted.
• DevOps and Deployment:
• The presence of .github workflows, Dockerfile, and Makefile indicate a CI/CD integration and containerized deployment.