Skip to content

Sistem-Store is a comprehensive ERP system developed using Flask, designed to manage various aspects of a store. It includes features such as production charts, user management, and article management. The system supports multiple access levels to control user permissions and store operations.

Notifications You must be signed in to change notification settings

thawancomt/Sistem-Store

Repository files navigation

Here's an improved version of your README:

ERP System with Python

An ERP system built with Flask, Python, JavaScript, TailwindCSS, MySQL, SQLAlchemy, and more.

Features

  • Login and User Registration: Secure user authentication and registration system.
  • Access Levels: Different levels of access for users.
  • Admin Control: Admins have high-level control over the system.
  • Production Management: Release and control production, with dynamic chart visualizations.
  • Stock Management: Manage and visualize stock releases through charts.
  • Article Management: Create and set parameters for articles.
  • Store Management: Create and manage different stores.
  • User Store Association: Associate users with specific stores to control access.
  • Chart Types: Three different chart types: bar, line, and pie.
  • Article Unit Management: Create units, alias, and descriptions for articles.
  • Create orders for the store: You can genarate PDF with orders of articles that you has in the store

These features demonstrate practical application of knowledge in real-world scenarios.

Technical Details

  • Flask: The micro web framework used to build the system.
  • MySQL: Relational database management system used to store data.
  • SQLAlchemy: Object-Relational Mapping (ORM) library for Python, used to interact with the database.
  • TailwindCSS: Utility-first CSS framework, used to style the application.

Screenshots

Login Methods

Login Login

User Registration

Register Users Register Users

Charts

Production chart

image image

Chart filtered

image

Project Structure

flaskr (root)
├── blueprints
│   └── ...
├── app.py
├── run.py
└── CONFIG.py

Project Design

The project follows a modular structure where each route has its own blueprint with its own static and template folders. This makes it easy to understand and maintain each route individually. The project also uses a base HTML template to reduce boilerplate code, ensuring that common elements like navigation, headers, and CSS links are written only once.

Why Flask?

Flask was chosen for its simplicity and ease of use. It allows easy expansion and control over the project. Flask's plugins, such as flask-SQLAlchemy, facilitate seamless integration with SQLAlchemy ORM.

MySQL was chosen for its robustness, adding complexity but offering infinite possibilities.

Example Code

In this section we will see some examples of code to understand more about the why did I chosen Flask and its plugins.

ProductionService.py

Querying and Insert the Database is simple.

from datetime import datetime, timedelta

def get_production_history(self):
    today = self.date
    tomorrow = (datetime.strptime(today, '%Y-%m-%d') + timedelta(days=1))
    
    return (
        db.session.query(Production)
        .filter(
            and_(
                Production.store_id == self.store_id,
                Production.date >= today,
                Production.date <= tomorrow,
            )
        )
        .all()
    )

def insert_production(self, data):
    date = data.get('date')
    if date:
        del data['date']
        
    for article_id, quantity in data.items():
        if int(quantity) > 0:
            new_production = Production(
                store_id=self.store_id,
                creator_id=self.creator_id,
                article_id=article_id,
                quantity=quantity,
                date=date
            )
            db.session.add(new_production)
            
    db.session.commit()

Using flask-login

Initially, a custom login and session management system was created, but it became complex to maintain. Instead of it flask-login was implemented for easier session and login management.

LoginView.py

@authentication.route('/', methods=['POST'])
def login():
    email = request.form.get('email')
    password = request.form.get('password')
    
    if LoginService(email=email, password=password).login():
        return redirect(url_for('homepage.home'))
    
    flash('Invalid email or password', 'danger')
    return redirect(url_for('auth.login_page'))

LoginService.py

class LoginService:
    def __init__(self, email=None, password=None):
        if email is None or password is None:
            return self.logout()
        
        self.email = email
        self.password = password
        self.user = UserService(email=self.email).get_user_by_email()

    def login(self) -> bool:
        if self.user and self.verify_password(self.user.password):
            self.user.last_login = datetime.now()
            db.session.commit()
            login_user(self.user)
            return True
        
        return False

The Admin and the managers that has access to the system can created task to do

image

Also we have the Daily Task

You can set up tasks for gonna be show as daily tasks to be done, imagine has a task that you need to do every day, so you can create a daily task to manage it, and it has a complexity logic behind it, so if you put this created task as completed it wont disappear, but will stop to be showed in the nexts days.

Installation

# Linux
git clone https://github.com/thawancomt/Sistem-Store.git
cd extensions
npm install -D tailwindcss (if you want to modify it the style)
cd .. | cd Sistem-Store
python -m venv YOUR_VENV_NAME
source YOUR_VENV_NAME/bin/activate
pip install -r requirements.txt
create a .env and put the DB_USERNAME, DB_PWD, DB_HOST with the creadentials to you database.
flask -m run

# Windows
git clone https://github.com/thawancomt/Sistem-Store.git
cd extensions
npm install -D tailwindcss (if you want to modify it the style)
cd .. | cd Sistem-Store
python -m venv YOUR_VENV_NAME
YOUR_VENV_NAME/Scripts/Activate.ps1
pip install -r requirements.txt
create a .env and put the DB_USERNAME, DB_PWD, DB_HOST with the creadentials to you database.
flask -m run

Skills

Python, Flask, MySQL, SQLAlchemy, HTML, CSS, Flask-Login, Flask-SQLAlchemy, TailwindCSS

About

Sistem-Store is a comprehensive ERP system developed using Flask, designed to manage various aspects of a store. It includes features such as production charts, user management, and article management. The system supports multiple access levels to control user permissions and store operations.

Topics

Resources

Security policy

Stars

Watchers

Forks

Packages

No packages published