Skip to content

saranskumar/neyyardms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯› Neyyar Dairy System

A mobile-first Progressive Web App (PWA) for managing dairy inventory, sales, and logistics.

Built with Next.js 14, Supabase, and TanStack Query.


🎯 Project Overview

Target Users:

  • Salesmen (Mobile users with low internet connectivity)
  • Admins (Desktop users for reporting and logistics)

Core Flow:

Factory β†’ Main Store (GVM) β†’ Branch (VEN) β†’ Salesman β†’ Customer

🎨 Brand Identity

Element Value
Primary Color (Violet) #3E2758
Accent Color (Yellow) #FACC15
Background #F3F4F6
Surface #FFFFFF
Font Inter / Sans-serif

πŸ› οΈ Tech Stack

  • Framework: Next.js 14 (App Router, TypeScript)
  • Database: Supabase (PostgreSQL)
  • State Management: TanStack Query (React Query)
  • Styling: Tailwind CSS (Mobile-first)
  • Icons: Lucide React
  • PWA: next-pwa (Webpack-based)

πŸ“± Key Features

Salesman Interface (Mobile)

  • POS (Point of Sale): Touch-optimized product selection with quantity steppers
  • Offline Support: Cached shop list and debt tracking
  • Route Management: View assigned shops in route order
  • Cash Collection: Record payments and update shop balances
  • Expense Tracking: Log fuel and other expenses
  • Damage Reporting: Report broken/leaked items

Admin Portal (Desktop)

  • Stock Receiving: Process daily factory arrivals with GVM/VEN split
  • Trip Planning: Assign salesmen to routes with vehicle tracking
  • Inventory Dashboard: Real-time stock levels across warehouses
  • Analytics: Daily reports, P&L, debtor lists with Excel export
  • User Management: Create and manage salesman accounts

πŸš€ Getting Started

Prerequisites

Node.js 18+ 
npm / yarn / pnpm
Supabase account

Environment Setup

Create .env.local:

NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key

Installation

npm install
# or
yarn install

Run Development Server

npm run dev

Open http://localhost:3000

Build for Production

npm run build
npm start

πŸ“ Project Structure

neyyar-app/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                  # Next.js App Router pages
β”‚   β”‚   β”œβ”€β”€ layout.tsx        # Root layout with providers
β”‚   β”‚   β”œβ”€β”€ login/            # Authentication
β”‚   β”‚   β”œβ”€β”€ pos/              # Point of Sale (Salesman)
β”‚   β”‚   β”œβ”€β”€ route/            # Shop list
β”‚   β”‚   └── admin/            # Admin portal
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ ui/               # Reusable UI primitives
β”‚   β”‚   └── ToastContext.tsx  # Toast notification system
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ supabase.ts       # Supabase client
β”‚   β”‚   β”œβ”€β”€ rpc.ts            # RPC function wrappers
β”‚   β”‚   β”œβ”€β”€ utils.ts          # cn() utility for Tailwind
β”‚   β”‚   └── utils/            # Utility functions folder
β”‚   β”‚       β”œβ”€β”€ index.ts      # Barrel export
β”‚   β”‚       β”œβ”€β”€ formatters.ts # money(), date formatters
β”‚   β”‚       β”œβ”€β”€ toast.ts      # Toast notifications
β”‚   β”‚       β”œβ”€β”€ rpc.ts        # RPC type definitions
β”‚   β”‚       └── rpc-helpers.ts # RPC result handlers
β”‚   └── providers/
β”‚       β”œβ”€β”€ QueryProvider.tsx # TanStack Query setup
β”‚       └── SupabaseProvider.tsx # Auth state management
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ manifest.json         # PWA manifest
β”‚   └── favicon.png           # Logo asset
└── tailwind.config.ts

πŸ—„οΈ Database Schema (Supabase)

Core Tables

  • storehouses - GVM (ID: 1) and VEN (ID: 2)
  • products - Product catalog with pricing
  • shops - Customer shops with debt tracking
  • inventory - Stock levels per warehouse
  • sales - Transaction records
  • sale_items - Line items for each sale
  • trips - Daily route assignments
  • expenses - Salesman expense logs
  • damage_logs - Broken/leaked item tracking

Key RPC Functions

  • process_sale_transaction() - Handles sale with inventory deduction
  • process_daily_arrival() - Logs factory stock and splits to warehouses
  • collect_payment() - Updates shop balance
  • report_damage() - Records damaged items
  • get_daily_report() - Time-machine analytics

πŸ“± PWA Configuration

Meta Tags (in app/layout.tsx)

<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="theme-color" content="#3E2758">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

Manifest Settings

{
  "display": "standalone",
  "background_color": "#3E2758",
  "theme_color": "#3E2758"
}

🎯 Design Principles

Mobile-First (Salesman View)

  • Layout: Single column, stacked cards
  • Navigation: Bottom tab bar (fixed)
  • Touch Targets: Minimum 44px height
  • Minimalism: Hide secondary info behind "Details" clicks

Desktop (Admin View)

  • Layout: Sidebar + Data Grid
  • Density: Higher information density with generous whitespace
  • Responsiveness: Tailwind breakpoints (md:, lg:)

Clean UI Guidelines

  • Use Skeletons for loading states (no spinners)
  • Use Toast notifications for feedback (no alerts)
  • Icons with labels only when necessary
  • Generous padding on touch targets

βœ… Deployment Checklist

1. Database

  • Run neyyar_golden_master.sql in Supabase
  • Verify Storehouses (ID: 1=GVM, 2=VEN)
  • Create admin user with role='admin'

2. PWA Setup

  • Configure manifest.json with standalone display
  • Add apple-mobile-web-app meta tags
  • Generate 192x192 and 512x512 icons

3. Frontend Logic

  • Implement POS stock validation (qty ≀ inventory)
  • Configure React Query cache for offline support
  • Restrict number inputs to positive integers

4. Operations Test

  • Morning: Admin receives 100 items
  • Sales: Salesman sells 10 items
  • Damage: Report 1 damaged item
  • Verify: Dashboard shows 89 remaining
  • Cash: Reconciliation matches physical money

πŸ“š Learn More


πŸ“„ License

Proprietary - Neyyar Dairy System Β© 2024

About

Neyyar Diary Management system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors