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

https://github.com/timothyjan/janshopper

Full-stack e-commerce web application using Angular for a responsive front-end, ASP.NET Core for a RESTful API, and SQL Server for database management, featuring user authentication, product CRUD operations, shopping cart functionality, and order tracking.
https://github.com/timothyjan/janshopper

Last synced: 9 months ago
JSON representation

Full-stack e-commerce web application using Angular for a responsive front-end, ASP.NET Core for a RESTful API, and SQL Server for database management, featuring user authentication, product CRUD operations, shopping cart functionality, and order tracking.

Awesome Lists containing this project

README

          

# JanShopper
Full-stack e-commerce web application using Angular for a responsive front-end, ASP.NET Core for a RESTful API, and SQL Server for database management, featuring user authentication, product CRUD operations, shopping cart functionality, and order tracking.

Process:


  • SQL Server Management Studio

    • Connect to Server

      • Server Type: Database Engine

      • Server Name: localhost

      • Authentication: Windows Authentication

      • Connect



    • Create a new Database

      • In the Object Explorer, right-click on Databases and select New Database

      • Database Name: JanShopperDb



    • Configure a User

      • Expand the Security node.

      • Right-click Logins and select New Login

      • In the Login - New dialog:

        • Login Name: Enter a username

        • Authentication: Choose SQL Server Authentication and set a password.



      • In the left panel, go to User Mapping, check your database (JanShopperDb), and assign the db_owner role.



    • Configure the Connection String in appsettings.json

      • "DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Database=JanShopperDb;User Id=youUserId;Password=yourPassword;Trusted_Connection=True;"





  • Create ASP.NET Core API

    • Add Required NuGet Packages

      • Microsoft.EntityFrameworkCore

      • Microsoft.EntityFrameworkCore.SqlServer

      • Microsoft.EntityFrameworkCore.Tools

      • For password hashing in UserRepository: Install BCrypt.Net: ~Install-Package BCrypt.Net-Next



    • Create Models(User, Category, Product) with data annotations.

    • Create DTOs to transfer only the required data between the client and server.
        User
      • UserRegistrationDTO for write operations where validation is critical.

      • UserProfileDTO for read operations where validation is not needed.



    • Create Database Context JanShopperDbContext. The DbContext simplifies database interactions, manages entities and their relationships, and ensures data consistency.

    • Create Repositories and IRepositories(Interface) for each model with async methods to abstract data access logic, promotes separation of concerns, and makes the code cleaner, more maintainable, and easier to test.

    • Create Controllers for each model to handle incoming HTTP requests, process the HTTP requests, and return appropriate responses.

    • Configure Program.cs to use connection string to SQL Server.

    • Create migrations and apply to the database to create tables.

      • ~dotnet ef migrations add InitialCreate

      • ~dotnet ef database update



    • Seed database with dummy data.

      • Create SeedData.cs.

      • Modify Program.cs to call the SeedData.Initialize method during application startup.

      • Add migrations and apply to the database to create tables.

        • Add Migration: ~dotnet ef migrations add SeedDataMigration

        • Apply Migration: ~dotnet ef database update



      • Clean and Recreate Database (Development Only)

        • ~dotnet ef database drop

        • ~dotnet ef migrations remove

        • ~dotnet ef migrations add InitialCreate

        • ~dotnet ef database update





    • Test all methods on Swagger.




Database Schema


  • User: Id, UserName, Email, Password

  • Category: Id, Name

  • Product: Id, Name, Description, Price, Stock, CategoryId

  • Order: Id, UserId, OrderDate, TotalAmount, Status

  • OrderItems: Id, OrderId, ProductId, Quantity, Price

  • Payment: Id, OrderId, PaymentDate, Amount, PaymentMethod