How utimur/online-store-full-course works
Main Components
• Client (Frontend):
– It uses React with routing and state management.
– Subdivide it into key segments such as:
○ Views/Pages (e.g., Admin, Auth, Basket, DevicePage, Shop)
○ Components (for the UI, e.g., NavBar, BrandBar, modals like CreateDevice, CreateType, etc.)
○ HTTP Service Layer (files under client/src/http, like deviceAPI.js, userAPI.js)
○ State Management (e.g., DeviceStore, UserStore)
○ A configuration/environment layer (represented by the .env file).
• Server (Backend):
– Built on Express, with an entry point (server/index.js).
– Divided into several layers:
○ Routes (organized in the server/routes folder, including brandRouter, deviceRouter, etc.)
○ Controllers (server/controllers handling business logic such as brandController, deviceController, etc.)
○ Models (in server/models - likely representing database entities, bundled in models.js)
○ Middleware (authentication, error handling, role-checking in server/middleware)
○ Error handling module (custom ApiError in server/error)
Relationships and Data Flows
• The Server should forward requests to the proper Controller based on the Route mappings.
• Controllers interact with Models and the Database to perform CRUD operations.
• Middleware is applied in the request flow: from the incoming API call, pass through authentication checks, role validations, and error handling.
• On the client, the state management (stores) receives data from HTTP responses and updates UI components accordingly.
Key Architectural Patterns & Design Principles
• The project is structured following a clear separation of concerns (MVC-like on the server side and component-based design on the client side).
• Use of RESTful API design: Different routers and controllers for brands, devices, types, and users.
• Modularity is present; for example, the separation into custom modals, utility functions, and isolated API service modules.
• Environment-specific configuration via .env files for both client and server.