A modern, full-stack snack bar management system for NECC (NΓΊcleo de Estudantes de CiΓͺncias da ComputaΓ§Γ£o) at University of Minho
Features β’ Tech Stack β’ Getting Started β’ Project Structure
Snecc Bar is a comprehensive web application designed to manage the NECC Snack Bar operations. It provides a seamless experience for students to browse and purchase products, while offering administrators powerful tools to manage inventory, users, transactions, and financial operations.
The system supports NECC's student activities by offering affordable snacks, drinks, and merchandise to students while maintaining a complete audit trail of all operations.
- Dynamic Product Display: Real-time product catalog with images, prices, and stock levels
- Member Pricing: Automatic price adjustment based on membership status
- Stock Visibility: Real-time stock indicators to prevent out-of-stock purchases
- Responsive Design: Fully optimized for mobile and desktop devices
- Shopping Cart: Add multiple products with quantity selection
- Dual Payment Methods:
- Balance-based payments (for registered users)
- Cash payments (for walk-in customers)
- Purchase Animations: Visual feedback when adding products to cart
- Order History: Complete purchase history with details and timestamps
- User Registration: Simple registration system for new users
- Authentication: Secure login with Supabase Auth
- Balance Tracking: Real-time balance display and transaction history
- Deposit History: Track all balance deposits and methods
- User CRUD Operations: Create, read, update, and manage user accounts
- User Details View: Comprehensive user information including:
- Purchase history
- Deposit history
- Balance changes
- Membership status
- Balance Management: Add or remove user balance with multiple methods:
- Cash deposits
- MB Way transfers
- Manual adjustments
- Membership Toggle: Enable/disable member pricing per user
- Pagination: Efficient user list with customizable items per page (5, 10, 15, 30)
- Search Functionality: Quick user search by name or email
- Unified Transaction View: All transaction types in one place:
- Orders: Customer purchases with item details
- Deposits: Balance additions with payment method tracking
- Cash Adjustments: Available cash modifications with admin tracking
- Theft/Loss Records: Inventory loss tracking with admin attribution
- Advanced Filtering:
- Filter by transaction type
- Filter by user
- Filter by product (for orders and thefts)
- Transaction Details:
- Previous value, new value, and difference columns
- Admin attribution for cash adjustments and thefts
- Timestamp and payment method information
- Transaction Deletion: Remove transactions with automatic reversals:
- Balance restoration for deposits
- Stock restoration for orders
- Stock restoration for thefts
- Pagination: Efficient transaction list with customizable items per page
- Transaction Summary: Total revenue, deposits, cash adjustments, and thefts
- Product CRUD: Complete product lifecycle management
- Stock Management:
- Add stock manually
- Edit product details (name, prices, stock, image)
- Track stock changes with automatic logging
- Theft/Loss Tracking:
- Mark stock reductions as "stolen/lost"
- Automatic admin attribution
- Complete audit trail
- Inactive Products: Soft delete system to preserve order history
- Product Restoration: Restore previously deleted products
- Available Cash Tracking: Monitor physical cash on hand
- Cash Adjustment Logs: Complete history of cash modifications with:
- Admin attribution
- Reason tracking
- Previous/new value tracking
- Deposit Statistics: Total deposits tracking
- Profit Calculation: Real profit calculation (revenue - purchase costs)
- Financial Dashboard: Overview cards with key metrics
- Next.js 16: React framework with App Router
- TypeScript: Type-safe development
- Tailwind CSS 4.1: Utility-first CSS framework
- Radix UI: Accessible component primitives
- Lucide React: Beautiful icon library
- Supabase:
- PostgreSQL database
- Row Level Security (RLS) policies
- Authentication system
- Real-time capabilities
- Database Features:
- Triggers for automatic stock updates
- Foreign key constraints
- Audit logging tables
- Vercel: Hosting and deployment platform
- Custom Domain: Configured with CNAME
- Node.js 18+ and npm/yarn
- Supabase account and project
- Git
-
Clone the repository
git clone <repository-url> cd snecc-bar
-
Install dependencies
npm install
-
Set up environment variables
Create a
.env.localfile in the root directory:NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
-
Set up the database
Run the SQL scripts in your Supabase SQL Editor:
- Create necessary tables (users, products, orders, etc.)
- Set up RLS policies
- Create triggers for stock management
- Add admin_id columns for audit trails
-
Run the development server
npm run dev
-
Open your browser
Navigate to http://localhost:3000
snecc-bar/
βββ app/
β βββ admin/ # Admin dashboard
β β βββ page.tsx # Main admin interface
β βββ api/ # API routes
β βββ config/ # Configuration files
β βββ login/ # Login page
β βββ register/ # Registration page
β βββ page.tsx # Main vending machine interface
β βββ layout.tsx # Root layout
β βββ globals.css # Global styles
βββ components/
β βββ ui/ # Reusable UI components
β β βββ button.tsx
β β βββ card.tsx
β β βββ input.tsx
β β βββ tabs.tsx
β β βββ alert-dialog.tsx
β βββ theme-provider.tsx # Theme management
βββ lib/
β βββ auth.ts # Authentication & database functions
β βββ utils.ts # Utility functions
βββ public/ # Static assets
β βββ [product-images] # Product images
βββ supabase/ # Supabase configuration
βββ package.json # Dependencies
- Row Level Security (RLS): Database-level access control
- Admin-only Routes: Protected admin dashboard
- Authentication: Secure user authentication via Supabase
- Audit Trails: Complete logging of admin actions
- Input Validation: Client and server-side validation
-
Orders: Customer purchases
- Tracks items, quantities, and payment method
- Automatic stock deduction
- Balance deduction for balance payments
- Cash tracking for cash payments
-
Deposits: Balance additions
- Multiple payment methods (cash, MB Way, adjustment)
- Automatic balance updates
- Complete transaction history
-
Cash Adjustments: Available cash modifications
- Admin attribution
- Reason tracking
- Complete audit trail
-
Theft/Loss Records: Inventory loss tracking
- Admin attribution
- Product and quantity tracking
- Automatic stock deduction
- Financial impact calculation
- Automatic Updates: Database triggers handle stock changes
- Movement Types:
sale: Customer purchasesadd_stock: Manual stock additionscorrection: Stock correctionstheft: Stolen/lost items
- Real-time Sync: Stock levels update immediately
- Dark Theme: Modern dark interface
- Responsive Design: Mobile-first approach
- Loading States: Visual feedback during operations
- Error Handling: User-friendly error messages
- Confirmation Dialogs: Prevent accidental actions
- Pagination: Efficient data display
- Search & Filters: Quick data access
- Animations: Smooth transitions and feedback
- users: User accounts with balance and membership status
- products: Product catalog with pricing and stock
- orders: Customer orders with payment information
- order_items: Individual items in orders
- deposits: Balance deposits with payment methods
- inventory_movements: Stock change tracking
- available_cash_logs: Cash adjustment history
- Users β Orders (one-to-many)
- Orders β Order Items (one-to-many)
- Order Items β Products (many-to-one)
- Inventory Movements β Products (many-to-one)
- Inventory Movements β Users (admin attribution)
npm run dev: Start development servernpm run build: Build for productionnpm run start: Start production servernpm run lint: Run ESLint
- TypeScript strict mode enabled
- ESLint configuration
- Consistent component structure
- Utility functions for reusability
This is an internal project for NECC. For contributions, please contact the project maintainers.
For issues or questions, please contact the NECC development team.
Built with β€οΈ for NECC - University of Minho