TradeFlow System

Table of Contents

GitHub

The project is deployed on AWS Lightsail (2vCPU, 1GB Memory). In addition to the backend application, PostgreSQL and Nginx based on Docker has been deployed separately. The program has been running continuously and stably for six months with 10 users.

Screenshots

1.png

2.png

3.png

4.png

5.png

6.png

7.png

Language Support

English, Simplified Chinese, Korean

Tradeflow Core

A lightweight tradeflow system designed for small businesses, built with React.js based frontend and Node.js + SQLite/PostgreSQL based backend.

Key Features

  • Inventory Management: Track inventory levels, inbound and outbound operations
  • Product Management: Manage product information and pricing strategies
  • Financial Tracking: Monitor accounts payable and accounts receivable
  • Sales Analysis: Generate reports and analyze sales data
  • Multi-language Support: Supports English, Korean, and Chinese
  • Data Export: Supports data export in Excel format
  • JWT Authentication: Stateless authentication system
  • Role Based Access Control: Can assign Editor and Viewer to each user
  • Multi-Database Support: Seamlessly switch between SQLite (default) and PostgreSQL for production environments

Tech Stack

  • Frontend: React 19, Vite, Ant Design, TypeScript
  • Backend: Node.js, Express, SQLite3 / PostgreSQL, TypeScript
  • Authentication: JWT stateless authentication
  • Styling: CSS3, Ant Design component library
  • Logging: Winston logging system
  • Precise Calculations: Decimal.js for precise numerical calculations

Backend Architecture Overview

Database Schema (Backend)

SQLite doesn’t support Date, so we use TEXT instead…

PARTNERS

Column NameData TypeKeyNullableDefault
codeTEXTUniqueNoNULL
short_nameTEXTPKNoNULL
full_nameTEXTNoNULL
typeINTEGERNoNULL

PRODUCTS

Column NameData TypeKeyNullableDefault
codeTEXTUniqueNoNULL
categoryTEXTNoNULL
product_modelTEXTNoNULL
remarkTEXTNoNULL

PRODUCT PRICE

Column NameData TypeKeyNullableDefault
idINTEGERUNIQUE, PKNoAI
partner_codeTEXTFKNoNULL
product_codeTEXTFKNoNULL
effective_dateTEXTNoCURRENT_TIMESTAMP
unit_priceREALNoNULL

INBOUND RECORDS

Column NameData TypeKeyNullableDefault
idINTEGERUNIQUE, PKNoAI
supplier_codeTEXTFKNoNULL
product_codeTEXTFKNoNULL
quantityINTEGERNo0
unit_priceREALNo0
total_priceREALNo0
inbound_dateTEXTNoCURRENT_TIMESTAMP
invoice_dateTEXTYesNULL
invoice_numberTEXTYesNULL
receipt_numberTEXTYesNULL
order_numberTEXTYesNULL
remarkTEXTYesNULL

OUTBOUND RECORDS

Column NameData TypeKeyNullableDefault
idINTEGERUNIQUE, PKNoAI
customer_codeTEXTFKNoNULL
product_codeTEXTFKNoNULL
quantityINTEGERNo0
unit_priceREALNo0
total_priceREALNo0
outbound_dateTEXTNoCURRENT_TIMESTAMP
invoice_dateTEXTYesNULL
invoice_numberTEXTYesNULL
receipt_numberTEXTYesNULL
order_numberTEXTYesNULL
remarkTEXTYesNULL

INVENTORY

Column NameData TypeKeyNullableDefault
product_modelTEXTPKNoNULL
quantityINTEGERNo0

INVENTORY LEDGER

Column NameData TypeKeyNullableDefault
idINTEGERUNIQUE, PKNoAI
product_modelTEXTNoNULL
change_qtyINTEGERNoNULL
change_typeTEXTNoNULL
reference_idINTEGERYesNULL
dateTEXTNoNULL
created_atTIMESTAMPNoCURRENT_TIMESTAMP

RECEIVABLE PAYMENTS

Column NameData TypeKeyNullableDefault
idINTEGERUNIQUE, PKNoAI
customer_codeTEXTFKNoNULL
amountREALNo0
pay_dateTEXTNoCURRENT_TIMESTAMP
pay_methodTEXTYesNULL
remarkTEXTYesNULL

PAYABLE PAYMENTS

Column NameData TypeKeyNullableDefault
idINTEGERUNIQUE, PKNoAI
supplier_codeTEXTFKNoNULL
amountREALNo0
pay_dateTEXTNoCURRENT_TIMESTAMP
pay_methodTEXTYesNULL
remarkTEXTYesNULL

API Overview

  • Base URL: /api
  • Auth: POST /api/login returns a JWT; include Authorization: Bearer <token> in subsequent requests.

Key endpoints (high level):

AreaMethod & PathPurpose
AuthPOST /api/loginExchange credentials for JWT
OverviewGET /api/overview/statsFetch dashboard metrics
OverviewPOST /api/overview/statsTrigger metrics recomputation
Products/api/products (GET, POST, PUT, DELETE)CRUD endpoints for product catalog
Partners/api/partners (GET, POST, PUT, DELETE)CRUD endpoints for customers/suppliers
Pricing/api/product-prices (GET, POST, PUT, DELETE)CRUD partner-specific product prices (also see /current and /auto helpers)
Inventory Inbound/api/inbound (GET, POST, PUT, DELETE); POST /api/inbound/batchReceive goods and perform batch updates
Inventory Outbound/api/outbound (GET, POST, PUT, DELETE); POST /api/outbound/batchShip goods and perform batch updates
StockGET /api/stockReal-time stock summary by product
Finance - Receivable/api/receivable/payments (GET, POST, PUT, DELETE)Track customer payments
Finance - Payable/api/payable/payments (GET, POST, PUT, DELETE)Track supplier payments
ExportGET /api/export/:typeExport configured datasets (e.g., Excel)

Quick Start

Prerequisites

  • Node.js 22+
  • npm
  • Docker (Optional)

Development (Without Docker)

  1. Clone the project:
git clone [https://github.com/lihaozhe013/tradeflow-core.git](https://github.com/lihaozhe013/tradeflow-core.git)
cd tradeflow-core
  1. Install dependencies:
npm run install:all
  1. Set up configuration:
# Copy the example configuration files
mkdir -p data
cp -r config-example/* data/
  1. Init:
npm run build
  1. Start the development servers:
# Start the dev server()
npm run dev

Data Files

The system uses JSON configuration files located in the data/ directory:

  • appConfig.json: Application settings and company information
  • exportConfig.json: Data export templates and settings