aytugyayman.com.tr

Logistics ERP · web application

In-house · in production

BEST Freight ERP

BEST Freight ERP is a web-based ERP system I develop for an international road freight company. The office team runs import and export trips, customs declarations, vehicles, drivers and accounting through it. The interface is in Turkish, and the system is used every day.

Because it's in-house software, I don't share its source code, screenshots or anything that belongs to the company. This page only describes what it does and how it's built.

Modules

  • Operations

    Import and export trips (positions), loads, seal numbers, CMRs and other documents generated as PDF, an archive of scanned paperwork, and a loading-metre calculator.

  • Customs

    NCTS transit declarations through SGS TransitNet, GVMS/GMR and CDS export declarations for the UK, and ICS/ENS for entry into the EU. The status of the declarations is polled regularly in the background.

  • Fleet

    GPS vehicle tracking, tachograph data sync, mileage and fuel per trip, fuel card transactions, and ECMT and UBAK permits.

  • Drivers

    Driver records, visa and document expiry dates, pages where drivers can upload documents from their phones, and messages to drivers.

  • Finance

    Accounting, expense forms, trip profitability, and e-invoicing through the accounting software.

  • Office

    E-mail tracking over IMAP, with reference codes that link correspondence to trips, team chat and notifications, HR and insurance records.

  • Document reading and assistant

    OCR and AI to extract data from scanned documents, and an assistant that answers questions asked in Turkish from the database.

How it's built

The server is written with Node.js and Express 5. It's split into routes, controllers and models (SQL only), and the code that talks to outside systems lives in separate services. The front end is a single-page app written with React 19, TypeScript and Vite, served by Express as static files.

Data is kept in several SQLite databases (better-sqlite3). The main data, the customs and messaging tables, the audit log, GPS and sessions each have their own file. PostgreSQL holds the tachograph data and live GPS.

Notifications and chat run in real time over Socket.IO. Jobs such as customs status polling, GPS refresh, tachograph sync and backups are scheduled in the background with node-cron. Backups are kept both locally and on Google Drive.

PDFs are generated with pdf-lib and pdfmake, Excel files with ExcelJS. SGS is reached over SOAP, HMRC through REST APIs with OAuth.

The hard parts

  • Moving from EJS to React

    The interface started as EJS pages rendered on the server. I moved the pages to React and TypeScript one by one while the system stayed in use. The real work wasn't the API; it was matching the small behaviours and the look of the old pages exactly.

  • Every customs system speaks its own language

    SGS's SOAP service and XML schemas for NCTS, HMRC's REST APIs with OAuth for the UK, and a separate flow for ICS/ENS. Each has different error codes and a different status cycle, so each integration runs as its own service with its own background polling.

  • Matching CMRs to loads

    A single delivered CMR can close several loads. Weights are written the Turkish way: “20.840” kilograms becomes 20.84 with a naive parse and matches the wrong row. The matching logic exists in both the front end and the server, and a test checks that the two stay identical.

Security

  • Session-based login and two-factor authentication (TOTP) with trusted devices.
  • CSRF protection and a limit on login attempts.
  • Role- and page-based permissions, re-read from the database on every request.
  • An audit log kept in a separate database.
  • Regular local and Google Drive backups.

Status

The system is in production and used every day. Development continues in small, frequent changes.