Skip to content

mohammadsofan/Ecommerce_API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ecommerce API (Mshop)

An ASP.NET Core 8.0 RESTful API for an e-commerce platform, built with Entity Framework Core, ASP.NET Identity, JWT authentication, and Stripe integration for payments.


Features

  • Authentication & Authorization

    • Register, confirm email, login, reset password (via code or link)
    • JWT-based authentication
    • Role-based access (SuperAdmin, Admin, Customer)
  • User Management

    • View all users (SuperAdmin only)
    • Change user roles
    • Lock / unlock users
  • Product Management

    • CRUD operations with image upload
    • Toggle product status
    • Manage stock quantity (increase/decrease)
  • Categories & Brands

    • CRUD operations
    • Toggle active/inactive status
  • Cart

    • Add, update, remove, and clear cart items
    • Calculate total price
  • Orders

    • Create and manage orders
    • Track order status (Pending, Approved, Shipped, Cancelled, Completed)
  • Checkout & Payments

    • Stripe payment gateway integration
    • Cash on delivery option
    • Refund support
    • Stripe webhook for session status updates
  • Reviews

    • Leave product reviews (only after purchase & completion)
    • Prevent duplicate reviews
    • Update/Delete reviews
    • Automatic product rating & review count updates
  • Utilities

    • Email service (for account confirmation, reset password, notifications)
    • DB Initializer with roles and seed data
    • Scalar API reference documentation

Tech Stack

  • Framework: ASP.NET Core 8.0
  • Database: Microsoft SQL Server (EF Core 9)
  • Authentication: ASP.NET Identity + JWT
  • Payments: Stripe API
  • ORM: Entity Framework Core
  • Mapping: Mapster
  • API Docs: Scalar
  • Email: SMTP (Gmail configured in appsettings.json)

Getting Started

Prerequisites

  • .NET 8 SDK
  • SQL Server
  • Stripe account (for payment keys)
  • Gmail (or SMTP provider) for email service

Installation

  1. Clone the repository:
    git clone https://github.com/mohammadsofan/Ecommerce_Api.git
    cd Ecommerce_Api/Mshop.Api
  2. Configure appsettings.json:
    "ConnectionStrings": {
      "DefaultConnection": "Server=.; Database=Mshop; Trusted_Connection=True; TrustServerCertificate=True;"
    },
    "JWT": {
      "SecretKey": "your-secret-key"
    },
    "Stripe": {
      "SecretKey": "your-stripe-secret",
      "PublishableKey": "your-stripe-publishable"
    },
    "EmailSender": {
      "FromEmail": "your-email@gmail.com",
      "Password": "your-app-password"
    }
  3. Run migrations:
    dotnet ef database update
  4. Run the project:
    dotnet run

API Endpoints (Examples)

Authentication

  • POST /api/account/register – Register user
  • POST /api/account/login – Login
  • GET /api/account/confirmEmail – Confirm email
  • GET /api/account/sendResetPasswordCode – Send reset code
  • POST /api/account/confirmResetPassword – Reset password

Products

  • GET /api/products – Get all products (with pagination & search)
  • POST /api/products – Add product (Admin/SuperAdmin)
  • PUT /api/products/{id} – Update product
  • PATCH /api/products/toggleStatus/{id} – Activate/Deactivate product

Cart

  • GET /api/cart – Get cart items
  • POST /api/cart – Add to cart
  • PATCH /api/cart/{id} – Update quantity
  • DELETE /api/cart/{id} – Remove item

Orders

  • GET /api/orders/user – Get current user’s orders
  • POST /api/orders – Create order
  • PATCH /api/orders/changeStatus/{id} – Change order status (Admin only)

Checkout

  • POST /api/checkout/createCheckoutSession – Start checkout
  • GET /api/checkout/success/{orderId} – Payment success
  • GET /api/checkout/cancel/{orderId} – Payment canceled
  • POST /api/checkout/refund – Refund payment (SuperAdmin)

Reviews

  • POST /api/reviews/product/{id} – Add review (after purchase)
  • PUT /api/reviews/{id} – Update review
  • DELETE /api/reviews/{id} – Delete review
  • GET /api/reviews/product/{id} – Get product reviews

Roles & Permissions

  • SuperAdmin: Full access (manage users, refunds, etc.)
  • Admin: Manage products, categories, brands, and orders
  • Customer: Shopping, checkout, reviews

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages