Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 143 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,143 @@
# Vendor-Helper
This is an application targeting small vendors and shop owners to maximize its profit and reduce the time cost. It has integrated ai that helps them to analyse the patterns and gain insight from it.
# Vendor-Helper (Shop Insights App)

This is an application targeting small vendors and shop owners to maximize its profit and reduce the time cost. It has integrated AI that helps them to analyse the patterns and gain insight from it.

## Project Structure

```
shop_insights_app/
├── lib/
│ ├── main.dart # Main entry point
│ │
│ ├── core/
│ │ ├── constants.dart # App-wide constants
│ │ └── app_router.dart # Navigation routing
│ │
│ ├── models/
│ │ ├── sale_model.dart # Sales data model
│ │ ├── dashboard_summary.dart # Dashboard summary model
│ │ └── user_model.dart # User data model
│ │
│ ├── repositories/
│ │ ├── sales_repository.dart # Sales repository interface
│ │ ├── dummy_sales_repository.dart # Mock sales repository
│ │ ├── firebase_sales_repository.dart # Firebase sales repository
│ │ ├── insights_repository.dart # Insights repository interface
│ │ ├── dummy_insights_repository.dart # Mock insights repository
│ │ └── api_insights_repository.dart # API insights repository
│ │
│ ├── services/
│ │ ├── dashboard_service.dart # Dashboard business logic
│ │ ├── ocr_service.dart # OCR processing service
│ │ └── auth_service.dart # Authentication service
│ │
│ ├── screens/
│ │ ├── login_screen.dart # Login screen
│ │ ├── dashboard_screen.dart # Main dashboard
│ │ ├── add_sale_screen.dart # Add sale manually
│ │ ├── ocr_screen.dart # OCR receipt scanning
│ │ └── ai_insight_screen.dart # AI-powered insights
│ │
│ ├── widgets/
│ │ ├── sales_chart.dart # Sales trend chart
│ │ ├── category_bar_chart.dart # Category revenue chart
│ │ ├── top_products_list.dart # Top products display
│ │ └── insight_card.dart # Insight card widget
│ │
│ └── utils/
│ └── parsers.dart # Data parsing utilities
├── backend/
│ ├── main.py # FastAPI backend server
│ ├── gemini_service.py # Gemini AI integration
│ ├── auth_middleware.py # Authentication middleware
│ └── requirements.txt # Python dependencies
└── README.md
```

## Features

- **Dashboard**: View comprehensive sales analytics and metrics
- **Sales Management**: Add sales manually or via OCR
- **OCR Receipt Scanning**: Automatically extract sale data from receipts
- **AI Insights**: Get AI-powered business insights and recommendations
- **Analytics**: Visualize sales trends, category performance, and top products
- **User Authentication**: Secure login and user management

## Technology Stack

### Frontend (Flutter)
- **Framework**: Flutter/Dart
- **State Management**: StatefulWidget (can be extended with Provider/Bloc)
- **UI Components**: Material Design 3

### Backend (Python)
- **Framework**: FastAPI
- **AI Integration**: Google Gemini AI
- **Authentication**: JWT-based (configurable)
- **CORS**: Enabled for cross-origin requests

## Getting Started

### Prerequisites
- Flutter SDK (3.0+)
- Python 3.8+
- Gemini API Key (optional, for AI features)

### Frontend Setup

1. Install Flutter dependencies:
```bash
flutter pub get
```

2. Run the app:
```bash
flutter run
```

### Backend Setup

1. Navigate to the backend directory:
```bash
cd backend
```

2. Install Python dependencies:
```bash
pip install -r requirements.txt
```

3. Set up environment variables (optional):
```bash
export GEMINI_API_KEY=your_api_key_here
```

4. Run the backend server:
```bash
python main.py
```

The backend will be available at `http://localhost:8000`

## API Endpoints

- `GET /` - API information
- `GET /health` - Health check
- `POST /api/insights` - Get AI-powered insights
- `POST /api/ocr/process` - Process OCR images

## Future Enhancements

- Firebase integration for real-time data sync
- Enhanced OCR with Google Vision API
- Advanced analytics and reporting
- Multi-user support
- Mobile app deployment
- Cloud deployment (AWS/GCP/Azure)

## License

This project is open source and available under the MIT License.
66 changes: 66 additions & 0 deletions backend/auth_middleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from fastapi import HTTPException, Header
from typing import Optional


async def verify_token(authorization: Optional[str] = Header(None)) -> str:
"""
Verify the authentication token

In production, this would:
1. Verify the JWT token
2. Check token expiration
3. Validate user permissions
4. Return user information
"""
if not authorization:
raise HTTPException(
status_code=401,
detail="Missing authorization header"
)

if not authorization.startswith("Bearer "):
raise HTTPException(
status_code=401,
detail="Invalid authorization header format"
)

token = authorization.replace("Bearer ", "")

# TODO: Implement actual token verification
# For now, accept any non-empty token
if not token:
raise HTTPException(
status_code=401,
detail="Invalid token"
)

return token


def create_token(user_id: str) -> str:
"""
Create a JWT token for the user

In production, this would:
1. Create a JWT with user claims
2. Set appropriate expiration
3. Sign with secret key
"""
# TODO: Implement actual JWT token creation
return f"mock_token_{user_id}"


def decode_token(token: str) -> dict:
"""
Decode and validate a JWT token

In production, this would:
1. Verify token signature
2. Check expiration
3. Return user claims
"""
# TODO: Implement actual JWT decoding
return {
"user_id": "mock_user",
"email": "user@example.com"
}
Loading