Skip to content

This project is a robust and secure ASP.NET Core Web API designed to manage an online store, providing comprehensive functionality for product, order, and customer management. The API follows best practices in RESTful API design, ensuring that it is scalable, maintainable, and easy to integrate with various front-end applications or other systems.

Notifications You must be signed in to change notification settings

abdullahsherdy/OnlineStoreAPI-NTier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Online Store API (NTier Architecture)

Overview

This is a .NET Core Web API for an online store system developed with NTier architecture, using the Repository Pattern for data access, DTOs for data transfer, and Services for business logic. The API includes functionality for managing products, customers, and orders, and is secured with JWT Authentication.

The system supports:

  • CRUD operations for Products, Customers, and Orders.
  • JWT Authentication for login and registration.
  • Error handling and validation at various levels.
  • Repository pattern to separate concerns.

Key Features

  • NTier Architecture: Separation of concerns into API, BLL (Business Logic Layer), and DAL (Data Access Layer) for scalability and maintainability.
  • JWT Authentication: Secure access with token-based authentication for login and registration.
  • Repository Pattern: Used for clean and maintainable data access in the DAL.
  • DTOs: Data Transfer Objects for smooth communication between layers.
  • Error Handling: Detailed error messages and exception handling.
  • Custom Responses: Tailored responses for API endpoints like GetOrderById and GetAllProducts.

Technologies Used

  • .NET Core 8.0
  • Entity Framework Core
  • SQL Server
  • JWT Authentication
  • Swagger UI for API documentation
  • AutoMapper for mapping DTOs

Project Structure

The project is divided into the following layers:

  • API Layer: Contains the controllers for handling HTTP requests.
  • BLL (Business Logic Layer): Contains the services and business logic for the application.
  • DAL (Data Access Layer): Implements the repository pattern for data access.
  • Common: Holds shared resources like DTOs.

Installation

Prerequisites

  • .NET 8.0 SDK installed.
  • SQL Server installed or available.
  • Visual Studio or VS Code.

Steps

  1. Clone the repository:

    git clone https://github.com/your-username/OnlineStoreAPI.git
    cd OnlineStoreAPI
  2. Setup database:

    • Update the connection string in appsettings.json:

      "ConnectionStrings": {
        "DefaultConnection": "Server=your_server;Database=OnlineStoreDB;Trusted_Connection=True;"
      }
    • Apply the migrations to create the database:

      dotnet ef database update
  3. Run the API:

    dotnet run

How to Use

  • You can interact with the API through Swagger at https://localhost:5001/swagger or through a tool like Postman.
  • To access secured endpoints, you need to:
    • Register a new user via POST /api/auth/register.
    • Login to get a JWT token via POST /api/auth/login.
    • Use the token in the Authorization header to access secured endpoints (e.g., Authorization: Bearer <your_token>).

API Endpoints

Auth

  • POST /api/auth/register: Register a new user.
  • POST /api/auth/login: Login and get a JWT token.

Products

  • GET /api/products: Get all products.
  • GET /api/products/{id}: Get a product by ID.
  • GET /api/products/{Name}: Get a product by Name.
  • POST /api/products: Create a new product.
  • PUT /api/products/{id}: Update a product.
  • DELETE /api/products/{id}: Delete a product.

Customers

  • GET /api/customers: Get all customers.
  • GET /api/customers/{id}: Get a customer by ID.
  • GET /api/customers/{Name}: Get a customer by Name.
  • POST /api/customers: Create a new customer.
  • PUT /api/customers/{id}: Update a customer.
  • DELETE /api/customers/{id}: Delete a customer.

Orders

  • GET /api/orders: Get all orders.
  • GET /api/orders/{id}: Get an order by ID.
  • POST /api/orders: Create a new order.
  • DELETE /api/orders: Delete an Order.
  • PUT /api/orders: Update an Order.

Future Enhancements

  • Add Unit Testing for each layer.
  • Implement Caching for performance improvements.
  • Expand functionality for Order Management, such as filtering by status.
  • Add Role-based Access Control (RBAC) for different user roles (e.g., admin, customer).

License

This project is licensed under the MIT License - see the LICENSE file for details.


This markdown is now properly formatted and ready to be used on GitHub or any markdown-supported platform.

About

This project is a robust and secure ASP.NET Core Web API designed to manage an online store, providing comprehensive functionality for product, order, and customer management. The API follows best practices in RESTful API design, ensuring that it is scalable, maintainable, and easy to integrate with various front-end applications or other systems.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages