Giter Site home page Giter Site logo

codingcolinmcm / ecommerce-online-inventory-sequelize Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 386 KB

E-commerce Back End with Object-Relational Mapping

License: MIT License

JavaScript 100.00%
api api-rest dotenv express expressjs insomnia javascript mysql mysql-database mysql2

ecommerce-online-inventory-sequelize's Introduction

eCommerce-Online-Inventory-Sequelize

Description

Problem:

eCommerce sites need a reliable and efficient way to manage their back end. This includes setting up an Express.js API and connecting it to a MySQL database using Sequelgize, a powerful ORM tool.

Solution:

To solve this problem, I have built the back end for an e-commerce site by configuring a working Express.js API to use Sequelize to interact with a MySQL database. This involved:

  1. Adding the necessary environment variables to the project and setting up the Sequelize configuration file.

  2. Defining Sequelize models for the different data entities in the e-commerce site, such as products, categories, and tags.

  3. Creating and running database migrations to update the MySQL database schema.

  4. Seeding the development database with test data.

  5. Testing the API routes using Insomnia Core to ensure that they function correctly.

By following these steps, I was able to create a reliable and efficient back end for the e-commerce site, with the ability to manage data using Sequelize and MySQL. This solution provides developers with a clear and straightforward way to set up an Express.js API using Sequelize and interact with a MySQL database.

Table of Contents

Overview

The application is organized into several files and folders:

  • The config folder contains the connection.js file, which sets up the Sequelize configuration for the MySQL database.

  • The db folder contains the schema.sql file, which creates the initial MySQL database schema.

  • The models folder contains the Sequelize models for the different data entities in the e- commerce site, such as products, categories, and tags.

  • The routes folder contains the API routes for the application, which allow developers to interact with the data entities in the MySQL database.

  • The seeds folder contains data that is used to seed the development database with test data.

  • LICENSE: This file contains the license agreement for the eCommerce application. It is licensed under the MIT License.

  • README.md: This is the README file for the eCommerce application, which provides information about the application, including how to install and use it.

The application has four models: Category, Product, Tag, and ProductTag. The Product model belongs to many Tag models, and the Tag model belongs to many Product models. Using the ProductTag model allows products to have multiple tags, and tags to have many products.

The application uses a dotenv file to store environment variables required for connecting to the MySQL database using Sequelize, such as the database name, username, and password. By storing these variables in a dotenv file, the application code can remain agnostic to the specific configuration details of the database, making it more modular and easier to maintain.

In addition to the API routes, the application also has controllers that handle the data returned by the Sequelize models and send it to the client-side.

Overall, this e-commerce application provides online store owners with a clear and straightforward way to set up an Express.js API using Sequelize and interact with a MySQL database.

Installation

To run this project, install the necessary npm packages by using:

npm install

Usage

To set up the data base to be populated with the seed data, execute the following commands:

mysql -u root -p
source db/schema.sql
quit

To seed the database with data, run the following command:

npm run seed 

Finally, you can run the application using the command:

npm start

To test the API routes, you can use a tool like "Insomnia Core" or "Postman." Open your preferred API testing tool and send requests to the API routes to interact with the data in MongoDB.

Screenshot

image

Demo Video

eCommerce Demonstration

License

License: MIT

The MIT License

© Colin McMurtray University at North Carolina Chapel Hill Coding Bootcamp MIT License Copyright (c) 2023 Permission is hereby granted, free of charge, to 
any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including 
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to 
whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE SOFTWARE.

Questions?

If you have any questions, please reach out to me using one of the following:

ecommerce-online-inventory-sequelize's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.