A professional automotive inventory management system featuring bulk data importing from CSV files, fully integrated with Aiven MariaDB Cloud.
- Backend: Node.js & Express framework.
- Database: MariaDB (3FN Architecture) hosted on Aiven Cloud.
- Frontend: Cyberpunk-themed UI built with HTML5, CSS3, and Vanilla JavaScript.
- Core Libraries:
- Multer: Middleware for handling
multipart/form-dataand file uploads viadiskStorage. - CSV-Parser: Fast, streaming CSV parser for processing large datasets (100+ rows).
- Dotenv: Secure management of environment variables.
- Multer: Middleware for handling
Ensure you have Node.js and Yarn installed on your system.
Install all required packages by running the following command in your terminal:
yarn installCreate a .env file in the root directory with the following variables:
DB_HOST=estka04-estkai.i.aivencloud.com
DB_USER=avnadmin
DB_PASSWORD=mypasswordhere
DB_NAME=defaultdb
DB_PORT=22078
PORT=3000
To manage the database or verify data integrity, connect directly to the Aiven instance via terminal: mysql -h estka04-estkai.i.aivencloud.com -P 22078 -u avnadmin -pAVNS_GY6VHfOElWqrEZUCcSB defaultdb
The database follows strict normalization rules (3FN) and business logic automation:
Vehicles Table: Stores the core inventory (Plates, Brand, Model Year, Base Price).
Persons Table: Stores seller and buyer information (Document ID, Full Name, Contact).
Transactions Table: Records all purchases and sales with Foreign Key constraints.
Business Logic (Trigger): An automated trigger tg_handle_sales updates vehicle availability status to 'SOLD' in real-time upon sale.
JE-AUTOS/ ├── config/ # Database connection logic using mysql2/promise ├── controllers/ # Business logic, CSV mapping, and error handling ├── middleware/ # Multer configuration for file upload handling ├── public/ # Cyberpunk Frontend (HTML, Neon CSS, JS) ├── routes/ # REST API endpoint definitions ├── uploads/ # Temporary storage for file processing ├── .env # Sensitive environment variables ├── app.js # Main server entry point └── package.json # Script and dependency manifest
----yarn dev
-
Middleware Definition and Flow A middleware is a function that executes during the request-response cycle. It acts as a bridge between the raw request and the final controller logic, allowing for tasks like authentication, logging, or file parsing.
-
Multipart/form-data Protocol Standard JSON requests cannot handle file binary data. The multipart/form-data protocol allows the browser to send files (like our 100-row CSV) by breaking the request into multiple parts, each with its own headers and content.
-
Multer Mechanisms: diskStorage vs. memoryStorage diskStorage: Used in this project to save uploaded files directly to the uploads/ folder. It is the most efficient choice for large CSV files as it prevents memory exhaustion (RAM).
memoryStorage: Stores files as Buffer objects in RAM. While faster for tiny files, it can crash the server if large datasets are uploaded.
- Bulk Import Logic Data Sanitization: The system automatically trims spaces and truncates strings to ensure database compatibility.
Automatic Cleanup: After a successful database insertion, the temporary file is deleted using fs.unlinkSync to maintain server storage health.