A comprehensive, full-stack inventory management solution designed for textile and apparel businesses. This system provides robust product management, stock tracking, sales monitoring, order processing, and comprehensive audit logging with role-based access control.
- Backend: FastAPI + PostgreSQL + SQLAlchemy (Async)
- Frontend: React 18 + TypeScript + Ant Design + Vite
- Database: PostgreSQL 15 with Alembic migrations
- Authentication: JWT with role-based access control
- Deployment: Docker Compose with multi-stage builds
- Testing: Jest + React Testing Library (Frontend) + Pytest (Backend)
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Frontend β β Backend β β Database β
β (React) βββββΊβ (FastAPI) βββββΊβ (PostgreSQL) β
β β β β β β
β β’ Product Mgmt β β β’ REST APIs β β β’ Products β
β β’ Stock Matrix β β β’ Auth System β β β’ Stock Logs β
β β’ Upload Tools β β β’ Audit Logging β β β’ Sales Logs β
β β’ User Mgmt β β β’ File Export β β β’ Orders β
β β’ Analytics β β β’ Scheduler β β β’ Users β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- Multi-variant Products: Support for size/color combinations with color-code mapping
- SKU Management: Unique product identifiers with validation
- Price Tracking: Unit price management with GST calculations
- Store/Agency Restrictions: Configure allowed stores and agencies per product
- Bulk Operations: Create, update, and delete multiple products efficiently
- Real-time Stock Matrix: Visual grid showing stock levels by color and size
- Inward Logs: Track incoming inventory with supplier details
- Sales Logs: Monitor outgoing inventory with store/agency information
- Atomic Updates: Database transactions ensure data consistency
- Stock Alerts: Low stock notifications and warnings
- Order Management: Complete order lifecycle from creation to fulfillment
- Excel Export: Generate professional order sheets with company branding
- Bulk Order Operations: Create and manage multiple orders simultaneously
- Order Tracking: Monitor order status and fulfillment progress
- Customer Database: Store customer information with GST details
- Agency Management: Track agencies with regional coverage
- Payment Terms: Configure payment days and terms
- Contact Management: Multiple contact numbers and addresses
- Excel Integration: Paste tab-delimited data directly from Excel
- Bulk Data Import: Import large datasets with validation
- Data Validation: Real-time validation of color/size combinations
- Overwrite Protection: Safe replacement of existing data with confirmation
- Error Handling: Comprehensive error reporting and recovery
- Role-Based Access Control: Admin, Manager, and Viewer roles
- JWT Authentication: Secure token-based authentication
- Audit Logging: Complete audit trail of all system changes
- User Management: Create, edit, and manage user accounts
- Session Management: Automatic token refresh and logout
- Dashboard Statistics: Real-time product and value metrics
- Stock Analytics: Comprehensive stock level reporting
- Sales Analytics: Sales performance and trend analysis
- Export Capabilities: Excel and CSV export functionality
- Region Mapping: Interactive maps showing agency coverage areas
- Location Tracking: Store and agency location management
- Territory Management: Regional assignment and monitoring
- Docker & Docker Compose (for containerized deployment)
- Node.js 18+ (for local frontend development)
- Python 3.9+ (for local backend development)
- PostgreSQL 15 (for local database development)
# Clone the repository
git clone <repository-url>
cd Abhishek
# Start all services
docker-compose up --build -d
# Check service status
docker-compose ps
# View logs
docker-compose logs -f# Start development environment with hot reload
docker-compose -f docker-compose.dev.yml up --build -d
# Access services
# Frontend: http://localhost:3000
# Backend: http://localhost:8000
# Database: localhost:5432cd backend
# Install dependencies
pip install -r requirements.txt
# Set environment variables
export DATABASE_URL="postgresql+asyncpg://postgres:password@localhost:5432/inventory_db"
export SECRET_KEY="your-secret-key-here"
# Run database migrations
alembic upgrade head
# Initialize admin user
python init_admin.py
# Start development server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000cd frontend
# Install dependencies
npm install
# Start development server
npm run dev
# Run tests
npm test
# Build for production
npm run build# Create PostgreSQL database
createdb inventory_db
# Run migrations
cd backend
alembic upgrade head- Email: admin@example.com
- Password: admin123
- Role: Admin (full system access)
- β Full system access
- β User management
- β Product management
- β Stock operations
- β Audit logs access
- β System configuration
- β Product management
- β Stock operations
- β Sales and inward logs
- β Order management
- β User management
- β Audit logs access
- β View products and stock
- β Read-only access to logs
- β No modification permissions
- β No administrative access
{
"id": 1,
"name": "Premium Cotton T-Shirt",
"sku": "TS001",
"description": "High-quality cotton t-shirt",
"unit_price": 599.99,
"sizes": ["S", "M", "L", "XL", "XXL"],
"colors": [
{"color": "Red", "colour_code": 101},
{"color": "Blue", "colour_code": 102}
],
"allowed_stores": ["Store A", "Store B"],
"allowed_agencies": ["Agency X", "Agency Y"]
}βββββββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββββββ
β Color β S β M β L β XL β XXL β Total β
βββββββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββββββ€
β Red β 10 β 15 β 20 β 12 β 8 β 65 β
β Blue β 8 β 12 β 18 β 10 β 6 β 54 β
βββββββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββββββ
Date Color Colour Code S M L Category Stakeholder
2024-01-15 Red 101 10 15 20 Supply Store A
2024-01-15 Blue 102 8 12 18 Supply Store B
Date Color Colour Code S M L Agency Store
2024-01-16 Red 101 2 3 5 Agency X Store Y
2024-01-16 Blue 102 1 2 3 Agency Y Store Z
POST /api/v1/auth/login- User loginPOST /api/v1/auth/signup- User registration (admin only)GET /api/v1/auth/me- Get current user info
GET /api/v1/products- List all productsPOST /api/v1/products- Create new productGET /api/v1/products/{id}- Get product detailsPUT /api/v1/products/{id}- Update productDELETE /api/v1/products/{id}- Delete product
GET /api/v1/stock/{product_id}- Get stock matrixGET /api/v1/stock/{product_id}/details- Get detailed stock info
GET /api/v1/inward/{product_id}- Get inward logsPOST /api/v1/inward/- Create inward logPOST /api/v1/inward/bulk-create- Bulk create inward logsDELETE /api/v1/inward/bulk-delete- Bulk delete inward logs
GET /api/v1/sales/{product_id}- Get sales logsPOST /api/v1/sales/- Create sales logPOST /api/v1/sales/bulk-create- Bulk create sales logsDELETE /api/v1/sales/bulk-delete- Bulk delete sales logs
GET /api/v1/orders/- List all ordersPOST /api/v1/products/{product_id}/orders- Create orderPOST /api/v1/orders/export-excel- Export orders to ExcelPUT /api/v1/orders/{order_id}- Update orderDELETE /api/v1/orders/{order_id}- Delete order
GET /api/v1/users/- List users (admin only)POST /api/v1/users/- Create user (admin only)PUT /api/v1/users/{id}- Update user (admin only)DELETE /api/v1/users/{id}- Delete user (admin only)
GET /api/v1/audit-logs/- Get audit logs (admin only)
GET /api/v1/customers/- List customersPOST /api/v1/customers/- Create customerGET /api/v1/agencies/- List agenciesPOST /api/v1/agencies/- Create agency
- Navigate to Products page
- Click "Add Product" button
- Fill in product details (name, SKU, price)
- Add sizes (S, M, L, XL, etc.)
- Add colors with color codes
- Configure allowed stores and agencies
- Save product
- Select product from Product View
- View current stock matrix
- Add inward logs for new inventory
- Record sales logs for outgoing inventory
- Monitor stock levels and alerts
- Navigate to Upload page
- Select product and log type (Inward/Sales/Orders)
- Use "Bulk Paste from Excel" feature
- Paste tab-delimited data from Excel
- Validate data format and color/size combinations
- Preview data before import
- Confirm overwrite if replacing existing data
- Create new order for specific product
- Specify color, size quantities, and destination
- Generate order number and track status
- Export order to Excel with company branding
- Monitor order fulfillment progress
- Admin logs into system
- Navigate to User Management
- Create new users with appropriate roles
- Assign permissions and access levels
- Monitor user activity through audit logs
cd backend
# Run all tests
pytest
# Run specific test file
pytest tests/test_products.py
# Run with coverage
pytest --cov=app tests/
# Run with verbose output
pytest -vcd frontend
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watch
# Run full test suite
npm run test:full- Backend: Unit tests for all API endpoints, models, and services
- Frontend: Component tests, hook tests, and integration tests
- Coverage: Minimum 80% code coverage requirement
- E2E: Playwright tests for critical user workflows
- Async Database Operations: Non-blocking database queries
- Connection Pooling: Efficient database connection management
- Caching: Redis integration for frequently accessed data
- Pagination: Large dataset handling with pagination
- Indexing: Optimized database indexes for fast queries
- Code Splitting: Lazy loading of components
- Memoization: React.memo and useMemo for performance
- Virtual Scrolling: AG-Grid for large data tables
- Bundle Optimization: Tree shaking and minification
- CDN Integration: Static asset optimization
- Proper Indexing: Strategic database indexes
- Query Optimization: Efficient SQL queries
- Connection Pooling: Managed database connections
- Backup Strategy: Automated database backups
- Monitoring: Database performance monitoring
- JWT Tokens: Secure token-based authentication
- Password Hashing: bcrypt password encryption
- Role-Based Access: Granular permission system
- Session Management: Secure session handling
- Token Expiration: Automatic token refresh
- Input Validation: Comprehensive input sanitization
- SQL Injection Prevention: Parameterized queries
- XSS Protection: Cross-site scripting prevention
- CSRF Protection: Cross-site request forgery protection
- Rate Limiting: API rate limiting and throttling
- Audit Logging: Complete system activity tracking
- Data Encryption: Sensitive data encryption
- Access Logs: User access and action logging
- Compliance: GDPR and data protection compliance
- Backup Security: Encrypted backup storage
# Build and deploy with Docker
docker-compose -f docker-compose.prod.yml up --build -d
# Set production environment variables
export NODE_ENV=production
export DATABASE_URL=postgresql://user:pass@host:port/db
export SECRET_KEY=your-production-secret-key
# Run database migrations
docker-compose exec backend alembic upgrade head
# Initialize admin user
docker-compose exec backend python init_admin.py# Database
DATABASE_URL=postgresql+asyncpg://user:password@host:port/database
# Security
SECRET_KEY=your-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
# Application
DEBUG=false
LOG_LEVEL=INFO
CORS_ORIGINS=http://localhost:3000,https://yourdomain.com
# External Services
REDIS_URL=redis://localhost:6379- Application Logs: Structured logging with log levels
- Error Tracking: Comprehensive error monitoring
- Performance Monitoring: Application performance metrics
- Health Checks: System health monitoring endpoints
- Alerting: Automated alert system for critical issues
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
- Python: Follow PEP 8 style guide
- TypeScript: Use strict TypeScript configuration
- React: Follow React best practices
- Testing: Maintain 80%+ test coverage
- Documentation: Update documentation for changes
- Use conventional commit messages
- Include descriptive commit messages
- Reference issue numbers when applicable
- Keep commits focused and atomic
- Authentication Guide - Complete authentication system documentation
- API Documentation - Interactive API documentation
- Test Reports - Comprehensive test coverage reports
- Migration Logs - Database migration history
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- OpenAPI Schema: http://localhost:8000/openapi.json
# Check database status
docker-compose ps postgres
# View database logs
docker-compose logs postgres
# Reset database
docker-compose down -v
docker-compose up -d# Clear node modules and reinstall
rm -rf node_modules package-lock.json
npm install
# Clear build cache
npm run build -- --force# Check backend logs
docker-compose logs backend
# Run migrations manually
docker-compose exec backend alembic upgrade head
# Initialize database
docker-compose exec backend python init_db.py- Check database query performance
- Monitor memory usage
- Review application logs
- Optimize database indexes
- Implement caching strategies
- Review audit logs for suspicious activity
- Check user permissions and roles
- Validate input data and sanitization
- Monitor API rate limiting
- Review security headers and CORS settings
- Documentation: Check the comprehensive documentation
- Issues: Report bugs and feature requests via GitHub issues
- Discussions: Use GitHub discussions for questions
- Email: Contact support team for urgent issues
- Minimum: 4GB RAM, 2 CPU cores, 20GB storage
- Recommended: 8GB RAM, 4 CPU cores, 50GB storage
- Production: 16GB RAM, 8 CPU cores, 100GB storage
- Chrome: 90+
- Firefox: 88+
- Safari: 14+
- Edge: 90+
This project is licensed under the MIT License - see the LICENSE file for details.
- FastAPI for the excellent web framework
- React and Ant Design for the frontend components
- PostgreSQL for the robust database system
- Docker for containerization and deployment
- AG-Grid for the powerful data grid component
Backstitch Inventory Management System - Empowering textile businesses with comprehensive inventory control and management solutions.