How 21dh113775/mockhang_app works
Main Components
• Frontend (Flutter Mobile/Web/Desktop App):
• This is primarily in the “lib” directory with separation into different modules:
▪ The “admin” module (lib/admin) which includes admin screens, data sources, models, repositories, and providers.
▪ The “user” module (lib/user) for client-facing screens (home, product, account, etc.).
▪ Shared modules such as authentication (lib/auth), common API handling (lib/api), routes (lib/routes), and common widgets.
• The project is multi-platform – notice folders for android, ios, linux, macos, windows, and web – which indicates the Flutter app is designed to run on several targets.
• Backend (Products API):
• Located in the “backend/ProductsApi” directory, this service is written in C# using ASP.NET Core.
• It contains Controllers (e.g., ProductController.cs), data models (Product.cs, StockUpdate.cs), and a DB context (ApplicationDbContext.cs) which suggests usage of an ORM (likely Entity Framework).
• There are also repository interfaces and their implementations for managing product data.
• External Services & Configuration:
• Firebase integration is signified by “firebase.json” and “lib/firebase_options.dart,” suggesting use for notifications, authentication, or analytics.
• Configuration files for different environments (e.g., appsettings.json, appsettings.Development.json).
Relationships and Interactions
• The Flutter frontend communicates with the backend API:
• API requests are handled by the “lib/api/api_client.dart” module, which likely wraps the network calls to the backend endpoints.
• Depending on user roles, different parts of the Flutter app (admin or user) will fetch, display, and update data.
• Separation between Admin and User components:
• The “admin” module in the lib/ directory uses local data sources and repository classes to interact with either a local database or remote endpoints (via the API client) for administrative tasks.
• The “user” module communicates similarly with the backend for displaying products, managing shopping carts, etc.
• Backend and Data Persistence:
• The backend service exposes RESTful endpoints (via the Controllers) with business logic via repositories and the DBContext.
• Although the exact database isn’t shown, the presence of an ApplicationDbContext implies a relational database is in use.
Architectural Patterns and Technologies
• The Flutter front-end likely follows a layered (or MVVM/MVC) approach with providers managing state.
• The backend uses standard ASP.NET Core patterns:
• Controller-Service-Repository structure.
• Dependency Injection is likely used to manage these components.