A full-stack stock-management platform β Next.js + Electron frontend, FastAPI + PostgreSQL backend, with forecasting baked in.
A stock-management system with a Next.js 15 / React 18 dashboard (also packageable as a Windows Electron desktop app), a FastAPI backend powered by SQLAlchemy + asyncpg, a PostgreSQL store provisioned via Docker Compose, and a built-in ETL + forecasting pipeline (Prophet, scikit-learn) that loads sales, SKUs and stock data and serves predictions through the API.
- Next.js 15 App Router with React 18 + TypeScript 5
- shadcn/ui components on top of Radix UI primitives
- Tailwind CSS 4 styling, Recharts dashboards, react-window virtualization
- Electron 38 packaging via
electron-builderfor a Windows desktop build
- FastAPI with
uvicorn[standard] - SQLAlchemy 2 + asyncpg async DB access
- Pydantic-AI integration for assistant flows
- PyInstaller spec (
api.spec) for bundling the API as a single executable
- ETL pipeline populates the
sales,skus, andstocktables - Prophet + scikit-learn for demand prediction (see
backend/PREDICTION_API.md) - pandas, pyarrow, fastparquet for data wrangling
docker-compose.yamldefinesfrontend,backend, and apostgresservice- Per-service
Dockerfiles infrontend/andbackend/
| Tool | Version | Notes |
|---|---|---|
| π Python | 3.12+ | Backend + ETL |
| π¦ Node.js | 18+ | Frontend dev server |
| π³ Docker | with Compose v2 | Postgres (and full-stack run) |
| π Postgres | via compose | Default credentials admin / admin |
docker compose up -d postgrespip install -r backend/requirements.txt
python run_main.pyβ³ The ETL load can take 5β10 minutes on first run due to the dataset size.
Override the connection by setting any of DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME, or DB_URL. For a host-side run against the compose Postgres, set DB_HOST=localhost.
python run_api.py
# or, directly:
uvicorn src.api.app:app --host 0.0.0.0 --port 8000Set UVICORN_RELOAD=1 before python run_api.py to enable autoreload during development. Use run_api_prod.py for the production entrypoint.
cd frontend
npm install
npm run dev # http://localhost:3005docker compose up --buildThe frontend ships an Electron shell that wraps the Next.js standalone output and bundles the backend executable as extra resources.
cd frontend
npm run build
npm run electron:build # β frontend/dist/*.exe (NSIS installer)The installer is non-one-click, lets the user pick the install path, and creates Desktop + Start Menu shortcuts (configured in package.json β build.nsis).
stockflow/
βββ docker-compose.yaml # frontend + backend + postgres
βββ run_main.py # ETL entrypoint
βββ run_api.py / run_api_prod.py # FastAPI entrypoints
βββ pyproject.toml poetry.lock uv.lock
β
βββ backend/
β βββ Dockerfile
β βββ requirements.txt
β βββ api.spec # PyInstaller bundle spec
β βββ PREDICTION_API.md # forecasting API notes
β βββ src/
β βββ api/
β β βββ app.py # FastAPI app
β β βββ routes/
β β βββ schemas.py
β β βββ tables.py
β β βββ db.py
β βββ config.py
β βββ database.py
β βββ etl_pipeline.py / etl_pipeline2.py
β βββ models.py
β βββ prediction.py
β βββ prediction_db.py
β
βββ frontend/
βββ Dockerfile
βββ package.json # Next 15 + Electron 38 + shadcn/ui
βββ next.config.mjs
βββ electron/ # Electron main process
βββ app/ # Next App Router (dashboard, layout, β¦)
βββ components/ components.json
βββ lib/ styles/ public/
βββ NOTIFICATION_SYSTEM.md
| Symptom | Fix |
|---|---|
| Backend can't reach Postgres | Make sure docker compose up -d postgres is running and set DB_HOST=localhost. |
| ETL takes a long time | Expected β first import processes a large dataset (5β10 min). |
| Frontend port conflict | The dev script binds 3005; change it in frontend/package.json β scripts.dev. |
| Electron build fails on non-Windows host | The electron:build target uses --win --x64; build it from a Windows host or in CI. |