Skip to content

Inventory management API for D&D players. Built with MongoDB, Express, and NodeJS

Notifications You must be signed in to change notification settings

snaeem3/inventory-api

Repository files navigation

Contributors Forks Stargazers Issues

D&D Social Inventory API

This project showcases a Dungeons & Dragons inventory application API built with Node.js & MongoDB. This API manages client requests to store, retrieve, and manage custom D&D items, user inventories, profile pictures, and more.

View Demo

Table of Contents
  1. Project Links
  2. Features
  3. Planned Features
  4. Skills Involved with this project
  5. Getting Started

Project Links

Live Client View: inventory-client-plum.vercel.app/

Front End: github.com/snaeem3/inventory-client

This project was inspired by a previous application: github.com/snaeem3/inventory-application

(back to top)

Features

👥 User Management Endpoints: Handle client requests for signing up, logging in, updating profile pictures, editing inventory items, and tracking gold

🛠️ Catalog Item Endpoints: Handle requests to create, read, update, and delete custom items and item pictures.

🔐 Authentication Management: Use JSON web tokens to ensure only authorized users can send requests to the server

(back to top)

Planned Features

See the client project for planned features to the overall application

(back to top)

Skills Involved with this project

  • Mongoose to connect to a MongoDB database
  • Querying data from MongoDB
  • CRUD (Create, Read, Update, and Delete) operations in MongoDB: findByIdAndDelete(), findByIdAndUpdate(), etc.
  • Cloudinary to manage image storage and retrieval
  • Multer to handle file upload requests from client
  • JSON Web Token (JWT) for secure and verifiable user authentication
    • Creation of token when users successfully log-in
    • Token verification when users make certain requests (e.g. Blog post creation, comment deletion, etc.)
  • User authentication with Passport.js
    • LocalStrategy for username and password authentication
    • Managing user sessions and serialization/deserialization
  • Secure password hashing using bcrypt
  • CORS to enable requests from specified routes
  • Basic and Dynamic Routing (by item ID) using Express Router
  • Middleware chaining in Express
  • Defining and creating Models with various schema types
  • Schema Virtual to return user's net worth
  • Schema Sub Documents- InventoryItemSchema in models/user.js
  • Controller modules (e.g., itemController, userController, etc.), adhering to the Model-View-Controller (MVC) architectural pattern and promoting code modularity
  • Express validator to validate and sanitize form data from the backend
  • Asynchronous Error Handling
  • App deployment with Vercel

Getting Started

To get a local copy up and running follow these simple steps.

(back to top)

Prerequisites

Before you get started with this application, make sure you have the following prerequisites installed on your system:

  • Node.js (version >= 18.12.1)
  • npm (Node Package Manager)

(back to top)

Installation

To install the application and its dependencies, follow these steps:

  1. Clone the repository:

    git clone https://github.com/snaeem3/inventory-api.git
    cd inventory-api
  2. Install the required packages:

    npm install
  3. Create a .env file in the root directory and configure the following variables:

    MONGODB_URI=your_mongodb_uri
    ACCESS_TOKEN_SECRET=your_jwt_access_token_code
    REFRESH_TOKEN_SECRET=your_jwt_refresh_token_code
    CLOUD_NAME="your_cloudinary_cloud_name"
    API_KEY="your_cloudinary_api_key"
    API_SECRET="your_cloudinary_api_secret"

    Replace your_mongodb_uri with the MongoDB connection URI.

    Replace your_jwt_access_token_code and your_jwt_refresh_token_code with secret keys of your choosing.

    Replace your_cloudinary_cloud_name, your_cloudinary_api_key, and your_cloudinary_api_secret with your Cloudinary credentials from the Cloudinary dashboard.

(back to top)

Usage

To run the application, you can use the following command:

npm start

Then, open the app in your web browser by navigating to http://localhost:3000.

(back to top)

About

Inventory management API for D&D players. Built with MongoDB, Express, and NodeJS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published