How hoanvirtue/sammistoreecommerce works
Project type and overall purpose
• This is a full-stack ecommerce platform that includes a web front end (built with Next.js), a back-end API (with a .NET Core-based API implementing domain-driven design principles), and a mobile application (likely built with React Native). There is also an Angular-based shared library (“thamkhao/base-angular”) that might be used for common utilities or micro-frontends.
• The system supports ecommerce activities such as managing products, orders, users, and payment processing (with integration to VNPay, ElasticSearch for search features, and external file storage via Cloudinary/FileStorage).
Analyzing the file structure
• At the top level, you see configuration files, SQL scripts (database.sql, database_mysql.sql), and documentation. This indicates that the database design has been carefully planned.
• Under the “source” directory, there are clear segregations:
– “SAMMI.ECOM.API”: contains the .NET backend API. Its structure follows a layered approach: Controllers for handling HTTP requests, an Application layer with Command Handlers that follow CQRS principles, Domain and Core projects (with domain models, enums, and responses), and Infrastructure (for EF Core configurations, migrations, external service integrations like ElasticSearch, caching with Redis, and more).
– “SammiMobile”: contains the mobile app code including API integrations, navigation, screens, components, and socket communications.
– “thamkhao”: contains a base Angular library that is likely used as a shared module or service library.
• There are docker-compose files and Dockerfiles that indicate containerization and preparation for deployment.
a. Frontend (Web Client):
– Component: Next.js based Frontend (source/FE)
– Sub-components: pages, layouts, components (auth guards, custom UI widgets), localization, theming, and state management (contexts/stores).
– Interactions: Communicates with backend API through REST/GraphQL endpoints.
b. Mobile Client:
– Component: SammiMobile (React Native based mobile app)
– Sub-components: Screens, Navigation, API clients, Socket integration, Redux/Context state.
– Interactions: Consumes backend API endpoints (similar to Web) for authentication, payment, orders, etc.
c. Backend API:
– Component: .NET Core API (SAMMI.ECOM.API)
– Layers:
• Controllers (presentation layer exposing endpoints)
• Application (Command Handlers, Mediator patterns, transaction/validation behaviors)
• Domain (aggregates for products, orders, user, payment, shipping, etc.)
• Infrastructure (Entity Framework Core configurations, repositories, external integrations such as for ElasticSearch, caching with Redis, file/media storage, third-party payment services like VNPay and GHN)
• Cross-cutting concerns: AutoMapper, FluentValidation, and logging (SysLog)
– Interactions: Communicates with the database (using SQL scripts), consumes external services, and is consumed by the Frontend and Mobile.
d. Database:
– Component: SQL Database (as defined by database.sql)
– Represents storage for ecommerce data – product catalog, user data, orders, payments, reviews, etc.
e. Shared Libraries/Services:
– “thamkhao/base-angular”: A reusable Angular-based collection of models/services/components that might be used by parts of the system or provide guidelines for structuring code.
– Additional cross-cutting services (such as caching, logging, and messaging via Redis or other patterns).
Relationships and interactions
• Backend’s interaction with the SQL database (using Entity Framework Core and migrations) and external services (ElasticSearch for search capabilities, VNPay for payment processing, Cloudinary/FileStorage for media, and Redis for caching).
• Internal layers within the Backend API (Controllers → Application Layer (commands/handlers) → Domain Models → Infrastructure/Repositories).
• If needed, show integration with shared libraries (e.g., “thamkhao/base-angular”) as a component that may wrap certain common functions or data models.
Architectural patterns & design principles
• That the backend adheres to Domain-Driven Design (DDD) patterns such as separation of concerns (Controllers vs. Application vs. Domain vs. Infrastructure), use of Command Handler (CQRS) patterns, and an emphasis on scalability (with Docker Compose support and containerized services).
• For the UI, the design separates presentation (pages and layouts) from business logic (hooks, context) and is built as a Single-Page Application (SPA) using Next.js.
• The mobile app typically uses similar separation between view components, API services, and state management.