• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
eddie_walk

eddie_walk

crm_OBUO_FARMS

Public
Like
crm_OBUO_FARMS
Home
Code
4
backend
3
frontend
5
shared
2
README.md
Branches
1
Pull requests
Remixes
History
Environment variables
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.
Sign up now
Code
/
README.md
Code
/
README.md
Search
6/3/2025
Viewing readonly version of main branch: v149
View latest version
README.md

OBUO Farms CRM

A dual-interface CRM application for OBUO Farms with separate client and admin portals.

Recent Fixes

βœ… Order Creation Issue Resolved

  • 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 createOrder function 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

βœ… Enhanced Product System & Inventory Management

  • 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

Features

  • 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

Interfaces

🐟 Client Portal (/)

  • Simple, customer-friendly order form
  • No backend data exposed to clients
  • Automatic email confirmations
  • Mobile-responsive design
  • Professional OBUO Farms branding

πŸ” Admin Dashboard (/admin)

  • Secure login required
  • Complete order management dashboard
  • Create new orders manually
  • View all orders with search/filter/sort
  • Order statistics and analytics
  • Logout functionality

Authentication

Default Admin Credentials:

  • Username: admin
  • Password: obuo2024

Note: Change these credentials for production use

Project Structure

β”œβ”€β”€ 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

API Endpoints

Orders

  • 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 order
  • PUT /api/orders/:id - Update order
  • DELETE /api/orders/:id - Delete order

Products & Inventory

  • GET /api/products - Get all active products with current stock levels
  • GET /api/products/low-stock - Get products below minimum stock level
  • GET /api/products/:id - Get specific product details
  • POST /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 product
  • GET /api/products/movements/all - Get all stock movements (admin only)

Users

  • POST /api/users/login - User authentication
  • GET /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)

Routes

  • / - Client order form (public)
  • /admin - Admin login/dashboard (protected)
  • /health - Health check endpoint

Database Schema

Orders table includes:

  • Client information (name, phone, email)
  • Order details (type, quantity, delivery date)
  • Notes and timestamps

Setup

The application automatically initializes the database on startup. No additional setup is required.

Usage

For Customers:

  1. Visit the main page (/) to place orders
  2. Fill out the simple order form
  3. Receive automatic email confirmation

For OBUO Farms Staff:

  1. Visit /admin to access the dashboard
  2. Login with admin credentials
  3. View all orders, create new orders, and manage the system
  4. Use the dashboard for analytics and order tracking

Security Features

  • βœ… 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

Product Categories Available

🐟 Fish Products

Catfish & Tilapia available in multiple forms:

  • Fresh Fish
  • Frozen Fish
  • Live Fish
  • Fish Fillet
  • Smoked Fish
  • Dried Fish

πŸ” Poultry & Eggs

  • Chicken (Whole)
  • Chicken (Parts)
  • Turkey
  • Duck
  • Eggs (Chicken)
  • Eggs (Duck)

🌾 Feed Products

  • Fish Feed
  • Poultry Feed

Inventory Management Features

  • βœ… 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

Features

  • βœ… 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
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
Β© 2025 Val Town, Inc.