crm_OBUO_FARMS
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data β all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v149View latest version
A dual-interface CRM application for OBUO Farms with separate client and admin portals.
- Issue: Orders were being created successfully in the database but the API was not returning the created order data, causing frontend errors
- Root Cause: SQLite result handling inconsistency - the
createOrderfunction wasn't properly extracting the created order from different possible result structures - Solution: Implemented robust result handling with fallback mechanisms to handle different SQLite response formats
- Status: β RESOLVED - Orders now create successfully and return proper data to the frontend
- New Feature: Complete product categorization system supporting Fish, Poultry, and Feed products
- Fish Products: Catfish and Tilapia in multiple forms (Fresh, Frozen, Live, Fillet, Smoked, Dried)
- Poultry Products: Chicken (Whole/Parts), Turkey, Duck, and Eggs (Chicken/Duck)
- Feed Products: Fish Feed and Poultry Feed
- Inventory Management: Real-time stock tracking with automatic updates when orders are placed
- Admin Controls: Manual stock adjustments with movement tracking and audit trail
- Stock Validation: Out-of-stock products are automatically disabled and greyed out in order forms
- Low Stock Alerts: Visual indicators for products below minimum stock levels
- Client Portal: Clean, simple order form for customers
- Admin Dashboard: Complete order management with authentication
- SQLite database for storing orders
- Automatic email confirmations to clients
- RESTful API for order management
- Simple, customer-friendly order form
- No backend data exposed to clients
- Automatic email confirmations
- Mobile-responsive design
- Professional OBUO Farms branding
- Secure login required
- Complete order management dashboard
- Create new orders manually
- View all orders with search/filter/sort
- Order statistics and analytics
- Logout functionality
Default Admin Credentials:
- Username:
admin - Password:
obuo2024
Note: Change these credentials for production use
βββ backend/
β βββ database/
β β βββ migrations.ts # Database schema
β β βββ queries.ts # Database operations
β βββ routes/
β β βββ orders.ts # Order API endpoints
β β βββ static.ts # Static file serving & routing
β βββ index.ts # Main Hono app
βββ frontend/
β βββ components/
β β βββ App.tsx # Main React app with routing
β β βββ ClientOrderForm.tsx # Public order form
β β βββ LoginForm.tsx # Admin login
β β βββ AdminDashboard.tsx # Admin interface
β β βββ OrderForm.tsx # Admin order creation
β β βββ Dashboard.tsx # Orders dashboard
β βββ index.html # Main HTML template
β βββ index.tsx # Frontend entry point
β βββ style.css # Styles
βββ shared/
βββ types.ts # Shared TypeScript types
βββ auth.ts # Authentication utilities
POST /api/orders- Create a new order (with automatic stock deduction)GET /api/orders- Get all orders (admin only)GET /api/orders/:id- Get specific orderPUT /api/orders/:id- Update orderDELETE /api/orders/:id- Delete order
GET /api/products- Get all active products with current stock levelsGET /api/products/low-stock- Get products below minimum stock levelGET /api/products/:id- Get specific product detailsPOST /api/products- Create new product (admin only)PUT /api/products/:id- Update product details (admin only)POST /api/products/:id/adjust-stock- Manually adjust product stock (admin/manager only)GET /api/products/:id/movements- Get stock movement history for specific productGET /api/products/movements/all- Get all stock movements (admin only)
POST /api/users/login- User authenticationGET /api/users- Get all users (admin only)POST /api/users- Create new user (admin only)PUT /api/users/:id- Update user (admin only)DELETE /api/users/:id- Delete user (admin only)
/- Client order form (public)/admin- Admin login/dashboard (protected)/health- Health check endpoint
Orders table includes:
- Client information (name, phone, email)
- Order details (type, quantity, delivery date)
- Notes and timestamps
The application automatically initializes the database on startup. No additional setup is required.
- Visit the main page (
/) to place orders - Fill out the simple order form
- Receive automatic email confirmation
- Visit
/adminto access the dashboard - Login with admin credentials
- View all orders, create new orders, and manage the system
- Use the dashboard for analytics and order tracking
- β Separate client and admin interfaces
- β Authentication required for admin access
- β Session management with 24-hour expiry
- β No sensitive data exposed to clients
- β Secure order creation and management
Catfish & Tilapia available in multiple forms:
- Fresh Fish
- Frozen Fish
- Live Fish
- Fish Fillet
- Smoked Fish
- Dried Fish
- Chicken (Whole)
- Chicken (Parts)
- Turkey
- Duck
- Eggs (Chicken)
- Eggs (Duck)
- Fish Feed
- Poultry Feed
- β Real-time Stock Tracking: Automatic stock deduction when orders are placed
- β Manual Stock Adjustments: Admin/Manager can manually add or remove stock
- β Stock Movement Audit Trail: Complete history of all stock changes with reasons
- β Low Stock Alerts: Visual warnings when products fall below minimum levels
- β Out-of-Stock Prevention: Products with zero stock are automatically disabled
- β Stock Validation: Order forms show real-time availability and maximum quantities
- β Multi-Unit Support: Products tracked in kg, pieces, or bags as appropriate
- β Dual Interface Design: Separate client and admin portals
- β Client Portal: Clean, simple order form without backend exposure
- β Admin Dashboard: Complete order management with authentication
- β Responsive design for mobile and desktop
- β Real-time order creation with validation
- β Automatic email confirmations to clients
- β Search and filter orders by multiple criteria
- β Sort orders by date, client name, or delivery date
- β Visual status indicators for delivery dates
- β SQLite database with proper schema
- β RESTful API with error handling
- β TypeScript for type safety
- β Session-based authentication for admin access