DEV Community

John Still
John Still

Posted on

Say Goodbye to Excel Hell: Build Your Cross-Border E-commerce WMS Data Hub with PostgreSQL and ServBay

Keywords: PostgreSQL, WMS, supply chain system, ServBay, local dev environment, cross-border e-commerce, API development, ERP integration


Image description
Cross-border e-commerce is booming, attracting many career switchers. But let’s be honest — managing inventory and orders with Excel or basic ERP modules quickly becomes tedious and error-prone. How can we optimize these repetitive workflows? The answer starts with your supply chain data.

In this article, I’ll show you how to build an efficient and reliable Warehouse Management System (WMS) data API using PostgreSQL and Flask, and how to speed up local development with ServBay — a lightweight all-in-one local development environment for macOS.

Image description

Why PostgreSQL for Your WMS?

PostgreSQL is a powerful open-source relational database, ideal for:

  • Accurate, real-time inventory tracking: Store SKU, location, and quantity precisely.
  • High-concurrency order processing: Ensure transactional integrity across multiple users.
  • Multi-system data integration: Serve as the central data hub linking ERP, TMS, and CRM systems.

Here’s a simple example of core table structures for stocks and orders:

CREATE TABLE stocks (
  id SERIAL PRIMARY KEY,
  sku VARCHAR(50) UNIQUE NOT NULL,
  quantity INTEGER NOT NULL,
  location VARCHAR(50) NOT NULL
);

CREATE TABLE orders (
  id SERIAL PRIMARY KEY,
  order_number VARCHAR(50) UNIQUE NOT NULL,
  sku VARCHAR(50) NOT NULL,
  quantity INTEGER NOT NULL,
  status VARCHAR(20) NOT NULL
);
Enter fullscreen mode Exit fullscreen mode

Quick Start: Build a RESTful WMS API with Flask

Using Python’s Flask framework and SQLAlchemy ORM, you can quickly expose your PostgreSQL data via REST APIs:

from flask import Flask, jsonify
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:password@localhost/wms_db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)

class Stock(db.Model):
    __tablename__ = 'stocks'
    id = db.Column(db.Integer, primary_key=True)
    sku = db.Column(db.String(50), unique=True, nullable=False)
    quantity = db.Column(db.Integer, nullable=False)
    location = db.Column(db.String(50), nullable=False)

class Order(db.Model):
    __tablename__ = 'orders'
    id = db.Column(db.Integer, primary_key=True)
    order_number = db.Column(db.String(50), unique=True, nullable=False)
    sku = db.Column(db.String(50), nullable=False)
    quantity = db.Column(db.Integer, nullable=False)
    status = db.Column(db.String(20), nullable=False)

@app.route('/stocks')
def get_stocks():
    stocks = Stock.query.all()
    return jsonify([{'sku': s.sku, 'quantity': s.quantity, 'location': s.location} for s in stocks])

@app.route('/orders')
def get_orders():
    orders = Order.query.all()
    return jsonify([{'order_number': o.order_number, 'sku': o.sku, 'quantity': o.quantity, 'status': o.status} for o in orders])

if __name__ == '__main__':
    with app.app_context():
        db.create_all()
    app.run(debug=True)
Enter fullscreen mode Exit fullscreen mode

This API allows your ERP, TMS, or other systems to consume inventory and order data in real-time — reducing manual errors and syncing delays.


Simplify Your Local Setup with ServBay

Setting up PostgreSQL and API dev environments locally can be a headache:

  • Complex PostgreSQL installation and configuration
  • Docker setup overhead and maintenance
  • Port conflicts and macOS permission issues

ServBay solves these problems by bundling PostgreSQL, PHP, Redis, Nginx, and other tools into a one-click macOS app. It’s perfect for developers needing a reliable, ready-to-use local environment without wrestling with configs.

How to Get Started

  1. Download and launch ServBay.
  2. Start PostgreSQL with one click.
  3. Connect via pgAdmin or DBeaver to create your wms_db database.
  4. Run your Flask app, which connects directly to ServBay’s PostgreSQL.
  5. Test your API with curl http://localhost:5000/stocks.

No Docker files, no terminal pain — just smooth local dev.

Image description

Why Choose ServBay Over Traditional Methods?

Scenario Docker ServBay
Local WMS API testing Complex installs and config One-click, zero config
Multi-service setup Manual Nginx and container tweaks Built-in HTTP routing and services
PostgreSQL setup Large images, slow updates Lightweight with GUI management
Debug & testing Difficult to simulate real env Easily replicate production setup

Final Thoughts

Optimizing cross-border e-commerce supply chains starts with solid data infrastructure. Before jumping to AI or big data, build a clean, standardized data layer using PostgreSQL and expose it through simple APIs. Using ServBay makes local development hassle-free and accelerates your build process.

Stay tuned for the next article where we'll dive into SQL query optimization for efficient inventory lookups and advanced API features.


Further Reading


#PostgreSQL #WMS #SupplyChainAutomation #CrossBorderEcommerce #ServBay #LocalDevEnvironment #FlaskAPI #ERPIntegration #InventoryManagement

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.