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.
- 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
andGetAllProducts
.
- .NET Core 8.0
- Entity Framework Core
- SQL Server
- JWT Authentication
- Swagger UI for API documentation
- AutoMapper for mapping DTOs
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.
- .NET 8.0 SDK installed.
- SQL Server installed or available.
- Visual Studio or VS Code.
-
Clone the repository:
git clone https://github.com/your-username/OnlineStoreAPI.git cd OnlineStoreAPI
-
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
-
-
Run the API:
dotnet run
- 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>
).
- Register a new user via
POST /api/auth/register
: Register a new user.POST /api/auth/login
: Login and get a JWT token.
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.
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.
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.
- 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).
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.