Code Monkey home page Code Monkey logo

personal-inventory's Introduction

Personal Inventory Tracker

Introduction

This repository is for a learning side-project to develop a personal inventory tracker using Django and React.

This project uses a hybrid structure, where the React is integrated into the Django project and interacts with the database through a RESTful API made with the Django REST framework. (See Architecture for more detail)

A demo for this project is deployed with Heroku, and is hosted at https://personalinventorytracker.herokuapp.com/. (Note that Heroku sleeps inactive apps, so it may take a while to initially load.)

GIF of Landing Page

Installation

For hosting on your local machine, follow these instructions on your terminal:

  1. Clone the repository onto your local machine with:

> git clone [email protected]:pangene/personal-inventory.git

  1. Move into your directory with

> cd personal-inventory

  1. Set up a virtual environment and install the necessary python packages with
> python -m venv venv
> source venv/bin/activate    <-- Note activating virtual envs on Windows is different
> pip install -r requirements.txt
  1. (Optional) Install the necessary node packages with

> npm install

  1. Run the following commands to prepare the project
> (Optional) npm run dev   <-- Bundles into index-bundle.js in static folder.
> python manage.py migrate

Note that running npm run dev is optional, since index-bundle.js is already included for the heroku repo. But, if you make any updates to the frontend, npm run dev must be run to see changes. To bundle for production, run npm run build instead.

  1. Start the server with

> python manage.py runserver

Now, the development server should be accessible from http://127.0.0.1:8000/.

Architecture

Below is an annotated folder structure (excluding files) of this github repo.

.   <-- Django project 
├── accounts    <-- Django app for all accounts/authentication stuff
│   ├── migrations
│   └── tests
├── frontend    <-- Frontend folder for the home React page (see below)
│   └── components
├── inventory   <-- Django app for all inventory stuff
│   ├── migrations
│   └── tests
├── myinventory     <-- Django config folder
├── static  <-- Django static resources folder
│   ├── css
│   ├── images
│   ├── js
│   └── webfonts
└── templates   <-- all templates used by Django, contains some base/include only html files as well
    ├── inventory   <-- all templates for inventory, including anchor for the React frontend
    └── registration    <-- all templates for accounts stuff

Note the above annotated architecture only includes the folders, and some basic knowledge of a Django project's typical file structure is expected.

As mentioned prior, this project uses a 'hybrid' structure for Django-React. This means that the frontend and backend are not completely decoupled. While perhaps not suitable for a large-scale project, this allows us to use many of Django's powerful 'batteries-included' built-in features, while also adding a bit of modern responsiveness.

This hybrid structure means that the React frontend anchors into the Django templates as it would when adding React to any html file. It interacts with the Django database with a RESTful API made with the Django REST Framework, with the serializers and views for the API found in the inventory/ folder.

Also, note that in the frontend, there is a components folder, but no styles folder. This differs from a proper React frontend, where components and styles are linked together so they are easily reusable. This is because the focus of this learning project was much more about the Django backend than the frontend. (Alternatively, it's because I didn't know that when I started.)

TODOS/Improvements

  • If you poke around the internals, you'll notice that the Item model includes a upc field. UPC stands for Universal Product Code, and it's because originally, I wanted to let the user scan bar codes. I had some trouble finding a good API for the UPC lookup though.

  • The frontend aspect, as noted in the architecture, is messy. I have only one styles.css for all my personal styling, which makes things fairly disorganized.

  • I use email as username. I should require an email to be sent to authorize accounts.

  • User profile and User authentication would ideally be separated.

personal-inventory's People

Contributors

pangene avatar

Watchers

 avatar

Forkers

denokenya

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.