Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/luzefiru/assetica

A full stack inventory management web application for the modern consumer.
https://github.com/luzefiru/assetica

express-js full-stack mongodb rest-api restful-api

Last synced: 4 days ago
JSON representation

A full stack inventory management web application for the modern consumer.

Awesome Lists containing this project

README

        

# Assetica

A cloud-based inventory management web application for the modern consumer. Powered by an Express.js REST API web service hosted on [Render.com](https://render.com/) that fetches data from a NoSQL [MongoDB](https://www.mongodb.com/) database cluster and performs HTML server-side rendering with EJS.

## Database Schema

This schema was made with [QuickDBD](https://www.quickdatabasediagrams.com/) for visualizing the relationships between the Mongoose Models.

- an `Item`'s `category` array field can have **1 or many** `Category` objects.
- a single `Category` object can belong to **0 or many** `Item` objects at any time.
- `URL` Strings are [Mongoose Virtuals](https://mongoosejs.com/docs/tutorials/virtuals.html) that are based on the base route URL and the `Schema.Types.ObjectId`.

```js
const ItemSchema = new Schema({
name: { type: String, required: true, trim: true },
description: { type: String, required: true, trim: true },
category: { type: Schema.Types.ObjectId, ref: 'Category', required: true },
price: { type: Number, required: true },
in_stock: { type: Number, required: true, min: 0, default: 0 },
});

ItemSchema.virtual('URL').get(function () {
return `/item/${this._id}`;
});

const CategorySchema = new Schema({
name: { type: String, required: true, trim: true },
description: { type: String, required: true, trim: true },
});

CategorySchema.virtual('URL').get(function () {
return `/category/${this._id}`;
});
```

## Mockups