dvjsharma / Drawn2Shoe

Drawn2Shoe is a user-friendly e-commerce platform. It offers customers the ability to purchase and personalize their shoes. The platform's intuitive interface ensures seamless navigation and usability across a variety of devices.
MIT License
26 stars 44 forks source link

feat: !(Breaking) Implemented Prisma ORM and Initial Database Setup #138

Closed kaali001 closed 2 months ago

kaali001 commented 2 months ago

Description

This PR introduces the implementation of Prisma ORM for database management in the Drawn2Shoe project. The changes include integrating Prisma, setting up the initial database schema, and adding seed data. This is Feat: #117 .

Changes

  1. Prisma Integration

    • Added Prisma and @prisma/client dependencies. Reason: To include Prisma ORM and its client library for database management and operations.

          "dependencies": {
           "prisma": "^3.0.0",
           "@prisma/client": "^3.0.0"
           }
      
  2. Database Schema setup

    • Created prisma/schema.prisma:
    • Reason: To define the database schema using Prisma's modeling language, ensuring a structured and scalable database design.
    • Created initial database schema including models for Mainuser, Product, Cart, Orders, Design, Designer, Retailer, Shoe, and Supplier.
  3. Database Seeding

    • Created prisma/seed.js:
    • Reason: To populate the database with initial values, facilitating development and testing with predefined data.
  4. Controllers Implementation

    • Modified the files in controllers folder which includes user.js, product.js, cart.js files for making query to database using Prisma.
  5. README Update

    Updated README.md:

    • Reason: To provide detailed setup instructions for Prisma, the database, and controllers, ensuring a smooth setup process for developers.

      • Changes: Added sections for Prisma setup, database seeding, and controllers:

How to test

  1. Clone the repository:

    ```
       git clone https://github.com/dvjsharma/Drawn2Shoe.git
       cd Drawn2Shoe
    ```
    1. Install dependencies:

      • Client:

           cd client
           npm install
        • Server:

          cd ../server
          npm install
          
    2. Set up the database:

      • Create a config.env file in the server directory and copy the contents from .env.example.
      • Add your MySQL database url in .env file (your user name and password).
      • Ensure your MySQL service is running and your database is named drawn2shoe.
  2. Run Prisma commands:

          cd server
          npx prisma migrate dev --name init
          npx prisma/db.seed
    
  3. Run the application:

    • Frontend:

                cd ../client
                npm run dev
      • Backend:

              cd ../server
              node server.js
    1. Verify the changes:

      • Ensure the application runs without errors.
      • Check the database to confirm the seeded data is correctly populated.
      • Test the CRUD operations to ensure Prisma ORM and controllers are functioning as expected.

Additional Notes

Checklist:

dvjsharma commented 2 months ago

Initial overview looks good @kaali001, will test over the weekend.

dvjsharma commented 2 months ago

Hey @kaali001, please squash the commits into 1 for merge.

kaali001 commented 2 months ago

Hey @kaali001, please squash the commits into 1 for merge.

I have done it.

kaali001 commented 2 months ago

Hey @dcoder13 , please review it , I have two opened issues to work on.