BionicSquareBook is a modern, full-featured e-commerce bookstore web application built with ASP.NET Core 10 MVC, Entity Framework Core 10, and SQL Server 2025. It demonstrates an N-Tier layered architecture with separation of concerns across presentation, business logic, data access, and domain models, backed by an automated testing suite comprising unit tests and full-stack integration tests.
Warning
Project Status: Under Active Development
This project is currently an ongoing work-in-progress. While core functionalities such as product & category management, role-based identity authentication, tiered pricing, and shopping cart management are functional, several key e-commerce features (e.g., checkout/payment processing via Stripe, order fulfillment workflow, and administrative analytics) are actively being developed. See the Roadmap & Pending Features section for details.
- Architecture Overview
- Project Structure
- Technology Stack
- Key Features
- Prerequisites
- Getting Started & Usage
- Default Roles & Access Control
- REST API Endpoints
- Testing & Code Coverage
- Contributing
- License
BionicSquareBook adheres to clean N-Tier layered architectural principles. Each project represents a specific layer with distinct responsibilities and unidirectional dependencies:
graph TD
subgraph Presentation ["Presentation Layer"]
Web["BionicSquare.Web (ASP.NET Core MVC 10)"]
end
subgraph Business ["Service / Business Logic Layer"]
Services["BionicSquare.Business (Services & Validation)"]
end
subgraph Data ["Data Access Layer"]
DataAccess["BionicSquare.DataAccess (EF Core & ApplicationDbContext)"]
end
subgraph Core ["Shared & Domain Layers"]
Models["BionicSquare.Models (Entities & ViewModels)"]
Utility["BionicSquare.Utility (Roles, Constants & Helpers)"]
end
subgraph Testing ["Automated Test Suites"]
UnitTests["BionicSquare.UnitTests (xUnit + Moq)"]
IntegrationTests["BionicSquare.IntegrationTests (WebApplicationFactory + Testcontainers + Respawn)"]
end
subgraph Infrastructure ["Infrastructure"]
DockerDB["SQL Server 2025 (Docker Container)"]
end
Web --> Services
Web --> DataAccess
Web --> Models
Web --> Utility
Services --> DataAccess
Services --> Models
Services --> Utility
DataAccess --> Models
DataAccess --> Utility
DataAccess --> DockerDB
UnitTests -.-> Services
UnitTests -.-> Models
UnitTests -.-> Web
IntegrationTests -.-> Web
IntegrationTests -.-> Services
IntegrationTests -.-> DataAccess
IntegrationTests -.-> DockerDB
-
BionicSquare.Web(Presentation Layer):- ASP.NET Core 10 MVC application organized into MVC Areas (
Customer,Admin,Identity). - Handles HTTP requests, view rendering (Razor), UI client scripts, and JSON API endpoints.
- Configures authentication, authorization cookies, and dependency injection services in
BionicSquare.Web/Program.cs. - Manages static assets including uploaded product images in
wwwroot/images/uploads/products.
- ASP.NET Core 10 MVC application organized into MVC Areas (
-
BionicSquare.Business(Business Logic Layer):- Contains domain services and business interfaces (
ICategoryServices,IProductServices,IShoppingCartService,IApplicationUserService). - Enforces business rules (duplicate category validation, tiered product calculations, cart item adjustments, and file handling for image attachments).
- Contains domain services and business interfaces (
-
BionicSquare.DataAccess(Data Access Layer):- Entity Framework Core 10 database context (
ApplicationDbContext) inheriting fromIdentityDbContext<ApplicationUser>directly mapped to SQL Server 2025. - Manages database relationships, foreign keys, table mapping, and initial seed data for categories and book catalog.
- Hosts database migrations tracking schema evolution.
- Entity Framework Core 10 database context (
-
BionicSquare.Models(Domain & ViewModel Layer):- Domain entities:
Category,Product,ShoppingCart,OrderHeader,OrderDetails,ApplicationUser. - View models:
ProductViewModel,ShoppingCartViewModel,LoginViewModel,RegisterViewModel.
- Domain entities:
-
BionicSquare.Utility(Shared Utilities):- Contains cross-cutting constants and helpers, such as role definitions (
Role.cswithAdmin,Customer, andEmployee).
- Contains cross-cutting constants and helpers, such as role definitions (
-
BionicSquare.UnitTests(Unit Testing Suite):- Focused unit tests verifying domain calculations, view models, service validations, and isolated controller behaviors using
xUnit,Moq, andFluentAssertions.
- Focused unit tests verifying domain calculations, view models, service validations, and isolated controller behaviors using
-
BionicSquare.IntegrationTests(Integration Testing Suite):- End-to-end server integration tests verifying HTTP endpoints, routing, cookie/claims security, Razor view rendering, EF Core transactions, foreign key constraints, file system interactions, and database persistence against real Microsoft SQL Server 2025 Testcontainers.
-
BionicSquare.Data(Infrastructure):- Contains
BionicSquare.Data/docker-compose.ymland environment configurations to provision containerized Microsoft SQL Server 2025.
- Contains
BionicSquareBook/
├── .github/ # GitHub configurations and DevOps automation
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md # Standardized bug reporting template
│ │ └── feature_request.md # Feature request & enhancement proposal template
│ ├── workflows/
│ │ ├── ci.yml # GitHub Actions CI (Build, Unit & Integration Tests, Coverage Summary)
│ │ └── codeql.yml # CodeQL Static Application Security Testing (SAST)
│ ├── dependabot.yml # Dependabot configuration (NuGet & GitHub Actions updates)
│ └── PULL_REQUEST_TEMPLATE.md # Engineering pull request quality checklist
│
├── .editorconfig # Code style and analyzer standards
│
├── BionicSquare.Business/ # Business Logic Layer (Services & Validation)
│ ├── Services/
│ │ ├── ApplicationUserService.cs
│ │ ├── CategoryServices.cs
│ │ ├── ProductServices.cs
│ │ └── ShoppingCartService.cs
│ └── BionicSquare.Business.csproj
│
├── BionicSquare.Data/ # Database container orchestration
│ ├── docker-compose.yml # SQL Server 2025 container specification
│ └── .env # Environment variables (MSSQL password)
│
├── BionicSquare.DataAccess/ # Data Access Layer
│ ├── ApplicationDbContext.cs # EF Core DB context & model seeding
│ ├── Migrations/ # EF Core database migrations
│ └── BionicSquare.DataAccess.csproj
│
├── BionicSquare.Models/ # Domain Entities & ViewModels
│ ├── ApplicationUser.cs # Extended IdentityUser
│ ├── Category.cs
│ ├── Product.cs
│ ├── ShoppingCart.cs
│ ├── OrderHeader.cs
│ ├── OrderDetails.cs
│ ├── ViewModels/
│ └── BionicSquare.Models.csproj
│
├── BionicSquare.Utility/ # Constants and Cross-cutting Utilities
│ ├── Role.cs # Role definitions (Admin, Customer, Employee)
│ └── BionicSquare.Utility.csproj
│
├── BionicSquare.Web/ # ASP.NET Core 10 Presentation Layer
│ ├── Areas/
│ │ ├── Admin/ # Admin controllers & views (Products, Categories, Dashboard)
│ │ ├── Customer/ # Customer storefront (Home, Cart, Catalog)
│ │ └── Identity/ # Authentication controllers (Login, Register, Logout)
│ ├── Views/Shared/ # Shared layouts, partials & notifications
│ ├── wwwroot/ # Static files (CSS, JS, product image uploads)
│ ├── Program.cs # App bootstrap, middleware pipeline & DI
│ ├── appsettings.json # Runtime configuration
│ └── BionicSquare.Web.csproj
│
├── BionicSquare.UnitTests/ # Unit Tests (Fast, Isolated, Moq + FluentAssertions)
│ ├── Controllers/
│ ├── Models/
│ ├── Services/
│ └── BionicSquare.UnitTests.csproj
│
├── BionicSquare.IntegrationTests/ # Integration Tests (Full Stack, Testcontainers, Respawn)
│ ├── Controllers/ # Controller endpoint integration tests
│ ├── Infrastructure/ # WebApplicationFactory, TestAuthHandler, AngleSharp helpers
│ ├── Services/ # Real EF Core database persistence & interceptor tests
│ └── BionicSquare.IntegrationTests.csproj
│
├── coverlet.runsettings # Code coverage instrumentation configuration
├── run-unit-tests-with-coverage.sh # Bash script: runs unit tests and generates coverage report
├── run-unit-tests-with-coverage.ps1 # PowerShell script: runs unit tests and generates coverage report
├── run-integration-tests-with-coverage.sh # Bash script: runs integration tests and generates coverage report
├── run-integration-tests-with-coverage.ps1# PowerShell script: runs integration tests and generates coverage report
├── BionicSquareBook.sln # Visual Studio / Rider Solution File
└── Readme.md # Project documentation
- Framework: .NET 10.0
- Web Layer: ASP.NET Core MVC with Razor View Engine
- ORM: Entity Framework Core 10.0 (SQL Server provider, Tools, Design)
- Database: Microsoft SQL Server 2025 (via Docker)
- Authentication / Security: ASP.NET Core Identity with role-based authorization and Cookie Authentication
- DevOps & CI/CD:
- GitHub Actions Continuous Integration (multi-stage build, test, and report summary)
- GitHub CodeQL Static Application Security Testing (SAST)
- Dependabot automated NuGet and Actions dependency updates
- Front-end UI & Styling:
- Bootstrap 5.3.8 + Bootstrap Icons 1.13.1
- Custom dark theme with vibrant emerald-green highlights (
#1DB954/#17A34A) - DataTables 2.3.8 (client-side interactive table with AJAX)
- SweetAlert2 (confirmation modals for destructive actions)
- Toastr (asynchronous toast notifications)
- jQuery 3.7.1 and unobtrusive validation
- Testing & Quality Assurance:
- xUnit test framework
- FluentAssertions for expressive assertion syntax
- Moq for isolating dependencies in unit tests
- ASP.NET Core WebApplicationFactory for in-memory HTTP server integration testing
- Testcontainers for .NET for real containerized SQL Server 2025 instances
- Respawn for fast database table reset between test fixtures
- AngleSharp for HTML DOM parsing and Razor UI assertions
- Coverlet and ReportGenerator for code coverage analysis and HTML reporting
- Storefront & Catalog Browsing:
- Hero banner showcasing featured books and quick navigation.
- Book catalog with cover thumbnails, category tags, author details, and list prices.
- Product detail view displaying description, ISBN, category, and tiered bulk pricing.
- Tiered Quantity Pricing Model:
- Products support multi-tier discounts automatically calculated based on ordered quantities:
- Base price (1–49 copies)
- 50+ copies discount price (
Price50) - 100+ copies discount price (
Price100)
- Products support multi-tier discounts automatically calculated based on ordered quantities:
- Shopping Cart:
- Authenticated customers can add products with custom quantities.
- Interactive cart review page with line-item totals and dynamic order subtotal calculations.
- Real-time cart quantity modification via AJAX (
/api/cart/update) and increment/decrement buttons. - Cart item count badge in top navigation bar.
- Product Management (Admin Area):
- Full CRUD operations with category association dropdown.
- Book cover upload and image file handling (saved with GUID to
wwwroot/images/uploads/products). - Interactive DataTables view with instant search, pagination, sorting, and SweetAlert2-backed AJAX deletion.
- Category Management (Admin Area):
- Full CRUD operations for product categories.
- Display order specification.
- Server-side validation ensuring uniqueness of category names.
- Authentication & Role-Based Authorization:
- Extended user profile (
ApplicationUser) storing shipping address, city, state, postal code, and phone number. - Registration with automatic role assignment (
Customer,Admin,Employee). - Cookie authentication with custom routes for login, logout, and access denied.
- Protected admin routes restricted via
[Authorize(Roles = Role.Admin)].
- Extended user profile (
- Automated Testing & Code Coverage Suite:
- Comprehensive unit tests covering business services, view models, and domain models.
- Full-stack integration test suite with 100+ tests verifying controllers, authentication, authorization, database persistence, and file handling against live SQL Server 2025 Testcontainers.
- Automated coverage collection and visual HTML reporting scripts.
The following capabilities are planned or currently in development:
- Checkout & Payment Gateway Integration:
- Wiring up checkout submission from the shopping cart.
- Integration with Stripe (or equivalent payment gateway) using the existing
OrderHeaderfields (SessionId,PaymentIntentId).
- Order Processing & Management Workflow:
- Administrative order management portal to review incoming orders.
- Order status tracking (e.g.,
Pending,Approved,Processing,Shipped,Cancelled). - Carrier assignment and tracking number entry.
- Admin Dashboard & Analytics:
- Expanding the admin dashboard from the current claims diagnostic view into a comprehensive analytics view (sales charts, order metrics, stock levels).
- Customer Order History:
- Customer portal allowing users to review past orders, view receipts, and monitor shipment status.
- Email Notifications:
- Email confirmation upon user registration and order placement receipts.
Before running the application or test suites, ensure the following are installed on your machine:
- .NET 10 SDK (or later)
- Docker and Docker Compose
- Required for local app development (SQL Server 2025 container).
- Required for integration tests (Testcontainers automatically pulls and executes
mcr.microsoft.com/mssql/server:2025-latest).
- .NET EF CLI Tool:
dotnet tool install --global dotnet-ef
- ReportGenerator Global Tool (installed automatically by coverage scripts):
dotnet tool install --global dotnet-reportgenerator-globaltool
git clone https://github.com/ibogatec/BionicSquareBook.git
cd BionicSquareBookThe database runs in a Microsoft SQL Server 2025 Docker container defined in BionicSquare.Data/docker-compose.yml. Before starting the container, choose one of the two options below to set your SQL Server system administrator (sa) password.
Important
Microsoft SQL Server enforces a strong password policy by default (at least 8 characters containing characters from three of the following four categories: uppercase letters, lowercase letters, numbers, and symbols).
Edit or create the BionicSquare.Data/.env file:
MSSQL_SA_PASSWORD=<your_strong_password>The docker-compose.yml automatically reads ${MSSQL_SA_PASSWORD} from this file.
Alternatively, set the password directly in the environment section of BionicSquare.Data/docker-compose.yml:
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2025-latest
container_name: mssqlserver2025
ports:
- "1433:1433"
environment:
MSSQL_SA_PASSWORD: "<your_strong_password>"
ACCEPT_EULA: "Y"
volumes:
- sql_data:/var/opt/mssql
networks:
- mssqlnetNavigate to the BionicSquare.Data directory and start the container:
cd BionicSquare.Data
docker compose up -d
cd ..This provisions Microsoft SQL Server running on port localhost:1433.
The application looks for a connection string named MSSqlConn. Configure it with the sa password chosen in Step 2. You can configure it using .NET User Secrets (recommended for local development) or via appsettings.Development.json.
Run the following command from the repository root, substituting <your_strong_password> with the password you set in Step 2:
dotnet user-secrets set "ConnectionStrings:MSSqlConn" "Server=localhost,1433;Database=BionicSquareDb;User Id=sa;Password=<your_strong_password>;TrustServerCertificate=True;" --project BionicSquare.WebAdd the connection string to BionicSquare.Web/appsettings.Development.json:
{
"ConnectionStrings": {
"MSSqlConn": "Server=localhost,1433;Database=BionicSquareDb;User Id=sa;Password=<your_strong_password>;TrustServerCertificate=True;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}Apply the Entity Framework Core migrations to create the database schema and populate seed data:
dotnet ef database update --project BionicSquare.DataAccess --startup-project BionicSquare.WebThis will automatically create the database (BionicSquareDb), generate the tables (Categories, Products, ShoppingCarts, OrderHeaders, OrderDetails, AspNetUsers, etc.), and seed initial categories and sample books.
Start the web application using the dotnet run command:
dotnet run --project BionicSquare.WebThe application will launch on:
- HTTPS:
https://localhost:7097 - HTTP:
http://localhost:5170
Open your browser and navigate to https://localhost:7097.
The application implements three primary roles defined in Role.cs:
| Role | Access Level | Description |
|---|---|---|
Admin |
Full Access | Can manage Categories, Products, view the Admin Portal, and manage future orders. |
Employee |
Staff Access | Can access the Admin Portal and perform authorized inventory operations. |
Customer |
Storefront | Can browse books, add items to cart, and proceed to checkout. |
- Click Register on the top navigation bar.
- Fill in the user details and select the desired role (
Admin,Customer, orEmployee) from the dropdown. - Once registered as an Admin, an Admin Portal link will appear in the navigation bar leading to:
- Category Management:
/Admin/Category - Product Management:
/Admin/Product - Admin Dashboard:
/Admin/Dashboard
- Category Management:
The web application exposes lightweight JSON endpoints consumed by client-side scripts:
| HTTP Method | Endpoint | Description | Authorization |
|---|---|---|---|
GET |
/api/products |
Returns all products with category details for DataTables | Public |
DELETE |
/api/products/delete?id={id} |
Deletes a product and its associated image file | Admin |
POST |
/api/cart/update?cartId={id}&quantity={qty} |
Updates the quantity of an item in the user's cart | Authenticated |
BionicSquareBook features a dual-layer testing strategy designed to ensure both rapid feedback during development and rock-solid validation across the entire request-response pipeline.
| Test Project | Technology Stack | Scope & Purpose | Speed |
|---|---|---|---|
BionicSquare.UnitTests |
xUnit, Moq, FluentAssertions | Isolated unit testing of business logic, models, view models, and controller branches using mocked dependencies. | Very Fast (< 2s) |
BionicSquare.IntegrationTests |
xUnit, ASP.NET Core WebApplicationFactory, Testcontainers.MsSql, Respawn, AngleSharp |
Full-stack server integration testing against a live SQL Server 2025 container. Tests authentication cookies, authorization policies, middleware, model binding, EF Core persistence, transactions, file uploads, and Razor view rendering. | ~5–10s |
The integration testing suite runs in an isolated, production-like environment configured in CustomWebApplicationFactory.cs:
sequenceDiagram
participant Test as Test Method
participant Client as HttpClient
participant Pipeline as ASP.NET Core Middleware & Routing
participant Auth as TestAuthHandler
participant Controller as MVC Controller
participant Service as Business Service
participant DB as MS SQL Server 2025 (Testcontainer)
participant Disk as Physical File System (wwwroot)
Note over DB: Testcontainers starts mcr.microsoft.com/mssql/server:2025-latest
Test->>Client: Send Request (e.g. POST /Admin/Product/Create with file)
Client->>Pipeline: HTTP Request with Claims/Headers
Pipeline->>Auth: Authenticate (Admin / Customer / Anonymous)
Pipeline->>Controller: Route to Action
Controller->>Service: Execute Domain Operation
Service->>DB: EF Core INSERT / UPDATE / DELETE
Service->>Disk: Save / Delete physical image file
Controller-->>Client: 302 Redirect / 200 OK HTML / JSON
Test->>DB: Query DbContext directly to verify persistence
Test->>Disk: Verify file presence or deletion on disk
Note over DB: Respawn resets table state for the next test fixture
Key integration test infrastructure components:
CustomWebApplicationFactory: Bootstraps the application in-memory, launches a dynamicTestcontainers.MsSqlcontainer, applies EF Core migrations, seeds identity roles, and initializes aRespawncheckpoint.RespawnDatabase Resetting: Fast checkpoint-based reset between test fixtures without dropping and recreating the database or restarting containers.TestAuthHandler&HttpClientExtensions: Intercepts HTTP requests to support seamless authentication testing across roles:Client.AsAnonymous(): Tests unauthenticated scenarios, login redirections, and public pages.Client.WithUser(userId): Tests authenticated customer user actions (shopping cart, account details).Client.WithAdmin(adminId): Tests admin-protected routes and role-based policies.
TestAntiforgery: Bypasses CSRF token validation during testing while keeping controller[ValidateAntiForgeryToken]attributes active in production.AngleSharp(HtmlHelpers): Parses server-rendered Razor HTML into an in-memory DOM to assert inputs, forms, and validation error messages.
To execute only the unit tests from the terminal:
dotnet test BionicSquare.UnitTests/BionicSquare.UnitTests.csprojEnsure Docker is running on your machine. Testcontainers will automatically pull and start the Microsoft SQL Server 2025 image (mcr.microsoft.com/mssql/server:2025-latest) during test execution.
To execute all integration tests:
dotnet test BionicSquare.IntegrationTests/BionicSquare.IntegrationTests.csprojDedicated shell and PowerShell scripts are provided at the root of the repository. Each script:
- Cleans up previous test results (
./TestResults) and coverage reports (./CoverageReport). - Checks for and installs
dotnet-reportgenerator-globaltoolif not already present. - Executes the target test project with Coverlet code coverage collection and the solution's
coverlet.runsettings. - Generates a standalone, visual HTML coverage report using ReportGenerator.
- Linux / macOS:
./run-unit-tests-with-coverage.sh
- Windows (PowerShell):
.\run-unit-tests-with-coverage.ps1
- Linux / macOS:
./run-integration-tests-with-coverage.sh
- Windows (PowerShell):
.\run-integration-tests-with-coverage.ps1
After running either coverage script, the output files are placed in standard directories:
| Output | Path | Format & Purpose |
|---|---|---|
| HTML Report (Visual) | CoverageReport/index.html |
Interactive, navigable visual coverage dashboard displaying line-by-line coverage and source code highlighting. |
| Raw Cobertura XML | TestResults/<guid>/coverage.cobertura.xml |
Machine-readable coverage XML suitable for CI/CD pipelines (e.g., GitHub Actions, Azure Pipelines, SonarQube). |
You can open the report directly using your default browser:
- Linux:
xdg-open CoverageReport/index.html
- macOS:
open CoverageReport/index.html
- Windows:
start CoverageReport/index.html
If you use VS Code / Cursor or prefer a local web server:
- With the Live Server extension: Right-click
CoverageReport/index.htmland select Open with Live Server (default URL:http://127.0.0.1:5500/CoverageReport/index.html). - With Python:
Then open
python3 -m http.server 5500
http://127.0.0.1:5500/CoverageReport/index.htmlin your browser.
When reviewing the HTML report:
- Line / Sequence Coverage: Measures the percentage of executable C# code statements traversed during the test run.
- Branch Coverage: Measures the percentage of decision pathways (such as
if/elsebranches, ternary expressions? :, null-coalescing operators??, and switch expressions) exercised during tests. - Source Code Line Color Codes:
- 🟩 Green: Line was fully executed by test cases.
- 🟥 Red: Line was not executed (uncovered code path).
- 🟧 Yellow / Orange: Partially covered branch (e.g. an
ifcondition was evaluated astrue, but thefalsebranch was never exercised).
- Collapsible Breakdown: Click on any assembly, namespace, or class (e.g.,
BionicSquare.Business_ProductServices.html) to inspect line-by-line coverage directly alongside source code.
Coverage collection is governed by coverlet.runsettings. To ensure the coverage metrics accurately represent meaningful business and application logic, non-actionable code is intentionally excluded:
<Configuration>
<DataCollectors>
<DataCollector friendlyName="XPlat Code Coverage">
<Configuration>
<Format>cobertura</Format>
<Exclude>[BionicSquare.UnitTests]*,[BionicSquare.IntegrationTests]*,[*]*.Migrations.*</Exclude>
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute</ExcludeByAttribute>
<ExcludeByFile>**/Program.cs,**/Migrations/*.cs</ExcludeByFile>
</Configuration>
</DataCollector>
</DataCollectors>
</Configuration>- Excluded: Test assemblies, auto-generated EF Core database migrations, compiler-generated closures, and boilerplate bootstrap files.
- Included: All production business services (
BionicSquare.Business), data access repositories (BionicSquare.DataAccess), domain models (BionicSquare.Models), controllers, and presentation logic (BionicSquare.Web).
- Fork the repository.
- Create a descriptive feature branch (
git checkout -b feature/awesome-feature). - Commit your changes (
git commit -m "Add awesome feature"). - Push to the branch (
git push origin feature/awesome-feature). - Open a Pull Request.
This project is licensed under the MIT License - see the repository LICENSE file for details.