Skip to content

LikhinMN/GroSence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎯 Grosense - AI-Powered Shopkeeper Management System

πŸš€ Quick Start (Ready to Use!)

Your complete FastAPI + Expo React Native system is ready! Follow these 3 simple steps:

Step 1️⃣: Configure Backend URL

  1. Find your computer's IP address:

    ipconfig  # Windows

    Look for IPv4 Address (e.g., 192.168.1.100)

  2. Update Expo/grosence/api/config.js:

    const API_BASE = "http://192.168.1.100:8000";  // Use YOUR IP

Step 2️⃣: Start Backend

cd backend
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

βœ… Backend running at: http://localhost:8000 πŸ“š API Docs at: http://localhost:8000/docs

Step 3️⃣: Start Frontend

cd Expo/grosence
npx expo start

Then:

  • Press a for Android
  • Press i for iOS
  • Scan QR code with Expo Go app

✨ What You Have

Backend (FastAPI)

βœ… Complete REST API with:

  • JWT authentication (login/signup)
  • Products CRUD with auto-generated barcodes
  • Sales transactions with automatic stock updates
  • Push notifications support
  • AI-ready database schema
  • Full API documentation at /docs

Frontend (Expo React Native)

βœ… Beautiful Mobile App with:

  • 🏠 Dashboard - Real-time stats, alerts, quick actions
  • πŸ“¦ Products - Add/edit/delete products, search, barcode system
  • πŸ’° Sales - Shopping cart, multi-item transactions, stock validation
  • 🎨 Modern UI - Styled with NativeWind (Tailwind CSS)
  • πŸ” Secure Auth - JWT token management, auto-login

πŸ“± Complete Features

Authentication

  • User registration with shop name
  • Secure login with JWT tokens
  • Auto-login on app restart
  • Password validation
  • Email validation

Dashboard

  • Total products count
  • Low stock alerts
  • Today's sales count
  • Today's revenue
  • Quick action buttons
  • Pull to refresh

Product Management

  • Add products with details
  • Auto-generate unique barcodes (UUID)
  • Edit product information
  • Delete products
  • Search products by name/category
  • View stock levels
  • Low stock indicators
  • Category management

Sales System

  • Create multi-item sales
  • Barcode-based product lookup
  • Shopping cart functionality
  • Quantity & discount support
  • Payment method selection (Cash/Card/UPI)
  • Automatic stock deduction
  • Stock validation before sale
  • Transaction history
  • Revenue tracking

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Expo React Native Frontend          β”‚
β”‚  (iOS, Android, Web)                    β”‚
β”‚  - NativeWind (Tailwind CSS)            β”‚
β”‚  - Expo Router Navigation               β”‚
β”‚  - JWT Authentication                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚ REST API
               β”‚ (axios + JWT tokens)
               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       FastAPI Backend                   β”‚
β”‚  - SQLAlchemy ORM                       β”‚
β”‚  - SQLite Database                      β”‚
β”‚  - JWT Security                         β”‚
β”‚  - Auto Stock Updates                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‚ File Structure

grosence/
β”œβ”€β”€ πŸ“– COMPLETE_SETUP_GUIDE.md       ← Start here!
β”œβ”€β”€ πŸ§ͺ test_integration.bat/sh       ← Test scripts
β”‚
β”œβ”€β”€ backend/                          ← FastAPI Backend
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py                  ← FastAPI app
β”‚   β”‚   β”œβ”€β”€ models.py                ← 9 database models
β”‚   β”‚   β”œβ”€β”€ schemas.py               ← Pydantic schemas
β”‚   β”‚   β”œβ”€β”€ deps.py                  ← Auth dependencies
β”‚   β”‚   β”œβ”€β”€ routers/
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.py              ← Login/Register
β”‚   β”‚   β”‚   β”œβ”€β”€ product.py           ← Products CRUD
β”‚   β”‚   β”‚   β”œβ”€β”€ sales.py             ← Sales transactions
β”‚   β”‚   β”‚   └── notifications.py     ← Push notifications
β”‚   β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”‚   β”œβ”€β”€ config.py            ← Environment config
β”‚   β”‚   β”‚   └── db.py                ← Database setup
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”‚   β”œβ”€β”€ security.py          ← JWT & password hashing
β”‚   β”‚   β”‚   β”œβ”€β”€ barcode.py           ← Barcode generation
β”‚   β”‚   β”‚   └── notifications.py     ← Expo push
β”‚   β”‚   └── services/
β”‚   β”‚       └── ai_stub.py           ← AI hooks (future)
β”‚   β”œβ”€β”€ .env                         ← Configuration
β”‚   β”œβ”€β”€ requirements.txt             ← Python packages
β”‚   └── grosense.db                  ← SQLite database
β”‚
└── Expo/grosence/                   ← React Native Frontend
    β”œβ”€β”€ app/
    β”‚   β”œβ”€β”€ _layout.jsx              ← Root + AuthProvider
    β”‚   β”œβ”€β”€ index.jsx                ← Auto-navigation
    β”‚   β”œβ”€β”€ onboarding.jsx           ← Welcome screen
    β”‚   β”œβ”€β”€ (auth)/
    β”‚   β”‚   β”œβ”€β”€ login.jsx            ← Login screen
    β”‚   β”‚   └── signup.jsx           ← Registration
    β”‚   └── (tabs)/
    β”‚       β”œβ”€β”€ _layout.jsx          ← Bottom tabs
    β”‚       β”œβ”€β”€ home.jsx             ← Dashboard
    β”‚       β”œβ”€β”€ products.jsx         ← Product management
    β”‚       └── sales.jsx            ← Sales system
    β”œβ”€β”€ api/
    β”‚   β”œβ”€β”€ config.js                ← ⚠️ UPDATE THIS!
    β”‚   β”œβ”€β”€ api.js                   ← Axios client
    β”‚   β”œβ”€β”€ auth.js                  ← Auth APIs
    β”‚   └── products.js              ← Product/Sales APIs
    β”œβ”€β”€ components/
    β”‚   β”œβ”€β”€ UI.jsx                   ← Reusable components
    β”‚   └── ProductCard.jsx          ← Cards
    β”œβ”€β”€ contexts/
    β”‚   └── AuthContext.jsx          ← Global auth state
    β”œβ”€β”€ hooks/
    β”‚   β”œβ”€β”€ useProducts.js           ← Products hook
    β”‚   └── useSales.js              ← Sales hook
    └── package.json                 ← Dependencies

πŸ”§ Testing Integration

Option 1: Quick Test (Windows)

test_integration.bat

Option 2: Manual Test

  1. Test Backend:

    curl http://localhost:8000/health
    # Should return: {"status":"ok"}
  2. Test API Docs: Open: http://localhost:8000/docs

  3. Test Registration:

    • Open app β†’ Sign Up
    • Fill in details
    • Should redirect to Dashboard
  4. Test Products:

    • Add a product
    • View in Products tab
    • Edit/Delete product
  5. Test Sales:

    • Create new sale
    • Enter product barcode
    • Complete transaction
    • Check stock decreased

🎨 UI Preview

Color Scheme

  • Primary: Blue #3B82F6
  • Success: Green #10B981
  • Warning: Red #EF4444
  • Info: Yellow #F59E0B

Screens

  1. Onboarding β†’ Feature showcase
  2. Login/Signup β†’ Authentication
  3. Dashboard β†’ Stats & quick actions
  4. Products β†’ Grid view with search
  5. Sales β†’ Cart-based system

πŸ” Security Features

βœ… Password hashing with bcrypt βœ… JWT token authentication βœ… Secure token storage (AsyncStorage) βœ… Request/response interceptors βœ… Auto-logout on 401 βœ… Input validation (frontend + backend) βœ… SQL injection protection (SQLAlchemy ORM)


πŸ“Š Database Schema

9 Complete Models:

  1. Shopkeeper - User accounts
  2. Supplier - Product suppliers
  3. Product - Inventory items
  4. SalesTransaction - Sale headers
  5. SalesRecord - Sale line items
  6. StockEvent - Inventory audit log
  7. AIPrediction - ML predictions (future)
  8. AIInsight - AI recommendations (future)
  9. ExpoPushToken - Push notifications

πŸš€ Deployment (Production)

Backend

  1. Switch to PostgreSQL
  2. Deploy to: Railway, Heroku, DigitalOcean
  3. Use environment variables
  4. Enable HTTPS

Frontend

  1. Build with: eas build
  2. Submit to App Store / Play Store
  3. Update API_BASE to production URL

πŸ› Troubleshooting

"Cannot connect to backend"

  • βœ“ Backend running on 0.0.0.0:8000
  • βœ“ Updated api/config.js with correct IP
  • βœ“ Same WiFi network
  • βœ“ Firewall allows port 8000

"Login failed"

  • βœ“ Check backend terminal for errors
  • βœ“ Register account first
  • βœ“ Check email/password

"Products not loading"

  • βœ“ Token is valid (try re-login)
  • βœ“ Check backend /products/ endpoint
  • βœ“ Check React Native Debugger

πŸ“š Documentation

  • Setup Guide: COMPLETE_SETUP_GUIDE.md
  • Backend Details: backend/IMPLEMENTATION_SUMMARY.md
  • Frontend Details: Expo/grosence/FRONTEND_GUIDE.md
  • API Docs: http://localhost:8000/docs

🎯 Next Steps (Optional Enhancements)

  • Camera barcode scanner (expo-barcode-scanner)
  • Push notifications integration
  • Offline mode with local database
  • Sales charts & analytics
  • Export reports (PDF/CSV)
  • Dark mode
  • Multi-language support
  • AI predictions implementation

πŸ’‘ Tips

  1. Development: Use http://YOUR_IP:8000 (not localhost)
  2. Testing: Use Expo Go app on real device
  3. Debugging: Enable Remote JS Debugging in Expo
  4. Backend Logs: Watch terminal for API errors
  5. Frontend Logs: Check React Native Debugger console

βœ… Checklist

Before you start:

  • Python 3.8+ installed
  • Node.js 14+ installed
  • Expo Go app on your phone
  • Both devices on same WiFi
  • Port 8000 not in use

Setup:

  • Updated api/config.js with your IP
  • Started backend server
  • Started Expo app
  • Scanned QR code

Testing:

  • Registered new account
  • Logged in successfully
  • Added a product
  • Created a sale
  • Verified stock updated

πŸŽ‰ You're All Set!

Your Grosense AI-Powered Shopkeeper Management System is ready to use!

Need help? Check the detailed guides or open an issue.

Happy selling! πŸš€


Built with ❀️ by Likhith M N FastAPI + Expo + SQLAlchemy + NativeWind + JWT

About

AI-powered shopkeeper management platform with inventory tracking, sales management, barcode support, and business insights.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors