An open API service indexing awesome lists of open source software.

https://github.com/mscbuild/-e-commerce-app

🧱Building Ecommerce web application
https://github.com/mscbuild/-e-commerce-app

core development ecommerce framework net payment postgresql razor-pages server webapp website

Last synced: about 1 month ago
JSON representation

🧱Building Ecommerce web application

Awesome Lists containing this project

README

          

# Building Ecommerce web application with C#
![](https://komarev.com/ghpvc/?username=mscbuild)
![](https://img.shields.io/github/license/mscbuild/e-learning)
![](https://img.shields.io/github/repo-size/mscbuild/-e-commerce-app)
![](https://img.shields.io/badge/PRs-Welcome-green)
![](https://img.shields.io/badge/code%20style-asp.net-green)
![](https://img.shields.io/github/stars/mscbuild)
![](https://img.shields.io/badge/Topic-Github-lighred)
![](https://img.shields.io/website?url=https%3A%2F%2Fgithub.com%2Fmscbuild)

## πŸ”§ Core Functional Requirements.

### 1. Product Management.

  • Add, update, delete products.

  • Store product details: name, description, price, SKU, images, category, etc.

  • Display products for customers.

    ### 2. Inventory Management.

  • Track inventory per product.

  • Add stock (e.g., when restocking).

  • Subtract stock when orders are placed (and paid).

  • Optional: Alert for low inventory levels.

    ### 3. Customer Management.

  • Register and authenticate customers.

  • Store profile: name, email, phone, shipping address, etc.

  • Allow customers to update their info.

    ### 4. Order Management

  • Store order details: products, quantities, price, customer info, shipping status.

  • Allow order history viewing for users.

  • Admins can manage or update order statuses (e.g., Processing, Shipped, Delivered).

    ### 5. Shopping Cart & Checkout

  • Add/remove items to/from cart.

  • Show total cost, taxes, and shipping.

  • Checkout page with payment and shipping details.

    ### 6. Payment Processing

  • Integrate a payment gateway (e.g., Stripe, PayPal, Square).

  • Securely handle payment details (PCI compliance).

  • Confirm successful/failed transactions and update order status accordingly.

    ## πŸ“‚ Optional (but valuable) Features

  • User authentication with JWT/cookies.

  • Product search and filtering (by category, price, etc.).

  • Promo codes or discount system.

  • Email confirmation and notifications.

  • Admin panel for managing products, customers, and orders.

  • Reviews/ratings system.

    ## 🧱 Technology Stack Suggestion (C#/.NET Core)

  • Backend: ASP.NET Core Web API

  • Frontend: Razor Pages, Blazor, or a JS framework (React, Angular) with API

  • Database: SQL Server or PostgreSQL via Entity Framework Core

  • Authentication: ASP.NET Identity or JWT

  • Payments: Stripe API (easiest to integrate/test)

    ## πŸ—‚οΈ Project Structure

    Assuming you're building an ASP.NET Core Web API backend, your folder structure might look like this:
    ```ruby

    EcommerceApp/
    β”‚
    β”œβ”€β”€ Controllers/ β†’ API endpoints (ProductsController, OrdersController, etc.)
    β”œβ”€β”€ Models/ β†’ Data models (Product, Customer, Order, etc.)
    β”œβ”€β”€ Data/ β†’ DbContext and seed data
    β”œβ”€β”€ DTOs/ β†’ Data Transfer Objects for requests/responses
    β”œβ”€β”€ Services/ β†’ Business logic (e.g., OrderService, PaymentService)
    β”œβ”€β”€ Repositories/ β†’ Data access layer (optional abstraction)
    β”œβ”€β”€ Migrations/ β†’ EF Core migrations
    β”œβ”€β”€ wwwroot/ β†’ Static files (if applicable)
    β”œβ”€β”€ Program.cs β†’ App entry point
    └── appsettings.json β†’ Configuration (connection strings, etc.)
    ```
    ### 🧩 1. Database Schema
    ### πŸ“¦ 2. Order
    ### πŸ“„ 3. OrderItem
    ### πŸ‘€ 4. Customer
    ### πŸ’³ 5. Payment (Optional if using external gateway only)
    ### πŸ”— 6. AppDbContext.cs
    ### 🧾 7. ProductsController.cs

    # πŸ§ͺ Example Test with curl or Postman.

    ### GET all products
    ```ruby
    GET http://localhost:5000/api/products
    ```
    ### POST new product

    ```ruby
    POST http://localhost:5000/api/products
    Content-Type: application/json

    {
    "name": "Laptop",
    "description": "High-performance laptop",
    "price": 1200.00,
    "stock": 15,
    "sku": "LAP123",
    "imageUrl": "https://example.com/laptop.jpg"
    }
    ```
    ### 🧩 8. OrderService.cs

    # βœ… How to Use OrderService

    Example us

    ```ruby
    [HttpPost("create")]
    public async Task CreateOrder(CreateOrderRequest request)
    {
    var result = await _orderService.CreateOrderAsync(request.CustomerId, request.Items);

    if (!result.Success)
    return BadRequest(result.Message);

    return Ok(result.Message);
    }
    ```
    ### DTO

    ```ruby
    public class CreateOrderRequest
    {
    public int CustomerId { get; set; }
    public List Items { get; set; }
    }

    public class OrderItemRequest
    {
    public int ProductId { get; set; }
    public int Quantity { get; set; }
    }
    ```
    # πŸ’³ Step-by-Step: Stripe Integration for

    ### βœ… 1. Set Up Stripe in Your

    Install the Stripe

    ```ruby
    dotnet add package Stripe.net
    ```

    In `appsettings.json`, add you
    ```ruby
    "Stripe": {
    "SecretKey": "sk_test_YourSecretKey",
    "PublishableKey": "pk_test_YourPublicKey"
    }
    ```
    ### Load Stripe configuration in Program.cs or Startup.cs:

    ```ruby
    StripeConfiguration.ApiKey = builder.Configuration["Stripe:SecretKey"];
    ```
    ### 🧾 2. Create a PaymentService

    This will handle creating a Stripe charge (or PaymentIntent for newer APIs):

    ### 🎯 3. Payment Controller Endpoint

    ### πŸ§ͺ 4. Testing

    You can now POST to /api/payments/create-checkout-session/{orderId} and redirect the user to the returned url

    # πŸ“‘ Stripe Webhook Integration (Payment Confirmation)

    ### βœ… 1. Why Use Webhooks?

    Stripe Checkout redirects users after payment, but the most secure way to confirm payment is by listening to Stripe’s server-side webhooks.

    ### πŸ› οΈ 2. Add Webhook Endpoint to Your App

    >πŸ“Œ Note: When creating the Checkout Session earlier, you can add Metadata = new Dictionary { { "order_id", order.Id.ToString() } } to the SessionCreateOptions.
    Stripe Checkout redirects users after payment, but the most secure way to confirm payment is by listening to Stripe’s server-side webhooks.

    ### πŸ§ͺ 3. Expose Localhost for Stripe Testing

    # βœ… Result

    1.Now your app will:

    2.Create Stripe Checkout sessions.

    3.Send users to Stripe to pay.

    4.Listen for successful payments via webhook.

    5.Automatically mark the order as β€œPaid” in your database.

    # πŸ–ΌοΈ Basic UI Components

    ### πŸ“„ Pages/Products.razor

    ### πŸ›’ Services/CartService.cs

    # πŸ’³ Checkout Page

    ### πŸ“„ Pages/Checkout.razor

    ### πŸ§ͺ Test Flow

    1.Run your backend API and Blazor app

    2.Visit /products

    3.Add items to cart

    4. /checkout

    5.Click "Proceed to Payment" β†’ redirects to Stripe

    6.After successful payment, Stripe webhook marks order as "Paid"

    # πŸš€ Azure Deployment:

    βœ… Backend (ASP.NET Core Web API)

    βœ… Frontend

    βœ… SQL Databas

    βœ… Stripe Webhooks (via Stripe CLI or Azure F)

    # πŸš€ GitHub Ac

    🧭 Y

    βœ… Automatic build and test on each push

    βœ… Publish to Azure App Servi (API and Blazor)

    ### πŸ”§ Step 1: Prep Your Azure App Services

    ### πŸ”‘ Step 2: Create Azure Deployment Credentials

    ### πŸ“ Step 3: Create GitHub Workflow Files

    ### πŸ” Step 4: Add Secrets to GitHub

    ### πŸ§ͺ Step 5: Test CI/CD

    # βœ… Result

    Every time you push changes:

  • API and frontend are built


  • Deployed automatically to Azure App Services


  • No manual steps needed

    ### Perfect β€” you're now fully set up with:

    βœ… A C# e-commerce backend (API)

    βœ… A Blazor Server frontend

    βœ… Stripe payment + webhook handling

    βœ… Azure SQL integration

    βœ… Fully automated CI/CD via GitHub Actions

    This stack is solid for portfolio use, production trials, or job interviews.