How elmehdiaderab/e-commerce_emsi works
Project type and purpose
• This is a full-stack ASP.NET Core MVC web application (“E-Commerce” prototype).
• Purpose: allow users to browse products, add items to a shopping cart, and manage products via CRUD operations.
File structure
• Top-level solution file: E-Commerce.sln.
• Project folder “WebApplication2” contains:
• Controllers (HomeController, ProductsController) – handle HTTP requests.
• Models (Product, Cart, CartItem, ErrorViewModel) – define domain entities and view models.
• Data (WebApplication2Context, Migrations) – Entity Framework Core DB context and schema migrations.
• Views – Razor templates under Home/, Products/, Shared/ – UI layer.
• wwwroot – static assets (CSS, JS, images, Bootstrap, jQuery libraries).
• Configuration: appsettings.json / appsettings.Development.json.
• Program.cs – application entry point and middleware configuration.
• SessionExtensions.cs – helper methods to store Cart in user session.
• SQLite database files (.db, .db-wal, .db-shm).
README for additional insights
• Tech stack: .NET 8, ASP.NET Core, EF Core, Bootstrap.
Main components and their interactions
a. Browser (Client)
– Renders HTML/CSS/JS served by the app; sends HTTP GET/POST to Controllers.
b. Web Server / Application Layer
– ASP.NET Core runtime hosts:
• MVC Controllers: interpret routes, user actions.
• Razor View Engine: composes HTML from Views + Models.
• Middleware pipeline (configured in Program.cs): routing, static files, sessions.
c. Business & Session Layer
– Controllers invoke SessionExtensions to manage shopping cart state between requests.
d. Data Access Layer
– EF Core DbContext (WebApplication2Context) exposes DbSet<Product>, DbSet<CartItem>, etc.
– Migrations manage schema evolution.
e. Database
– SQLite file stored locally; receives SQL queries from EF Core.
f. Static Assets & Libraries
– wwwroot contains CSS/JS and 3rd-party libs (Bootstrap, jQuery, validation).
Architectural patterns & principles
• MVC: strict separation of concerns (Models, Views, Controllers).
• Layered architecture:
• Presentation (Views + static assets)
• Application / Business (Controllers + services/helpers)
• Persistence (EF Core context + SQLite)
• Convention over configuration: folder names map to routing.
Diagramming recommendations
• Keep it 2-3 tiers deep to avoid clutter: UI → App → Database.