Coder Social home page Coder Social logo

inventory-management's Introduction

Grocery Inventory Management

This repository contains a grocery inventory management system. It consists of a frontend and a backend.

Repository structure


inventory-management
├── frontend
└── backend

Installation


Frontend

cd frontend
npm install

Backend

cd backend
npm install

Frontend


The frontend is built with React, TypeScript, and Vite.

Local Development

npm run dev

Production Build

To build the frontend for production, run:

npm run build
npm run preview

Backend


The backend is built with Express, MongoDB, and Nodemon.

Local Development

Before running the backend server, make sure you establish a connection to the database.

To start the server locally, run:

npm run dev

Production Build

To build and run the backend server in production, use these commands:

npm run build
npm run start

Connecting to the Database


Local Database connection

To connect to a local MongoDB database:

  • Make sure MongoDB is installed on your system.
  • Create a collection using MongoDB Compass.
  • Configure the environment variable DATABASE_URL, located in the backend/.env path, with the MongoDB connection URL.
  • Run the mongod command in the terminal to establish a connection to the database.

MongoDb Atlas Cloud

To connect to a MongoDB Atlas cloud database:

  • Create an account on MongoDB Atlas.
  • Choose the Free tier subscription.
  • Configure the username and password.
  • Create a MongoDB instance with NodeJS as the connection driver.
  • Update the DATABASE_URL in the backend/.env file with the MongoDB Atlas connection URL.

Api Testing


Api Url: http://localhost:${PORT}/api

Items

Get all items

GET /items

Returns a list of items from the inventory. |

Status codes

Status code Description
200 OK Indicates a successful response.
500 Internal Server Error Indicates that server has encountered an error.

Example response:

[
    {
        "_id": "651fda7e14a661825ccd67fa",
        "id": "babf61f0-c032-49be-a3a7-1ba1069ebe3e",
        "name": "Tomato",
        "category": "grocery",
        "description": "",
        "price": 30,
        "createdAt": "2023-10-06T09:59:26.404Z",
        "updatedAt": "2023-10-06T09:59:26.404Z",
        "__v": 0,
        "quantity": 100
    },
]

Create a new item

Adds a new item to the items collection.

POST /items

Status codes

Status code Description
201 Created Indicates that the cart has been created successfully.
400 Bad Request Indicates that the parameters provided are invalid.
500 Internal Server Error Indicates that server has encountered an error.

Example Body:

{
    "id": "babf61f0-c032-49be-a3a7-1ba1069ebe3e",
    "name": "Orange",
    "category": "grocery",
    "description": "",
    "price": 40,
    "quantity": 70
}

inventory-management's People

Contributors

dhoni77 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.