Skip to content

Repository files navigation

πŸ’» The Gadget Hub | Enterprise E-Commerce System

A modern, multi-role e-commerce system built with ASP.NET Core 8 that enables customers to place orders, distributors to manage inventory and quotations, and employees to oversee the entire order lifecycle.

C# .NET 8 SQL Server ASP.NET Core

πŸ“‹ Overview

GadgetHub consists of four interconnected applications:

Application Purpose Tech Port
GadgetHub.API REST API backend with JWT authentication, Entity Framework Core, business logic ASP.NET Core Web API 7151
GadgetHub.CustomerPortal Customer-facing portal for browsing products, placing orders Razor Pages 7193
GadgetHub.DistributorPortal B2B portal for inventory management and quotation handling Razor Pages 7160
GadgetHub.EmployeeDashboard Internal admin dashboard for product and order management Razor Pages 7263

All applications share a single SQL Server database managed through Entity Framework Core with Identity for authentication.

πŸ”§ Prerequisites

  • Visual Studio 2022 (with ASP.NET and web development workload)
  • .NET 8 SDK or later
  • SQL Server LocalDB (included with Visual Studio) or SQL Server Express
  • HTTPS enabled for local development

οΏ½ Technical Stack

Backend

Technology Purpose
ASP.NET Core 8 Web API framework
Entity Framework Core 9 ORM for database operations
SQL Server Relational database
ASP.NET Identity User authentication and authorization
JWT (JSON Web Tokens) API security and token-based authentication
C# 12 Backend programming language

Frontend

Technology Purpose
Razor Pages MVC-based server-side rendering
HTML5 Markup
CSS3 Styling
Bootstrap 5 Responsive UI framework
JavaScript Client-side interactivity
HttpClient API communication

Development Tools

Tool Purpose
Visual Studio 2022 IDE
SQL Server Management Studio Database management
Swagger/OpenAPI API documentation
Entity Framework Core Migrations Database versioning

οΏ½πŸ“¦ Setup Instructions

Step 1: Create the Database

  1. Open SQL Server Object Explorer in Visual Studio or SQL Server Management Studio (SSMS)
  2. Connect to (localdb)\mssqllocaldb
  3. Execute the provided GadgetHubDb.sql script in the solution root
    • This creates the database schema and inserts seed data (products, roles, users)
  4. Verify the database GadgetHubDb appears in your instance

Step 2: Configure Multiple Startup Projects

  1. Open GadgetHub.Solution.sln in Visual Studio
  2. Right-click Solution in Solution Explorer β†’ Set Startup Projects...
  3. Select Multiple startup projects
  4. Set all four projects to Start:
    • GadgetHub.API
    • GadgetHub.CustomerPortal
    • GadgetHub.DistributorPortal
    • GadgetHub.EmployeeDashboard
  5. Click Apply β†’ OK
  6. Press F5 to launch all applications simultaneously

Step 3: Access Applications

Once running, open in your browser:

πŸ”‘ Test Credentials

Use these pre-seeded accounts to test different roles:

Role Username Password
Admin (Employee) testadmin Password123!
Distributor TechWorld Password123!
Distributor ElectroCom Password123!
Distributor GadgetCentral Password123!
Customer TestCustomer Password123!

πŸ“‚ Project Structure

GadgetHub.Solution/
β”œβ”€β”€ GadgetHub.API/
β”‚   β”œβ”€β”€ Controllers/       β†’ API endpoints (Auth, Products, Orders, etc.)
β”‚   β”œβ”€β”€ Models/            β†’ Entity models (Product, Order, Distributor, etc.)
β”‚   β”œβ”€β”€ Data/              β†’ DbContext and migrations
β”‚   β”œβ”€β”€ Services/          β†’ Business logic (Quotations, etc.)
β”‚   β”œβ”€β”€ Dtos/              β†’ Data transfer objects
β”‚   └── appsettings.json   β†’ API configuration & JWT settings
β”œβ”€β”€ GadgetHub.CustomerPortal/
β”‚   β”œβ”€β”€ Pages/             β†’ Razor Pages for customer UI
β”‚   β”œβ”€β”€ Services/          β†’ HTTP client for API calls
β”‚   └── Models/            β†’ View models
β”œβ”€β”€ GadgetHub.DistributorPortal/
β”‚   β”œβ”€β”€ Pages/             β†’ Razor Pages for distributor UI
β”‚   β”œβ”€β”€ Services/          β†’ HTTP client for API calls
β”‚   └── Models/            β†’ View models
β”œβ”€β”€ GadgetHub.EmployeeDashboard/
β”‚   β”œβ”€β”€ Pages/             β†’ Razor Pages for admin UI
β”‚   β”œβ”€β”€ Services/          β†’ HTTP client for API calls
β”‚   └── Models/            β†’ View models
β”œβ”€β”€ GadgetHubDb.sql        β†’ Database schema and seed data
└── GadgetHub.Solution.sln β†’ Solution file

πŸ”Œ API Endpoints (Key)

Method Endpoint Description
POST /api/auth/register Register new customer or distributor
POST /api/auth/login User authentication (returns JWT)
GET /api/products Fetch all products with pagination
POST /api/orders Create customer order
GET /api/orders Retrieve user's orders
POST /api/quotations Submit quotation request
GET /api/quotations Fetch quotations
POST /api/purchaseorders Create purchase order (distributor)

Full API documentation available at /swagger when API is running.

βš™οΈ Configuration

Connection String (API)

Located in GadgetHub.API/appsettings.json:

"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=GadgetHubDb;Trusted_Connection=True;MultipleActiveResultSets=true"

JWT Settings (API)

Configure in GadgetHub.API/appsettings.json:

  • ValidAudience: Audience for JWT validation
  • ValidIssuer: Issuer of JWT tokens
  • Secret: JWT signing key (change in production)

CORS Configuration (API)

The API allows requests from portal applications:

πŸ› Troubleshooting

Issue Solution
Cannot connect to database Verify SQL Server is running; check connection string in appsettings.json
HTTPS certificate errors This is normal for localhost dev environment; add exception in browser
CORS errors in console Ensure API CORS is configured for your portal port numbers
GadgetHubDb.sql fails to execute Verify you're connected to the correct SQL Server instance; modify file path if needed
Ports already in use Change ports in launchSettings.json for each project
Multiple startup projects won't work Ensure all projects are set to "Start" action, not "None"

πŸš€ Development Notes

  • Authentication: JWT tokens issued by API; stored in session cookies on portals
  • Database: Migrations in GadgetHub.API/Migrations/ tracked in source control
  • Entity Framework: Using code-first approach; modify migrations if schema changes
  • HTTPS: Required for JWT Bearer token validation; localhost certificates auto-generated by Visual Studio
  • Session Timeout: 30 minutes on portal applications; configure in Program.cs

πŸ“ Key Features

  • Multi-role authentication with ASP.NET Identity and JWT
  • Order management from customer perspective
  • Inventory tracking for distributors
  • Quotation system for B2B operations
  • Purchase orders for distributor stock fulfillment
  • Role-based access control (Customer, Distributor, Employee)
  • SQL Server database with Entity Framework Core migrations

Developed as a comprehensive C#/.NET enterprise software demonstration.

About

πŸ’» An enterprise-level e-commerce system built with ASP.NET Core 8 & EF Core. Features a microservices-inspired architecture with dedicated portals for customers, B2B distributors, and admins.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages