A complete, production-ready food inventory management system with automatic raw material deduction, authentication, and admin features.
Frontend: https://food-inventory-frontend-j9yy4cbh2.vercel.app/
- User Management: Admin, manager, and staff roles
- Secure Login: JWT-based authentication with refresh tokens
- Protected Routes: Role-based access control
- Admin Dashboard: User management and system overview
- Raw Materials: Track ingredients with units, quantities, and minimum thresholds
- Low Stock Alerts: Visual indicators for items below minimum threshold
- Smart Deletion: Prevents deletion of materials used in recipes with detailed warnings
- Edit Capabilities: Update stock levels and material details
- Food Items: Create menu items with prices and availability
- Recipe Builder: Define ingredient requirements for each food item
- Availability Tracking: Automatic availability based on ingredient stock
- Edit Recipes: Modify existing food items and their recipes
- Smart Ordering: Real-time inventory checking before order placement
- Atomic Transactions: Guaranteed inventory deduction with rollback protection
- Order Tracking: Complete order lifecycle management (Placed → Completed/Cancelled)
- Order Details: View detailed information for each order
- Modern UI: Clean, responsive design with Tailwind CSS
- Dark/Light Theme: Automatic theme switching with system preference
- Real-time Updates: Live inventory status and availability checking
- Mobile Responsive: Works perfectly on all device sizes
- Type Safety: Full TypeScript implementation
- API Documentation: Auto-generated OpenAPI/Swagger docs
- Error Handling: Comprehensive error handling with user-friendly messages
- Production Ready: Configured for Vercel and Render deployment
- Database Support: SQLite for local, PostgreSQL for production
- Node.js 18+ and npm
- Python 3.11+
- Git
-
Clone the repository
git clone https://github.com/sh1vam31/Food_Inventory_Frontend.git cd Food_Inventory_Frontend -
Setup Backend
# Using the provided script (recommended) ./run_backend_local.sh # Or manually: cd backend python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
-
Setup Frontend
cd frontend npm install npm run dev -
Access the Application
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
food-inventory-system/
├── frontend/ # Next.js Frontend
│ ├── app/ # App Router pages
│ │ ├── admin/ # Admin dashboard
│ │ ├── dashboard/ # Main dashboard
│ │ ├── inventory/ # Raw materials management
│ │ │ └── edit/ # Edit inventory items
│ │ ├── menu/ # Food items management
│ │ │ └── edit/ # Edit menu items
│ │ ├── orders/ # Order management
│ │ │ └── [id]/ # Order details
│ │ ├── login/ # Authentication
│ │ └── home/ # Landing page
│ ├── components/ # Reusable UI components
│ ├── contexts/ # React contexts (Auth, Theme)
│ ├── lib/ # Utilities and API client
│ └── types/ # TypeScript type definitions
│
├── backend/ # FastAPI Backend
│ ├── app/
│ │ ├── models/ # SQLAlchemy database models
│ │ ├── schemas/ # Pydantic schemas
│ │ ├── services/ # Business logic layer
│ │ ├── routers/ # API route handlers
│ │ │ └── auth.py # Authentication endpoints
│ │ └── core/ # Core configurations & auth
│ ├── alembic/ # Database migrations
│ └── seed_data.py # Sample data generator
│
└── scripts/ # Utility scripts
├── run_backend_local.sh
└── test_local_config.sh
- Models: SQLAlchemy ORM with proper relationships
- Services: Business logic with atomic transactions
- Routers: RESTful API endpoints with validation
- Authentication: JWT tokens with bcrypt password hashing
- Database: SQLite for development, PostgreSQL for production
- App Router: Modern Next.js 14 routing
- Components: Reusable UI components with Tailwind CSS
- State Management: React Context API for Auth and Theme
- API Integration: Axios client with proper error handling
- Protected Routes: Client-side route protection
# Atomic transaction ensures data consistency
def create_order(db: Session, order_data: OrderCreate):
with db.begin():
# 1. Validate inventory availability
# 2. Create order record
# 3. Deduct raw materials atomically
# 4. Rollback on any failure- Real-time calculation of food item availability based on ingredient stock
- Prevents orders that cannot be fulfilled
- Shows detailed shortage information to users
Backend → Render
- Automatic deployments from Git
- PostgreSQL database support
- Environment variable management
- Built-in SSL and custom domains
Frontend → Vercel
- Optimized for Next.js
- Global CDN and edge functions
- Automatic preview deployments
- Environment variable support
See DEPLOYMENT.md and POSTGRESQL_DEPLOYMENT.md for detailed deployment instructions.
Backend (.env)
# Local Development
DATABASE_URL=sqlite:///./food_inventory.db
ENVIRONMENT=development
SECRET_KEY=your-secret-key-change-in-production
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
REFRESH_TOKEN_EXPIRE_DAYS=7Frontend (.env.local)
# Local Development
NEXT_PUBLIC_FOOD_API_URL=http://localhost:8000
# Production
NEXT_PUBLIC_FOOD_API_URL=https://your-backend.onrender.comThe system includes comprehensive seed scripts:
- 10 raw materials (flour, sugar, eggs, etc.)
- 4 food items with complete recipes
- Sample admin and staff users
- Realistic inventory levels and pricing
Run python seed_data.py to populate the database.
Interactive API documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
POST /api/auth/login- User authenticationGET /api/raw-materials/- List all raw materialsPOST /api/orders/- Create new order with inventory deductionGET /api/food-items/- List available menu itemsPOST /api/orders/check-inventory- Validate order before placement
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For support and questions:
- Create an issue on GitHub
- Check the documentation files (DEPLOYMENT.md, POSTGRESQL_DEPLOYMENT.md)
- Review API documentation at
/docsendpoint
Built with ❤️ for efficient food service management