Skip to content

Estka-ai/JE-Autos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JE-AUTOS: Cloud Inventory System (Cyberpunk Edition)

A professional automotive inventory management system featuring bulk data importing from CSV files, fully integrated with Aiven MariaDB Cloud.


Tech Stack

  • 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-data and file uploads via diskStorage.
    • CSV-Parser: Fast, streaming CSV parser for processing large datasets (100+ rows).
    • Dotenv: Secure management of environment variables.

Installation & Setup

1. Prerequisites

Ensure you have Node.js and Yarn installed on your system.

2. Dependencies

Install all required packages by running the following command in your terminal:

yarn install

Environment Configuration (.env)

Create 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

Database Management (Aiven Cloud)

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

SQL Schema Overview

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.

Project Structure

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

Running the Application

----yarn dev

Technical Investigation: Multer & Middlewares

  1. 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.

  2. 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.

  3. 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.

  1. 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.

About

Vehicle inventory control system — Node.js + Express + MySQL with SQL Triggers, file uploads via Multer

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors