Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Warehouse Neuron 🧠

A neural upgrade for traditional warehouse management systems

Modern inventory tracking with barcode scanning, real-time updates, and intelligent workflows.

Phase Backend Frontend Web Dashboard

🎯 Project Vision

Transform inventory management from a chore into an intelligent, responsive system:

  • πŸ“± Mobile-First: Scan barcodes anywhere in the warehouse
  • ⚑ Real-Time: Instant stock updates via Redis streams
  • πŸ” Complete Audit Trail: Every movement tracked and traceable
  • 🌐 Multi-Platform: Web, mobile, and desktop from one codebase
  • πŸš€ Cloud-Ready: Designed for scale and reliability

Current Status: Phase A - Backend + Web Dashboard Complete!


🌐 Access Points


πŸ“‹ Phase A Progress

βœ… Completed

  • Nix flake development environment with automatic venv
  • Docker Compose multi-service setup (Postgres, Redis, FastAPI)
  • SQLAlchemy schema with 5 core tables
  • FastAPI backend with stock intake endpoint
  • Redis event streaming for real-time updates
  • Database connection pooling
  • Code formatting (Black + isort)
  • API documentation (Swagger UI)
  • Comprehensive testing guides
  • Flutter web dashboard with stock intake interface
  • CORS middleware for web access

🚧 In Progress

  • Database migrations (Alembic)
  • Flutter mobile app (Android + iOS)
  • Tauri desktop wrapper
  • Authentication system
  • Unit and integration tests
  • Real-time statistics dashboard

πŸ“š Documentation


πŸš€ Quick Start

Prerequisites

  • Nix with flakes enabled
  • direnv (optional but recommended)
  • Docker or Podman

1. Setup Environment

# Clone the repository
git clone <repository-url>
cd warehouse-neuron

# Allow direnv (automatic environment)
direnv allow

# Or manually activate Nix environment
nix develop

The Nix environment provides:

  • Python 3.13.8 with venv
  • Black & isort formatters
  • All backend dependencies

2. Start Services

# Start all services (Postgres, Redis, Backend)
docker compose up -d

# View logs
docker compose logs -f backend

3. Initialize Database

# Run initial migration
docker exec -i warehouse-neuron_postgres_1 psql -U wn_user -d warehouse_neuron < services/migrations/0001_init.sql

# Verify tables created
docker exec -it warehouse-neuron_postgres_1 psql -U wn_user -d warehouse_neuron -c '\dt'

4. Test API

Open http://localhost:8000/docs in your browser to access the interactive API documentation.

Quick test:

curl http://localhost:8000/health
# Expected: {"status":"healthy"}

πŸ—οΈ Architecture

Tech Stack

Backend:

  • FastAPI 0.121.0 - Modern async web framework
  • PostgreSQL 15 - Primary data store
  • Redis 7 - Event streaming and caching
  • SQLAlchemy 2.0 - Async ORM
  • Pydantic 2.12 - Data validation

Frontend (Coming):

  • Flutter - Cross-platform UI (mobile + web)
  • Tauri - Desktop wrapper (Windows, macOS, Linux)

DevOps:

  • Nix Flakes - Reproducible environments
  • Docker Compose - Local development
  • GitHub Actions - CI/CD (future)

Database Schema

locations          β†’ Warehouse zones/bins
skus               β†’ Product catalog
sku_barcodes       β†’ Barcode mappings (many-to-one)
stock_ledger       β†’ Current inventory levels
stock_movements    β†’ Complete transaction history

See DATABASE_SETUP.md for detailed schema documentation.


πŸ“ Project Structure

warehouse-neuron/
β”œβ”€β”€ flake.nix                   # Nix development environment
β”œβ”€β”€ .envrc                      # direnv auto-activation
β”œβ”€β”€ docker-compose.yml          # Multi-service orchestration
β”œβ”€β”€ README.md                   # This file
β”œβ”€β”€ APP.md                      # Project vision & roadmap
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ API_GUIDE.md           # Complete API documentation
β”‚   └── DATABASE_SETUP.md      # Database guide
β”œβ”€β”€ apps/                       # Frontend applications (future)
└── services/
    β”œβ”€β”€ backend/                # FastAPI backend
    β”‚   β”œβ”€β”€ Dockerfile
    β”‚   β”œβ”€β”€ requirements.txt
    β”‚   └── app/
    β”‚       β”œβ”€β”€ main.py         # Application entry point
    β”‚       β”œβ”€β”€ config.py       # Settings management
    β”‚       β”œβ”€β”€ database.py     # DB connection pool
    β”‚       β”œβ”€β”€ models.py       # SQLAlchemy models
    β”‚       β”œβ”€β”€ schema.py       # Pydantic schemas
    β”‚       β”œβ”€β”€ crud.py         # Database operations
    β”‚       └── routes/
    β”‚           └── stock.py    # Stock management API
    └── migrations/
        └── 0001_init.sql       # Initial schema

πŸ”§ Development Workflow

Code Formatting

# Format all Python files
black .
isort .

# Check without changes
black --check .
isort --check-only .

Docker Operations

# Start services
docker compose up -d

# Rebuild after code changes
docker compose up -d --build --no-cache

# View logs
docker compose logs -f backend

# Stop services
docker compose down

# Reset everything
docker compose down -v  # Removes volumes too

Database Access

# Connect via psql
psql -h localhost -p 5434 -U wn_user -d warehouse_neuron

# Or via Docker
docker exec -it warehouse-neuron_postgres_1 psql -U wn_user -d warehouse_neuron

# Run query
docker exec -it warehouse-neuron_postgres_1 psql -U wn_user -d warehouse_neuron -c 'SELECT * FROM skus;'

🌐 Service Endpoints

Backend API

Database (PostgreSQL)

  • Host: localhost
  • Port: 5434 (external), 5432 (internal)
  • Database: warehouse_neuron
  • User: wn_user
  • Password: wn_pass

Redis

  • Host: localhost
  • Port: 6379

πŸ“š API Reference

Key Endpoints

Health Check

GET /health

Stock Intake (Main Feature)

POST /api/v1/stock/intake
Content-Type: application/json

{
  "barcode": "123456789012",
  "qty": 10,
  "location_code": "WH-A-01",
  "movement_type": "IN",
  "auto_create_sku": true,
  "created_by": "user@example.com"
}

Interactive Documentation


πŸ§ͺ Testing

API Testing with Postman

See API_GUIDE.md for:

  • Postman collection setup
  • Example requests
  • Complete testing scenarios

Database Testing with DBeaver

See DATABASE_SETUP.md for:

  • Connection setup
  • Sample queries
  • Performance monitoring

Manual Testing

# Test health endpoint
curl http://localhost:8000/health

# Test stock intake
curl -X POST http://localhost:8000/api/v1/stock/intake \
  -H "Content-Type: application/json" \
  -d '{"barcode":"TEST-001","qty":10,"auto_create_sku":true}'

πŸ“¦ Environment Variables

Backend service configuration (set in docker-compose.yml):

DATABASE_URL=postgresql+asyncpg://wn_user:wn_pass@postgres:5432/warehouse_neuron
REDIS_URL=redis://redis:6379
APP_ENV=development

πŸ› οΈ Troubleshooting

Services won't start

# Check container status
docker ps -a

# View logs
docker compose logs backend
docker compose logs postgres

# Restart services
docker compose restart

Port conflicts

# Check what's using port 5434
netstat -tuln | grep 5434

# Or use different port in docker-compose.yml

Database connection failed

# Test from host
psql -h localhost -p 5434 -U wn_user -d warehouse_neuron

# Test from container
docker exec warehouse-neuron_postgres_1 pg_isready -U wn_user

See troubleshooting sections in:


πŸ—ΊοΈ Roadmap

Phase A - Foundations (Current)

Backend scaffold, schema, basic scanning

Phase B - Reliability

Error handling, offline queue, retry logic

Phase C - Intelligence

AI-powered predictions, anomaly detection

Phase D - Optimization

Multi-warehouse, advanced analytics

Phase E - Polish

UI/UX refinement, performance tuning

See APP.md for complete roadmap details.


🀝 Contributing

  1. Follow existing code style (Black + isort)
  2. Run formatters before committing
  3. Test changes locally with Docker Compose
  4. Update documentation for new features
  5. Write tests for new functionality

πŸ“„ License

[License TBD]


πŸ“ž Support


Built with ❀️ for modern warehouse operations

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages