FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
eddie_walk
eddie_walkcrm_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
/
Code
/
Search
index.ts
https://eddie_walk--aa24c4823fc711f0b39e76b3cceeab13.web.val.run
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, Guinea Fowl, 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

✅ Comprehensive Financial Management & Accounting System

  • Complete Financial Dashboard: Real-time financial overview with key metrics
  • Expense Management: Track all business expenses by category (feed, equipment, labor, utilities, etc.)
  • Revenue Tracking: Automatic sales revenue tracking plus manual other income entries
  • Profit Analysis: Gross profit, net profit, and profit margin calculations
  • Cost Management: Product-level cost and selling price tracking for accurate profitability
  • Financial Reports: Detailed sales reports with category and product breakdowns
  • Payment Tracking: Multiple payment method support (cash, bank transfer, check, card)
  • Expense Categories: Organized expense tracking (feed, equipment, labor, utilities, maintenance, transport, marketing, other)
  • Date Range Analysis: Flexible reporting periods (daily, monthly, quarterly, yearly)
  • Top Products Analysis: Identify best-selling and most profitable products
  • Expense Breakdown: Visual percentage breakdown of spending by category

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)

Financial Management

  • POST /api/financial/expenses - Add new expense
  • GET /api/financial/expenses - Get expenses (with date/category filters)
  • GET /api/financial/expenses/:id - Get specific expense
  • PUT /api/financial/expenses/:id - Update expense
  • DELETE /api/financial/expenses/:id - Delete expense
  • POST /api/financial/revenue - Add other revenue (non-sales)
  • GET /api/financial/revenue - Get revenue records
  • GET /api/financial/summary - Get comprehensive financial summary
  • GET /api/financial/sales-report - Get detailed sales analytics

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
  • Guinea Fowl
  • Eggs (Chicken)
  • Eggs (Duck)

🌾 Feed Products

  • Fish Feed
  • Poultry Feed

Financial Management Features

💰 Complete Accounting System

  • ✅ Real-time Financial Dashboard: Live overview of revenue, expenses, and profitability
  • ✅ Expense Management: Categorized expense tracking with receipt management
  • ✅ Revenue Tracking: Automatic sales revenue + manual other income entries
  • ✅ Profit Analysis: Gross profit, net profit, and margin calculations
  • ✅ Cost Management: Product-level cost and selling price tracking
  • ✅ Financial Reports: Comprehensive sales and financial analytics
  • ✅ Payment Method Tracking: Support for cash, bank transfer, check, and card payments
  • ✅ Date Range Analysis: Flexible reporting periods for any time frame
  • ✅ Top Products Analysis: Identify best-selling and most profitable items
  • ✅ Expense Breakdown: Visual percentage analysis of spending by category

📊 Key Financial Metrics Available

  • Revenue Metrics: Total sales, average order value, sales by category/product
  • Expense Metrics: Total expenses, expense breakdown by category, payment methods
  • Profitability: Gross profit, net profit, profit margins, cost analysis
  • Sales Analytics: Top-selling products, sales trends, quantity sold
  • Performance Indicators: Order statistics, customer analytics, growth metrics

💸 Expense Categories

  • Feed & Supplies
  • Equipment & Tools
  • Labor & Wages
  • Utilities (electricity, water, etc.)
  • Maintenance & Repairs
  • Transportation & Delivery
  • Marketing & Advertising
  • Other Business Expenses

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
HTTP
  • index.ts
    eddie_walk--aa…13.web.val.run
Code
backendfrontendsharedREADME.md
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.