Here's an improved version of your README:
An ERP system built with Flask, Python, JavaScript, TailwindCSS, MySQL, SQLAlchemy, and more.
- 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, aliases, and descriptions for articles.
These features demonstrate practical application of knowledge in real-world scenarios.
- 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.
flaskr (root)
├── blueprints
│ └── ...
├── app.py
├── run.py
└── CONFIG.py
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.
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.
In this section we will see some examples of code to understand more about the why did I chosen Flask and its plugins.
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()
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.
@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'))
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
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.
# 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 Sistem-Store
python -m venv YOUR_VENV_NAME
source YOUR_VENV_NAME/bin/activate
flask -A run.py run
# Windows
git clone https://github.com/thawancomt/Sistem-Store.git
cd Sistem-Store
python -m venv YOUR_VENV_NAME
YOUR_VENV_NAME/Scripts/Activate.ps1
pip install -r requirements.txt
flask -A run.py run
echo 'Done'
Python, Flask, MySQL, SQLAlchemy, HTML, CSS, Flask-Login, Flask-SQLAlchemy, TailwindCSS