A full-stack inventory management system โ with a live demo that needs no backend.
Overview โข Live Demo โข Quick Start โข Architecture โข Commands โข Packages
SimpleStock is a production-ready inventory management system built as a monorepo with two independent packages. Track stock levels, record product sales, manage suppliers, and analyze sales trends โ all through a responsive dashboard. No backend required to evaluate: the demo mode runs entirely in the browser using localStorage.
| Package | Description | Stack |
|---|---|---|
| web | React SPA frontend | React 19, Vite 7, Tailwind CSS, Chart.js |
| server | Express REST API backend | Express 4, MongoDB, Mongoose 9, Winston |
- ๐ฆ Product Management โ Full CRUD with real-time stock tracking and low-stock alerts
- ๐ฐ Sales Transactions โ Record sales with automatic inventory decrement
- ๐ฅ Supplier Directory โ Manage vendor contacts and filter products by supplier
- ๐ Analytics Dashboard โ Sales charts, daily breakdowns, and summary statistics
- ๐ Authentication โ Session-based auth with better-auth and role-based access control
- ๐ฎ Demo Mode โ Fully functional without a backend, data persisted in localStorage
No setup required. Visit the demo and explore every feature with pre-seeded data:
| Field | Value |
|---|---|
demo@simplestock.com |
|
| Password | demo123456 |
All data in the live demo is stored in your browser โ nothing is sent to a server. Data persists across sessions.
- โ Add, edit, delete, and sell products
- โ Manage the supplier directory
- โ Browse transaction history with period filters
- โ View the dashboard with charts and analytics
- โ Experience the responsive mobile layout
Visit https://simplestock-demo.onrender.com and log in with the demo credentials above.
# Navigate to the project root
cd SimpleStock
# Install dependencies for all packages
make install
# Copy the server environment template and add your MongoDB credentials
cp packages/server/.env.example packages/server/.env
# Seed an initial admin user (optional)
make seed-admin
# Start both the web frontend and API server concurrently
make dev| Service | URL |
|---|---|
| ๐ Web UI | http://localhost:5173 |
| ๐ API Server | http://localhost:3000 |
| โค๏ธ Health Check | http://localhost:3000/health |
cd SimpleStock/packages/web
npm install
npm run dev:demoDemo credentials: demo@simplestock.com / demo123456
# Terminal 1 โ API server
cd SimpleStock/packages/server
npm install
cp .env.example .env
# Configure .env with your MongoDB credentials
npm run dev
# Terminal 2 โ web frontend
cd SimpleStock/packages/web
npm install
npm run devโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CLIENTS โ
โ (Browser / Mobile / API Consumer) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ WEB PACKAGE โ
โ (React 19 + Vite 7) โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ Pages โ โ Components โ โ Hooks โ โ Services โ โ
โ โ Dashboard โ โ UI โ โ useProducts โ โ API/Local โ โ
โ โ Products โ โ Layout โ โ useSupplier โ โ Client โ โ
โ โ Reports โ โ Common โ โ useTrans... โ โ โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโฌโโโโโโโ โ
โ โ โ
โ Vite Dev Proxy: /api/* โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SERVER PACKAGE โ
โ (Express 4 + MongoDB) โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ Routes โ โ Controllers โ โ Services โ โ Repos โ โ
โ โ /products โโโโ Product โโโโ Product โโโโ Product โ โ
โ โ /suppliers โ โ Supplier โ โ Supplier โ โ Supplier โ โ
โ โ /transact โ โ Transaction โ โ Transaction โ โ Transaction โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโฌโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ DATABASE LAYER โ โ
โ โ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ MongoClient โ โ Mongoose โ โ โ
โ โ โ (better-auth) โ โ (ODM Operations) โ โ โ
โ โ โ โ โ โ โ โ
โ โ โ โข user โ โ โข Product Model โ โ โ
โ โ โ โข session โ โ โข Supplier Model โ โ โ
โ โ โ โข verification โ โ โข Transaction Model โ โ โ
โ โ โโโโโโโโโโฌโโโโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโโโโโ โ โ
โ โ โ โ โ โ
โ โ โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โผ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ MongoDB โ โ โ
โ โ โ (Atlas/Local) โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Category | Base Path | Description |
|---|---|---|
| Auth | /api/v1/admin/auth/* |
Authentication (better-auth) |
| Products | /api/v1/admin/products |
Product CRUD + sell |
| Suppliers | /api/v1/admin/suppliers |
Supplier CRUD |
| Transactions | /api/v1/admin/transactions |
Transaction queries |
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ React Hook โโโโโโบโ Service โโโโโโบโ API Client โ
โ useProducts โ โproductServiceโ โ fetch/axios โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโฌโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTP Request
โผ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ Route โโโโโโบโ Controller โโโโโโบโ Service โ
โ Handler โ โ parseRequest โ โ businessLogicโ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ MongoDB โโโโโโโ Repository โ
โ Database โ โ dataAccess โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโ
โ Login โโโโโบโ AuthContext โโโโโบโ AuthClient โโโโโโบโ better- โ
โ Page โ โ Provider โ โ (API/Local) โ โ auth โ
โโโโโโโโโโโ โโโโโโโโฌโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโฌโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ Route โ โ MongoDB โ
โ Guards โ โ Sessions โ
โ Protected/ โ โ โ
โ Public โ โโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโ
All commands run from the SimpleStock/ project root.
| Command | Description |
|---|---|
make install |
Install dependencies for all packages |
make install-web |
Install web package dependencies only |
make install-server |
Install server package dependencies only |
| Command | Description |
|---|---|
make dev |
Start both web and server concurrently |
make dev-web |
Start web frontend only (port 5173) |
make dev-server |
Start server backend only (port 3000) |
make dev-demo |
Start web in demo mode (localStorage) |
| Command | Description |
|---|---|
make build |
Build both packages for production |
make build-web |
Build web package |
make build-server |
Build server package |
make build-demo |
Build web in demo mode |
make start |
Start server in production mode |
make preview |
Preview web production build |
make preview-demo |
Preview demo production build |
| Command | Description |
|---|---|
make lint |
Run ESLint on all packages |
make lint-web |
Lint web package |
make lint-server |
Lint server package |
make format |
Format server code with Prettier |
| Command | Description |
|---|---|
make test |
Run web tests once |
make test-watch |
Run web tests in watch mode |
make test-coverage |
Run web tests with coverage report |
| Command | Description |
|---|---|
make seed-admin |
Create initial admin user |
make clean |
Remove all build artifacts and node_modules |
make clean-web |
Clean web package only |
make clean-server |
Clean server package only |
make check |
Verify required tools are installed |
make status |
Show project installation status |
# Full development setup
make install && make dev
# Demo mode โ no backend needed
make install-web && make dev-demo
# Production build
make build && make start
# Run tests with coverage
make test-coverageReact SPA with a comprehensive UI component library, dual data source support, and interactive charts.
Stack: React 19.2 ยท TypeScript 5.9 ยท Vite 7.2 ยท Tailwind CSS 3.4 ยท Chart.js ยท React Router 7 ยท Zod ยท Vitest
- ๐จ Custom UI component library (Button, Card, Dialog, Table, Pagination, and more)
- ๐ Interactive dashboard with weekly and monthly sales charts
- ๐ Automatic API/localStorage switching via
VITE_DATA_SOURCE - ๐ฑ Responsive mobile-first design
- โ Component tests with Vitest + Testing Library
RESTful API backend with layered architecture, dual MongoDB connection strategy, and session-based authentication.
Stack: Express 4.21 ยท TypeScript 5.9 ยท MongoDB 7.0 ยท Mongoose 9.0 ยท better-auth ยท Winston ยท Zod
- ๐ Session-based authentication with admin role support via better-auth
- ๐๏ธ Dual MongoDB connection (MongoClient for auth, Mongoose for business data)
- โ Zod validation with typed domain error propagation
- ๐ Winston structured logging with environment-specific formatters
- โก Graceful shutdown with connection pool cleanup
| File | Package | Purpose |
|---|---|---|
packages/server/.env |
Server | Database, auth, logging config |
packages/web/.env.development |
Web | Development settings (VITE_DATA_SOURCE=api) |
packages/web/.env.production |
Web | Production settings |
packages/web/.env.demo |
Web | Demo mode settings (VITE_DATA_SOURCE=local) |
# packages/server/.env
NODE_ENV=development
PORT=3000
# Database
MONGODB_URI=mongodb+srv://user:<PASSWORD>@cluster.mongodb.net
MONGO_PASSWORD=your-password
DATABASE_NAME=simplestock
# Authentication
BASE_URL=http://localhost:3000
AUTH_SECRET_USER=your-32-char-secret-key
TRUSTED_ORIGINS=http://localhost:3000,http://localhost:5173
# Logging
LOG_LEVEL=info# API mode โ connects to backend at localhost:3000
VITE_DATA_SOURCE=api
# Demo mode โ uses localStorage, no backend required
VITE_DATA_SOURCE=localThe Vite dev server forwards all /api requests to the backend automatically:
// vite.config.ts
server: {
proxy: {
'/api': {
target: 'http://localhost:3000',
changeOrigin: true,
},
},
}| Category | Technology | Version |
|---|---|---|
| Framework | React | 19.2 |
| Language | TypeScript | ~5.9.3 |
| Build Tool | Vite | 7.2 |
| Styling | Tailwind CSS | 3.4 |
| Routing | React Router | 7.10 |
| Charts | Chart.js | 4.5 |
| Auth Client | better-auth | 1.4 |
| Validation | Zod | 4.1 |
| Icons | Lucide React | 0.555 |
| Testing | Vitest | 4.0 |
| Category | Technology | Version |
|---|---|---|
| Framework | Express | 4.21 |
| Language | TypeScript | ~5.9.3 |
| Database | MongoDB | 7.0 |
| ODM | Mongoose | 9.0 |
| Auth | better-auth | 1.4 |
| Validation | Zod | 4.3 |
| Logging | Winston | 3.19 |
| Dev Runner | tsx | 4.21 |
- Session-based with HTTP-only cookies and role-based access (user/admin)
- Rate limiting on auth endpoints โ 3 sign-in attempts per 10 seconds, 5 sign-ups per minute
- Configurable session expiry with daily refresh
- All inputs validated with Zod schemas on both client and server
- Parameterized database queries via Mongoose โ no raw query construction
- Environment variables for all secrets โ no hardcoded credentials
- Password hashing via bcrypt
- CORS restricted to configured trusted origins
- HTTP request logging for audit trails
- Generic error messages to clients โ no internal stack trace exposure
- Authentication middleware on all protected routes with
userId-scoped queries
make test # Run all tests once
make test-watch # Watch mode during development
make test-coverage # Generate coverage report# Health check
curl http://localhost:3000/health
# Login and save session cookie
curl -X POST http://localhost:3000/api/v1/admin/auth/sign-in/email \
-H "Content-Type: application/json" \
-d '{"email":"admin@example.com","password":"password"}' \
-c cookies.txt
# Get products (authenticated)
curl http://localhost:3000/api/v1/admin/products -b cookies.txt| Issue | Solution |
|---|---|
| MongoDB connection failed | Check MONGODB_URI and MONGO_PASSWORD in .env; verify Atlas IP allowlist |
| Port 3000 already in use | Kill existing process or change PORT in .env |
| Auth not working | Verify AUTH_SECRET_USER is 32+ characters |
| CORS errors | Add frontend URL to TRUSTED_ORIGINS in server .env |
| Demo mode not loading | Ensure VITE_DATA_SOURCE=local in packages/web/.env.demo |
make status # Show installation status for all packages
make check # Verify required tools are installed
make clean && make install # Reset and reinstall everythingSimpleStock/
โโโ Makefile # Orchestration commands for all packages
โโโ README.md # This file
โโโ packages/
โโโ server/ # Backend API
โ โโโ src/
โ โ โโโ config/ # Environment configuration
โ โ โโโ controllers/ # HTTP request handlers
โ โ โโโ dtos/ # Data transfer objects & mappers
โ โ โโโ lib/ # Core libraries (auth, db, logger)
โ โ โโโ middleware/ # Express middleware
โ โ โโโ models/ # Mongoose schemas
โ โ โโโ repos/ # Data access layer
โ โ โโโ routes/ # API route definitions
โ โ โโโ services/ # Business logic
โ โ โโโ shared/ # Shared utilities (domain errors)
โ โ โโโ types/ # TypeScript declarations
โ โ โโโ validators/ # Zod schemas
โ โ โโโ app.ts # Express app factory
โ โ โโโ server.ts # Entry point
โ โโโ scripts/ # Utility scripts (seed-admin)
โ โโโ .env.example # Environment template
โ โโโ package.json
โ โโโ tsconfig.json
โ โโโ README.md
โโโ web/ # Frontend SPA
โโโ public/ # Static assets
โโโ src/
โ โโโ assets/ # App assets (logo)
โ โโโ components/
โ โ โโโ common/ # Brand, PageHead
โ โ โโโ layout/ # DashboardLayout, Navbar, Sidebar
โ โ โโโ ui/ # UI component library
โ โโโ constants/ # App constants and route definitions
โ โโโ contexts/ # UserAuthContext
โ โโโ guards/ # PublicRoute, UserProtectedRoute
โ โโโ hooks/ # Custom data hooks
โ โโโ lib/
โ โ โโโ local-storage/ # Demo mode storage layer
โ โโโ pages/ # Page components
โ โโโ routes/ # Router configuration
โ โโโ services/ # API service layer
โ โโโ styles/ # Global CSS and theme variables
โ โโโ utils/ # Utility functions
โ โโโ validators/ # Zod schemas
โ โโโ App.tsx # Root component with providers
โ โโโ main.tsx # Entry point
โโโ .env.development
โโโ .env.demo
โโโ .env.production
โโโ package.json
โโโ vite.config.ts
โโโ vitest.config.ts
โโโ README.md
This project is private and proprietary. All rights reserved.
Built with โค๏ธ using React, Express, TypeScript, and MongoDB
๐ฎ Try the Live Demo
Web Package โข Server Package โข Back to Top