# Python Flask CRUD Application  

A minimal python flask app for inventory management, with some basic functionality:  
- Fetch and display items from the MySQL db as an html table  
- Add new items to the db (individually) using a form  
- Edit existing (individual) items in the db using a form  
- Delete (individual)items in the db  
- Add a batch of new items from a csv file  
- Edit a batch of existing items with new data from a csv file  
- Let the user preview and edit the csv data in a table before submission  
- Use an admin-defined configuration to decide the attributes of an item, and how to manage the db and data  

## Acknowledgment  

This project was originally forked from [this project](https://github.com/MovieTone/crud-flask-export-csv), although it has undergone significant improvent, and resembles nothing like it.

## File structure:  
```
.
├── app.py                     # Main application file
├── config.py                  # Application configuration (database, item attributes)
├── definitions/               # Definitions for attributes and database models
│   ├── attribute.py           # Attribute types (text, integer, date, select)
│   └── models.py              # SQLAlchemy models and dynamic table creation
├── functions/                 # Helper functions
│   ├── process_csv.py         # Extract and process CSV data
│   ├── validate_config.py     # Validate configuration file
│   └── validate_values.py     # Validate user input and CSV data
├── routes/                    # Flask routes
│   ├── confirm_save.py        # Save validated CSV data to the database
│   ├── create.py              # Add new items
│   ├── delete.py              # Delete items
│   ├── export_csv.py          # Export data as CSV
│   ├── update.py              # Edit existing items
│   ├── upload.py              # Upload and process CSV files
│   └── viewall.py             # View all items in the database
├── static/                    # Static files (e.g., JavaScript)
│   └── edited_csv.js          # JavaScript for editing CSV preview tables
└── templates/                 # HTML templates
    ├── csv_preview.html       # Preview and edit CSV data
    ├── delete.html            # Confirm item deletion
    ├── item_form.html         # Form for adding/editing items
    ├── upload.html            # Upload CSV file
    └── viewList.html          # Home page (view all items)
```