- Project Overview
- Features
- Quick Start
- Technologies Used
- Endpoints
- Authentication (JWT)
- Image Storage (Azure Blob Storage)
- Payments (Stripe)
- Contributing
- License
- Acknowledgements
A modern, scalable RESTful API for an ecommerce platform built with ASP.NET Core, featuring JWT authentication, Azure Blob Storage for image management, and Stripe for payment processing. The API is designed for extensibility, security, and cloud readiness.
- User Registration & Login (JWT Authentication)
- Menu Item CRUD with image upload to Azure Blob Storage
- Shopping Cart management
- Order Placement & Tracking
- Stripe Payment Integration
- Role-based Authorization
- Robust Error Handling & API Responses
- Clone the Repository
git clone https://github.com/Sonseldeep/E-commerce-Assignment.git cd Ecommerce.Api - Configure Environment
- Edit
Ecommerce.Api/appsettings.json:ConnectionStrings:DefaultConnection: SQL Server connection stringAzureBlobStorage:ConnectionString: Azure Storage connection stringStripeSettings:SecretKey: Stripe secret keyJwt:Key, Jwt:Issuer, Jwt:Audience: JWT settings
- Edit
- Run Database Migration
dotnet ef migrations add InitialCreate --project Ecommerce.Api dotnet ef database update --project Ecommerce.Api
- Start the API
The API will be available at
dotnet run --project Ecommerce.Api
https://localhost:5001(or as configured).
- ASP.NET Core 9 Web API
- Entity Framework Core (Code First, Migrations)
- Azure Blob Storage (for image uploads)
- JWT (JSON Web Token) for authentication
- Stripe for payment processing
- SQL Server (default, configurable)
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register | Register a new user |
| POST | /api/auth/login | Login and receive JWT token |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/menuitems | Get all menu items |
| GET | /api/menuitems/{id} | Get menu item by ID |
| POST | /api/menuitems | Create a new menu item (image upload) |
| PUT | /api/menuitems/{id} | Update a menu item |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/shoppingcart?userId={userId} | Get shopping cart for a user |
| POST | /api/shoppingcart | Add/update item in cart (userId, menuItemId, updateQuantityBy) |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/orders | Place a new order |
| GET | /api/orders?userId={userId} | Get orders for a user |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/payment/{userId} | Create Stripe payment intent for user's cart |
- All protected endpoints require the
Authorization: Bearer <token>header. - JWT is issued on successful login and must be included in subsequent requests.
Example Login Request:
POST /api/auth/login
Content-Type: application/json
{
"email": "[email protected]",
"password": "yourpassword"
}Response:
{
"token": "<JWT_TOKEN>",
"expires": "2025-10-24T12:00:00Z"
}- Menu item images are uploaded to Azure Blob Storage.
- Ensure your Azure Storage connection string and container name are set in
appsettings.json. - Containers are auto-created if missing.
Example Create Menu Item (multipart/form-data):
POST /api/menuitems
Content-Type: multipart/form-data
name: "Pizza"
price: 12.99
category: "Food"
specialTag: "Hot"
description: "Delicious pizza"
file: <image-file>- Stripe is used for secure payment processing.
- Set your Stripe secret key in
appsettings.json. - Payment intent is created and client secret returned for frontend integration.
Example Payment Request:
POST /api/payment/{userId}Response:
{
"isSuccess": true,
"result": {
"stripePaymentIntentId": "pi_123456789",
"clientSecret": "sk_test_..."
},
"statusCode": 200
}Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License.