A voice-enabled digital ration ledger app for small shop owners to track customers and their ration entries, with phone OTP login via Twilio.
- ๐ฑ Phone OTP Login โ Secure login via Twilio SMS verification
- ๐๏ธ Voice Entry โ Add entries using voice commands in Hindi/English
(e.g., "Ram Kumar 2 kg rice 60 rupees") - ๐ฅ Customer Management โ Add, view, and manage customers
- ๐ Ration Entries โ Track items, quantities, units, and prices per customer
- ๐ Search โ Quickly find customers by name
- ๐ Protected Routes โ Only authenticated users can access the app
| Layer | Technology |
|---|---|
| Frontend | React 18 + TypeScript + Vite |
| Styling | Tailwind CSS + shadcn/ui |
| Backend | Lovable Cloud (powered by Supabase) |
| Database | PostgreSQL (via Lovable Cloud) |
| Edge Functions | Deno (serverless, auto-deployed) |
| SMS | Twilio API |
| State Management | TanStack React Query |
Before you start, make sure you have:
- Node.js v18+ โ Download here or install via nvm
- npm (comes with Node.js) or bun (install bun)
- A Twilio Account โ Sign up free
- Account SID (starts with
AC...) - Auth Token
- A Twilio phone number for sending SMS
- Account SID (starts with
git clone <YOUR_GIT_URL>
cd digital-khatanpm installOr if using bun:
bun installThe .env file is auto-configured by Lovable Cloud with these variables:
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_PUBLISHABLE_KEY=your-anon-key
VITE_SUPABASE_PROJECT_ID=your-project-id
โ ๏ธ Do NOT commit.envto version control. It's already in.gitignore.
In Lovable, go to Settings โ Cloud โ Secrets and add:
| Secret Name | Where to Find It |
|---|---|
TWILIO_ACCOUNT_SID |
Twilio Console โ Account SID |
TWILIO_AUTH_TOKEN |
Twilio Console โ Auth Token (click "Show") |
TWILIO_PHONE_NUMBER |
Twilio Console โ Phone Numbers โ Your number (format: +1XXXXXXXXXX) |
npm run devThe app will open at http://localhost:5173
- Open
http://localhost:5173in your browser - Enter your phone number on the login screen
- You'll receive a 6-digit OTP via SMS
- Enter the OTP to log in
- Start adding customers and ration entries!
digital-khata/
โโโ public/ # Static assets
โ โโโ favicon.ico
โ โโโ robots.txt
โโโ src/
โ โโโ components/ # Reusable UI components
โ โ โโโ ui/ # shadcn/ui components
โ โ โโโ AddCustomerDialog.tsx
โ โ โโโ AddEntryForm.tsx
โ โ โโโ CustomerCard.tsx
โ โ โโโ GlobalVoiceEntry.tsx
โ โ โโโ NavLink.tsx
โ โโโ contexts/
โ โ โโโ AuthContext.tsx # Authentication state management
โ โโโ hooks/
โ โ โโโ useCustomers.ts # Customer CRUD operations
โ โ โโโ useRationEntries.ts # Entry CRUD operations
โ โ โโโ useVoiceInput.ts # Browser speech recognition
โ โโโ integrations/
โ โ โโโ supabase/
โ โ โโโ client.ts # Supabase client (auto-generated)
โ โ โโโ types.ts # Database types (auto-generated)
โ โโโ pages/
โ โ โโโ Index.tsx # Home page (customer list)
โ โ โโโ Login.tsx # Phone OTP login page
โ โ โโโ CustomerDetail.tsx # Individual customer view
โ โ โโโ NotFound.tsx # 404 page
โ โโโ App.tsx # Root component with routing
โ โโโ index.css # Design tokens & global styles
โ โโโ main.tsx # Entry point
โโโ supabase/
โ โโโ functions/
โ โ โโโ send-otp/
โ โ โ โโโ index.ts # Edge function: send OTP via Twilio
โ โ โโโ verify-otp/
โ โ โโโ index.ts # Edge function: verify OTP code
โ โโโ config.toml # Supabase project config
โโโ .env # Environment variables (auto-configured)
โโโ package.json
โโโ tailwind.config.ts
โโโ vite.config.ts
โโโ tsconfig.json
| Column | Type | Default | Description |
|---|---|---|---|
id |
uuid | auto | Primary key |
name |
text | โ | Customer name |
phone |
text | null | Phone number (optional) |
created_at |
timestamptz | now() | Creation timestamp |
updated_at |
timestamptz | now() | Last update timestamp |
| Column | Type | Default | Description |
|---|---|---|---|
id |
uuid | auto | Primary key |
customer_id |
uuid | โ | FK โ customers.id |
item_name |
text | โ | Item name (e.g., "rice") |
quantity |
numeric | 1 | Amount |
unit |
text | "kg" | Unit (kg, g, litre, ml, piece, packet) |
price |
numeric | 0 | Price in โน |
created_at |
timestamptz | now() | Entry timestamp |
| Column | Type | Default | Description |
|---|---|---|---|
id |
uuid | auto | Primary key |
phone |
text | โ | Phone number |
code |
text | โ | 6-digit OTP |
expires_at |
timestamptz | โ | Expires 5 min after creation |
verified |
boolean | false | Whether verified |
created_at |
timestamptz | now() | Creation timestamp |
| Function | Method | Description |
|---|---|---|
send-otp |
POST | Generates 6-digit OTP, stores in DB, sends via Twilio SMS |
verify-otp |
POST | Validates OTP against DB, marks as verified |
Request examples:
# Send OTP
curl -X POST https://your-project.supabase.co/functions/v1/send-otp \
-H "Content-Type: application/json" \
-d '{"phone": "+919876543210"}'
# Verify OTP
curl -X POST https://your-project.supabase.co/functions/v1/verify-otp \
-H "Content-Type: application/json" \
-d '{"phone": "+919876543210", "code": "123456"}'- Open the project in Lovable
- Click Publish button (top-right corner)
- Click Update to deploy
- Your app is live at
https://yourapp.lovable.app - (Optional) Connect a custom domain:
Go to Settings โ Domains โ Connect Domain
๐ก Backend (edge functions, database) deploys automatically. Frontend requires clicking "Update".
- Push your code to GitHub
- Go to vercel.com โ Import your repo
- Set build command:
npm run build - Set output directory:
dist - Add environment variables (
VITE_SUPABASE_URL,VITE_SUPABASE_PUBLISHABLE_KEY) - Click Deploy
- Push your code to GitHub
- Go to netlify.com โ Import from Git
- Build command:
npm run build - Publish directory:
dist - Add environment variables in Site Settings โ Environment
- Deploy
# Build for production
npm run build
# The 'dist/' folder contains your production-ready app
# Upload it to any static hosting (AWS S3, Cloudflare Pages, etc.)The app supports Hindi and English voice commands. Format:
[Customer Name] [Quantity] [Unit] [Item] [Price] rupees
Examples:
- "Ram Kumar 2 kg rice 60 rupees"
- "เคฐเคฎเฅเคถ เคเฅเคฎเคพเคฐ 5 เคเคฟเคฒเฅ เคเคเคพ 200 เคฐเฅเคชเคฏเฅ"
- "Sita 1 litre oil 150 rupees"
Supported units: kg, g, litre, ml, piece, packet
Supported Hindi units: เคเคฟเคฒเฅ, เคเฅเคฐเคพเคฎ, เคฒเฅเคเคฐ, เคชเฅเคธ, เคชเฅเคเฅเค
| Command | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Build for production |
npm run preview |
Preview production build locally |
npm run lint |
Run ESLint |
npm run test |
Run tests |
npm run test:watch |
Run tests in watch mode |
| Issue | Solution |
|---|---|
| OTP not received | Check Twilio credentials in Cloud Secrets. Ensure phone number format is +91XXXXXXXXXX |
| "Failed to send SMS" | Verify Twilio Account SID and Auth Token are correct |
| Login succeeds but no redirect | Clear browser cache and try again |
| Voice not working | Allow microphone permission in browser. Works best in Chrome |
| Customers not loading | Check that the database tables exist and RLS policies are set |
MIT