A simple web app for managing a car database with full CRUD operations. Built with Flask and PostgreSQL.
This app lets you manage a car database through a web interface. You can add, view, edit, delete, and search records across 5 different tables. It also imports car data from a CSV file.
The database has 5 tables in Third Normal Form:
- companies - Car manufacturers (Ferrari, Toyota, etc.)
- fuel_types - Types of fuel (Petrol, Diesel, Hybrid, etc.)
- engines - Engine specs (type, CC, horsepower, torque)
- cars - Main car info with foreign keys to company, engine, and fuel type
- performance - Performance metrics (top speed, 0-100 acceleration)
-
Install PostgreSQL (if not already installed)
# macOS brew install postgresql brew services start postgresql # Ubuntu sudo apt install postgresql sudo systemctl start postgresql
-
Create database and user
sudo -u postgres psql CREATE DATABASE db; CREATE USER p4ris WITH PASSWORD 'p4ris'; GRANT ALL PRIVILEGES ON DATABASE db TO p4ris; \q
-
Install Python dependencies
python3 -m venv env source env/bin/activate pip install -r requirements.txt -
Set up environment variables
Create a
.envfile (already exists):DATABASE_URL="postgresql://p4ris:p4ris@localhost:5432/db" -
Run the app
flask run
-
Open in browser
Go to
http://127.0.0.1:5000
- View all records in any table
- Add new records with a form
- Edit existing records
- Delete records
- Search by name/type
- Import CSV data from
data/CarsDatasets2025.csv
- Backend: Flask (Python)
- Database: PostgreSQL
- Frontend: HTML, TailwindCSS, Vanilla JavaScript
- ORM: SQLAlchemy
.
├── app.py # Flask app setup
├── models.py # Database models (5 tables)
├── views.py # API routes and frontend route
├── controller.py # CSV import logic
├── templates/
│ └── index.html # Frontend UI
├── data/
│ └── CarsDatasets2025.csv
└── requirements.txt
Each table has full CRUD endpoints:
GET /api/{table}- Get all recordsGET /api/{table}/<id>- Get one recordPOST /api/{table}- Create recordPUT /api/{table}/<id>- Update recordDELETE /api/{table}/<id>- Delete recordGET /api/{table}/search?q=query- Search records
Tables: companies, fuel_types, engines, cars, performance
- The database is normalized to Third Normal Form (3NF)
- Foreign key relationships maintain data integrity
- CSV import parses messy data (e.g., "$1,100,000" → 1100000)
- All CRUD operations have error handling