A web application project developed at Lodz University of Technology. It combines a Flask backend with database management, REST API endpoints, and Machine Learning integration.
The app serves as a registry for cat data and features a k-Nearest Neighbors (k-NN) model to predict breeds based on physical attributes stored in the database.
- CRUD: REST API allows user to manage database records (Create, Read, Delete)
- Machine Learning: AI Model provides cat breed prediction using a k-NN classifier trained on the current dataset.
- Validation: Robust user input validation and HTTP error handling. It was crucial for us to eliminate vulnerabilities similar to SQL Injection.
- SQLAlchemy: Is used for secure SQLite database interactions and object-relational mapping.
- JSON: Returned by API Endpoints for external integration.
Backend was made in Python 3.8+, with the addition of Flask web interface.
Database is created through SQLite extension, provided by Python.
SQLAlchemy ensures proper ORM.
AI was created using Scikit-learn model with the usage of StandardScaler and K-nn classifier.
Testing was made with Unittest and Requests - both included in Python package.
Frontend is using HTML5 with Jinja2 templates and a simple CSS file for visuals.
-
Clone the repository
git clone https://github.com/velosysop/webcatt-app.git cd webcatt-app -
Install additional libraries
pip install flask flask-sqlalchemy scikit-learn requests
-
Run it!
python main.py
...or just double-click ;)
The server will start athttp://127.0.0.1:5000.
The following REST Endpoints are exposed:
| Method | Endpoint | Description | Example parameters |
|---|---|---|---|
GET |
/api/data |
Retrieve all records | - |
POST |
/api/data |
Add a new record | {"weight": 4.5, "tail_length": 30.0, "breed": 1} |
DELETE |
/api/data/<id> |
Delete a record by ID | - |
GET |
/api/predictions |
Predict breed (AI) | ?weight=5.0&tail_length=25.5 |
Automated tests were created and saved to file test.py. They verify API and error handling.
In order to run tests, you must run the server in one terminal, and then launch test.py in other terminal.