Code Monkey home page Code Monkey logo

stocked-up's Introduction

StockedUp | Live Demo

GitHub Workflow Status (with event) Website codecov Docker Image Version

cover

StockedUp is a complete Inventory Management System that focuses on managing distributed stock for large organizations.

Quick Start

If you want to start using StockedUp, I host fully fledged live demo. For simplicity's sake, you can also create a demo account and skip the registration process.

You can also setup local instance on your machine or deploy this project to a cloud. For instructions please reefer to the setup guide.

About

StockedUp is an easy-to-use service that allows for managing vast amounts of inventory data for logistical companies. The design philosophy is to separate product definitions from actual stock data. This allows for separation between global changes of product details (such as price or description) and stock values.

The general ideas used in StockedUp are:

  • Organization - You can think of an organization as your company.
  • Product Definition - Information about a product. Its name, price, description, SKU.
  • Warehouse - Representation of the physical location where your company stores products, like a warehouse or a store.
  • Inventory - A product inside a warehouse with quantity and its location.

Tech Stack

  • Nest.js - Nest.js, a TypeScript-based Node.js framework, is used as the main backend.
  • React - React.js alongside Tailwind CSS and other client-side libraries is used as the frontend library.
  • Amazon AWS - AWS is used as the primary hosting provider that handles server hosting with EC2 and image hosting with S3.
  • MongoDB - MongoDB (with Mongoose ODM) is the primary database used to optimize access to vast amounts of organizational data.
  • Redis - Redis is used as a secondary database for sessions and caching.

API

StockedUp uses a REST API authenticated using session cookies. You can explore this API using Swagger or Postman:

Run In Postman View in Swagger

Contributing

Want to contribute to the project?

First of all, thanks! If you find any problems with the project or want to suggest a feature, don't hesitate to create an issue. If you want to contribute code changes, please create Pull Requests.

stocked-up's People

Contributors

imgbot[bot] avatar mrbartusek avatar

Stargazers

 avatar  avatar

Watchers

 avatar

stocked-up's Issues

Implement demo accounts system

Users should be able to create demo accounts via

  • Frontend navbar button
  • Register form

image

This demo account should create:

  • A user account that have no login credentials and is marked as isDemo
  • This account should be deleted after 24 hours
  • This account should have the following pre-defined entities:
    • 1 organization
    • 4 warehouses
    • 30 product definitions
    • randomly distributed inventory items in all warehouses

This demo can be themed for a car parts store. Three warehouses can be physical store locations. Products are oil filters, alternators, and spark plugs.

Add organization security managment panel

Add a panel for managing members of the organization

image

Front

  • Ability to view members with pagination
  • Dropdown to change member role
  • Button to remove a user from an organization with a popup confirmation
  • Page to add new members to the organization

Back

  • List members (paginated) endpoint
  • POST Add/update rule endpoint
  • DELETE rule endpoint
  • Invite member endpoint

Add missing tests

There are missing tests that cause CI to fail

  • Auth Module
  • Inventory Module
  • Products Module
  • Organizations Module
  • Inventory controler
  • Organization controller

Demo disable bug

Updating user preferences on the demo account currently disables the demo mode.

Data consistency on Updates/Deletes

  • Consistency on Create / Update / Delete between warehouses and org warehouse references
  • Delete inventory on warehouse delete
  • Delete inventory on product delete

Cleanup data-based repositories and services mocks

Mocks for model-based services and repositories became very messy and need to be cleaned. For example this is mock for products repository

const regularMockFindFunction = (id?: Types.ObjectId) => {
	return {
		_id: id,
		name: 'test-product',
		buyPrice: 10,
		sellPrice: 10,
		imageKey: 'image-key',
	};
};

const mockProductsRepository = {
	create: jest.fn((dto: CreateProductDto) => {
		return dto;
	}),
	find: jest.fn(() => new Array(10).fill(() => regularMockFindFunction(new Types.ObjectId()))),
	findById: jest.fn((id: Types.ObjectId) => regularMockFindFunction(id)),
	deleteOneById: jest.fn((id: Types.ObjectId) => regularMockFindFunction(id)),
	exist: jest.fn(() => true),
	findOneByIdAndUpdate: jest.fn((id: Types.ObjectId, query: any) => ({
		...regularMockFindFunction(id),
		...query,
	})),
	countDocuments: jest.fn(() => 100),
	paginate: jest.fn(() => ({ data: [regularMockFindFunction(new Types.ObjectId())] })),
};

Which is just tons of duplicate code over all the tests, this can be siplified to:

const mockProductsRepository = new MockEntityRepository<Product>({
		name: 'test-product',
		buyPrice: 10,
		sellPrice: 10,
		imageKey: 'image-key',
	});

Rework account creation experience

Currenly, a user creating an account faces a choice to create a demo or regular account. This choice is fine but I think the register option should be the main option and the demo should be smaller in size, they should not be just similarly sized options.

image

Rewrite controllers tests to mock repos

All service tests have been recently rewritten to MockEntityRepository, controllers should receive similar treatment, probably using something like MockEntityService.

  • ProductsController
  • InventoryController
  • WarehousesController
  • OrganizationsController

Missing delete pages

The following resources have missing delete forms while API routes are complete

  • Organization
  • Warehouse
  • Product
  • Inventory Item

Clean up module references

StockedUp currently has a messy structure regarding module references. There are a couple of god modules, that have dependencies for half of the project. Most modules use forwardRefs. Many modules depend on each other unnecessarily. The goal of this issue is to check all modules and implement fixes regarding their imports and exports.

Progress:

  • AuthModule
  • AuthEmailsModule
  • DemoModule
  • EmailsModule
  • GravatarModule
  • ImagesModule
  • InventoryModule
  • OrganizationsModule
  • ProductsModule
  • UsersModule
  • WarehousesModule
  • OrganizationResolverModule
  • RedisModule
  • S3Module
  • S3CacheModule
  • SecurityModule

Implement a proper `FormImageInput`

Using <input type="file" /> was always tricky. There can be a nice layer of abstraction added to properly upload files to the backend.

Ideally a FormImageInput should have a simple signature:

<FromInput {...register('image')} />

Honesty I am not quite sure if it is possible with react-hook form. But this is the ideal solution.

This element should serve multiple purposes:

  • The user should be able to view the current image
  • The user should be able to set or replace the image
  • The user should be able to delete the image

These actions should return probably ImageDto to react hook form? If that's even possible, there is multipart/form-data' encoding required,

Rewrite cascade delete logic to event emmiters

The current code logic around cascade deleting is messy, violates SOLID and makes a lot of barely used dependencies (and also a ton of forwardRef). There are services which are responsible for deleting other entities (this should not happen)

Instead, there should be Event Emmiters configured to send and listen to delete events. For example organizationsService can fire OrganizationDeleteEvent and product and warehouse services can listen to it.

This needs to be changed in the following files:

  • organizations.service.ts - deleting warehouses and products
  • organizations.service.ts - deleting and adding warehouse refs to org
  • products.service.ts - deleting inventory items
  • warehouses.service.ts - deleting inventory items
  • users.service.ts - deleting ACL rules and empty orgs

Setup real attachments

Following resources use placeholder photos

  • User avatars
  • Products

These resources should have the ability to upload and retrieve images from Rest API to S3

Blocked by: #8

Organization settings page rework

The current setup of organization settings is lacking and blocks the ability to add new features

Mock:

org mock

Progress:

  • Create elements for creating a generic settings page with react-router routing
  • Implement this element for organization pages
  • Organization details page with buttons to edit, delete and leave
  • Warehouse details page
  • Settings page
  • #32

Rework users profile page

There are currently some issues that are blocked by the lack of space on user settings page such as:

This page should be reworked using <SettingsLayout /> element. Mock design:

image

Move Email confirm & Password reset to separate module

Currently the auth-related email actions such as:

  • Confirming user email
  • Resetting user password

(And maybe in the future things like confirming account deletion or changing password)

Are handled by AuthController and AuthService which is I guess not that bad place for these, but kind of makes the auth module bear too much responsibility.

https://github.com/MrBartusek/stocked-up/blob/master/apps/api/src/auth/auth.controller.ts#L68-L97

These actions should be moved to a separate module, that depends on token service, auth service and email service. It can be named something like AuthEmailsModule

Improve E2E test suite

Many tests are missing:

  • Basic auth: register, login, logout
  • creating demo accounts
  • Updating user profile
  • CRUD on organizations
  • CRUD on products
  • CRUD on warehouses
  • CRUD on inventory items

Create setup guide

This project lacks a propert SETUP.md file with setup guide. There should also be a mention of this file in

  • README section
  • Contributing section

Proper organization access system

Currently, any logged user can modify any org resources. This should restricted via some access control system

List of ways that security module can be called:

  • HasOrganizationAccessPipe when org id is passed via params
  • HasProductAccess, HasWarehouseAccess and other similar pipes that will fetch org id
  • SecurityValidationPipe to validate DTOs with custom decorators (with reflect-metadata)

E-mail system

StockeUp currently lacks an email system to notify and validate important account steps.

  • Basic email system
  • Workflow for tokens and confirmable emails
  • Confirming email (via user token)
  • Reseting password (via user token)

The following tools can be used:

Disable security controls for non-admins

Users that are not admin or higher will be rightfully blocked from creating, deleting and updating of security rules by backend. But, buttons for them are still enabled.

image

Remove mock data from Dashboard

A lot of data in the main dashboard currently is not working, not implemented or fake elements. They need to be replaced before 1.0:

image

Resources pagination and filtering

The following resources should be paginated, filterable and searchable:

Backend:

  • Organizations
    • Pagination
  • Products
    • Pagination
    • Search by: name
    • Sort by: buyPrice, sellPrice, name
  • Inventory Items
    • Pagination
    • Sort by: quantity
  • Warehouses
    • Pagination

Frontend:

  • Products
  • Inventory Items
  • Organizations
  • Warehouses

User's settings page

There is a button for user settings that is not used:

image

This page should include the ability to

  • Change username
  • Change password
  • Change avatar
  • Delete account

Rewrite organization recalculate logic to event emmiters

The current code logic around recalculating org values is messy and hard to use. Services need to manually call value recalculation on each action. Instead, there should be Event Emmiters configured to listen to create, update and delete events inside warehouseStatsService and call recalculation independently.

This needs to be changed in the following files:

  • organizations-stats.service.ts
  • warehouse-stats.service.ts
  • inventory-stats.service.ts
  • any other files that manual call recalculation

This is the chart of how this logic should be implemented:

image

This implementation features two queues to prevent duplicate events from firing and hopefully optimize this whole process. There are situations where recalculation is fired multiple times and acting on it is wasting resources

  • Deleting organization calls warehouse recalculate for each deleted inventory item and product. Each of this recalculations calls organization recalculate
  • Deleting warehouse calls recalculation for each deleted inventory item
  • Deleting product call recalculation for each deleted inventory item

Improve inventory item quanity modificaiton

image

Updating quantity might be tricky and prone to error if it is just an input field.

The objective is to add a better experience for adding and removing inventory on this page. There should be option to

  • Type quantity manually (like right now)
  • Add/Remove specific ammount

Add popup product selector field

image

Currently /inventory/add doesn't allow for selection of product definition to add. Instead, it redirects to the products page.

Product selection button should open a popup with simplified ProductsTable and search bar to easily select product

Improve way that e-mail address is changed

The current workflow for changing e-mail address of user is just simple input field with PUT to API. The actions of changing user email should be more robust:

  • First, the email changing page should be another sub-page in user settings
  • Changing emails needs to require the current user password
  • The user needs to re-confirm this email

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.