Skip to content

samletnorge/assist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

82 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Assist

AI-powered tools for extending ERPNext with MCP (Model Context Protocol) integration

License: MIT Python 3.10+ ERPNext

Features β€’ Installation β€’ Architecture β€’ API β€’ Documentation


🎯 Overview

Assist is a comprehensive Frappe/ERPNext app that extends your ERP system with AI-powered automation, marketplace integrations, and Norwegian business tools. It bridges the gap between traditional ERP systems and modern AI capabilities through the Model Context Protocol (MCP).

Key Capabilities

  • πŸ“Έ Smart Image Processing - AI-powered background removal and enhancement for product photography
  • 🧾 Intelligent Receipt Scanning - OCR and automatic item extraction from receipts
  • πŸͺ Multi-Platform Marketplace - Seamlessly post to Facebook Marketplace, FINN.no, leid.no
  • πŸ’° Price Intelligence - Real-time price comparison across vendors and Prisjakt.no
  • 🚚 Smart Logistics - Optimized pickup route planning for marketplace orders
  • 🏒 Norwegian Compliance - Skatteetaten, Kommune, and NS 4102 accounting integration
  • πŸ“¦ Warehouse Discovery - Automated warehouse finding on FINN.no
  • πŸ€– AI Integration - Full MCP server for AI model interaction
  • πŸ“ Technical Standards - RDS 81346 and S1000D documentation generation
  • πŸ”§ DevOps Integration - GitHub repository management as ERP assets

πŸ—οΈ Architecture

graph TB
    subgraph "External Services"
        AI[AI Models via MCP]
        Marketplaces[Marketplaces<br/>FB β€’ FINN β€’ leid.no]
        Norwegian[Norwegian Services<br/>Skatteetaten β€’ Kommune]
        ImageAPI[Image APIs<br/>rembg β€’ altlokalt]
        Prisjakt[Price Services<br/>Prisjakt.no]
    end

    subgraph "Assist App"
        direction TB
        API[API Layer<br/>assist/api.py]
        MCP[MCP Server<br/>mcp_server/server.py]
        Utils[Utilities<br/>Image Processing]
        Doctypes[Custom Doctypes<br/>Tool Drafts β€’ Listings]
        
        API --> Utils
        API --> MCP
        MCP --> Utils
        MCP --> Doctypes
    end

    subgraph "ERPNext Core"
        Items[Items & Stock]
        Assets[Assets]
        Accounting[Accounting]
        Warehouse[Warehouses]
    end

    subgraph "User Interfaces"
        UI[ERPNext Desk UI]
        Mobile[Mobile/Camera]
        AIUI[AI Assistants]
    end

    UI --> API
    Mobile --> API
    AIUI --> MCP
    
    API --> Items
    API --> Assets
    API --> Accounting
    API --> Warehouse
    
    MCP --> AI
    API --> Marketplaces
    API --> Norwegian
    Utils --> ImageAPI
    API --> Prisjakt

    style Assist App fill:#e1f5ff
    style ERPNext Core fill:#fff4e6
    style External Services fill:#f3e5f5
    style User Interfaces fill:#e8f5e9
Loading

Data Flow Example: Camera Item Addition

sequenceDiagram
    participant User
    participant Mobile
    participant API
    participant ImageProc as Image Processing
    participant AI as AI Service
    participant ERPNext

    User->>Mobile: Capture product photo
    Mobile->>API: POST quick_add_item(image, warehouse)
    API->>ImageProc: process_camera_image()
    
    alt Use AI Background Removal
        ImageProc->>AI: remove_background()
        AI-->>ImageProc: cleaned image
    end
    
    ImageProc->>ImageProc: enhance_image()
    ImageProc-->>API: processed image
    
    API->>ERPNext: Create Item with image
    ERPNext->>ERPNext: Attach to warehouse
    ERPNext-->>API: Item created
    API-->>Mobile: Success + Item details
    Mobile-->>User: Show confirmation
Loading

✨ Features

πŸ“Έ Image Processing & OCR

  • AI Background Removal

    • Local processing with rembg
    • Cloud API via altlokalt.com
    • Automatic fallback mechanism
  • Image Enhancement

    • Brightness, contrast, sharpness adjustment
    • Batch processing support
    • Multiple format support (PNG, JPG, WebP)
  • Camera Stock Upload ⭐ NEW!

    • Quick add items using phone camera
    • Batch upload for multiple items at once
    • Automatic background removal and enhancement
    • Intuitive mobile-first interface
    • Real-time processing status tracking
  • Receipt Scanning

    • OCR text extraction
    • Automatic item detection
    • Line item parsing with prices

πŸͺ Marketplace Integration

Supported Platforms:

  • Facebook Marketplace
  • FINN.no (Norway's leading classifieds)
  • leid.no (rental marketplace)
  • bruktdel.no (used car parts) ⭐ NEW!
  • Custom marketplace support

Features:

  • Automated listing creation
  • Image optimization
  • Price suggestion
  • Listing synchronization
  • Phone-control automation
    • Google Maps Route Generation ⭐ NEW!
    • Automatic route link generation for pickup locations
    • Multi-listing route optimization
    • Seller contact tracking
  • Packaging Management ⭐ NEW!
    • Track packaging status (Pending/In Progress/Completed)
    • Packaging notes and requirements
  • Auto Photoshoot ⭐ NEW!
    • Automated multi-angle product photography
    • Integration with camera batch upload
    • Background removal and enhancement =======
  • Car Parts Tracking - Monitor bruktdel.no for new car parts linked to owned vehicle assets
  • Marketplace Hustle Routine ⭐ NEW!
    • Automatic monitoring of saved marketplace searches
    • Smart matching with Material Requests and Tasks
    • Real-time notifications when needed items appear
    • Tracks building materials, pallets, equipment, and more
    • Scheduled hourly checks for new listings

🏒 Norwegian Business Tools

  • Accounting Standards

    • NS 4102 (private sector)
    • DFØ standard (government)
    • Automatic chart of accounts import
  • Government Services

    • Skatteetaten API integration
    • Employee registration
    • Tax report submission
    • Deadline monitoring
  • Municipal Services

    • Building permit applications
    • Property upgrade requests
    • Renovation permits
  • Norwegian Support Programs Index ⭐ NEW!

    • Comprehensive database of grants and deductions (stΓΈtte og fradrag)
    • Support for private persons, companies, housing, and farms
    • Enova stΓΈtte programs (energy efficiency, solar, heat pumps)
    • Kommune support and building permits (byggesΓΈknad)
    • Tax deductions from Skatteetaten (BSU, etc.)
    • Husbanken loans and grants
    • Innovasjon Norge business support
    • Agricultural support from Landsbruksdirektoratet
    • Kommune newsletter tracking with highlighted news
    • Search and filter by entity type, provider, category
    • Detailed requirements and document lists

πŸ€– MCP Server (AI Integration)

The MCP server exposes ERPNext operations to AI models:

Built-in Tools:

  • Inventory queries (natural language)
  • Item creation and management
  • Receipt processing
  • Price comparison
  • Route optimization
  • Marketplace posting

Dynamic Tools:

  • Create custom tools via UI
  • Non-programmer friendly
  • Automatic registration
  • Parameter validation

πŸ“ Technical Documentation

  • RDS 81346 - Reference designation system
  • S1000D Issue 6 - Technical publication standard
  • GitHub Integration - Repository as asset management

πŸš€ Installation

Prerequisites

  • Frappe/ERPNext v15+
  • Python 3.10+
  • bench CLI tool

Quick Install

# Navigate to your bench directory
cd $PATH_TO_YOUR_BENCH

# Get the app
bench get-app https://github.com/minfuel/assist.git

# Install on your site
bench --site your-site-name install-app assist

# Install Python dependencies
cd apps/assist
pip install -r requirements.txt

# Restart services
bench restart

Optional Dependencies

Install based on features you need:

# Image processing (background removal, enhancement)
pip install rembg pillow

# MCP server (AI integration)
pip install "mcp[cli]"

# OCR capabilities (receipt scanning)
pip install pytesseract

# All optional features
pip install -e ".[all]"

Verifying Installation

# Check app is installed
bench --site your-site-name list-apps

# Run in console to test
bench --site your-site-name console
>>> import assist
>>> assist.__version__
'0.0.1'

πŸ”„ Migration from Assist-v0

If you're upgrading from the old erpnext_assist app:

Migration Steps

# 1. Backup your site (IMPORTANT!)
bench --site your-site-name backup --with-files

# 2. Uninstall old version
bench --site your-site-name uninstall-app erpnext_assist

# 3. Get new version
bench get-app https://github.com/minfuel/assist.git

# 4. Install new version
bench --site your-site-name install-app assist

# 5. Install dependencies
cd apps/assist
pip install -r requirements.txt

# 6. Restart services
bench restart

What's Preserved

βœ… All custom doctypes and their data
βœ… Marketplace listings
βœ… Tool drafts
βœ… Configuration settings

What Changed

  • App name: erpnext_assist β†’ assist
  • Import paths updated
  • Enhanced documentation
  • Optional dependency structure

See MIGRATION.md for detailed migration guide.


πŸ“š API Endpoints

All endpoints are whitelisted and accessible via REST API.

Image Processing

# Remove background from image
POST /api/method/assist.api.remove_image_background
{
    "image_data": "base64_string",
    "enhance": true,
    "use_altlokalt_api": false
}

# Enhance image quality
POST /api/method/assist.api.enhance_image
{
    "image_data": "base64_string",
    "brightness": 1.1,
    "contrast": 1.1,
    "sharpness": 1.2
}

Item Management

# Quick add item with camera
POST /api/method/assist.api.quick_add_item
{
    "image_data": "base64_string",
    "warehouse": "Main Warehouse",
    "item_group": "Products",
    "valuation_rate": 100.00,
    "remove_background": true,
    "enhance_image_quality": true
}

# Scan receipt and add items
POST /api/method/assist.api.scan_receipt
{
    "receipt_image": "base64_string",
    "add_as": "stock",
    "warehouse": "Main Warehouse"
}

Marketplace Operations

# Compare prices across vendors
POST /api/method/assist.api.compare_prices
{
    "item_name": "Product Name",
    "search_prisjakt": true
}

# Plan pickup route
POST /api/method/assist.api.plan_pickup_route
{
    "listings": ["listing-1", "listing-2"],
    "start_location": "Oslo",
    "preferred_date": "2026-01-20"
}

# Generate Google Maps route for multiple listings ⭐ NEW!
POST /api/method/assist.api.generate_marketplace_route
{
    "listing_ids": "[\"ML-00001\", \"ML-00002\", \"ML-00003\"]",
    "start_location": "Oslo, Norway"
}

# Auto photoshoot for rental items ⭐ NEW!
POST /api/method/assist.api.auto_photoshoot_rental_item
{
    "listing_id": "ML-00001",
    "remove_background": true,
    "enhance_image": true,
    "num_angles": 4
}
# Run marketplace hustle routine (manual trigger)
POST /api/method/assist.api.run_marketplace_hustle_routine
{}

# Get marketplace hustle routine status
POST /api/method/assist.api.get_marketplace_hustle_status
{}

Norwegian Business

# Import Norwegian chart of accounts
POST /api/method/assist.api.import_norwegian_accounts
{
    "standard": "NS4102",  # or "DFO"
    "company": "Your Company"
}

# Interact with Skatteetaten
POST /api/method/assist.api.interact_with_skatteetaten
{
    "action": "employee_registration",
    "data": "{...}"
}

# Get Norwegian support programs
POST /api/method/assist.api.get_norwegian_support_programs
{
    "entity_type": "private_person",  # or "company", "housing", "farm"
    "provider": "Enova",
    "category": "Energi"
}

# Get Enova support programs
POST /api/method/assist.api.get_enova_support_programs
{}

# Search support programs
POST /api/method/assist.api.search_support_programs
{
    "search_term": "varmepumpe"
}

# Get kommune newsletters
POST /api/method/assist.api.get_kommune_newsletters
{
    "kommune": "Oslo",
    "is_highlighted": true
}

See assist/api.py for complete endpoint documentation.


πŸ› οΈ Configuration

Hooks Configuration

Configure the app through ERPNext's hooks system in hooks.py:

# Example: Add custom scheduled tasks
scheduler_events = {
    "daily": [
        "assist.tasks.sync_marketplace_listings"
    ]
}

# Example: Add custom API overrides
override_whitelisted_methods = {
    "frappe.desk.get_items": "assist.api.get_enhanced_items"
}

App Settings

Configure via Desk β†’ Setup β†’ System Settings or create custom settings doctypes.

Using the Marketplace Hustle Routine

The marketplace hustle routine automatically monitors marketplace listings and matches them with your needs:

  1. Create Saved Searches:

    • Navigate to Assist Tools β†’ Saved Marketplace Search
    • Create a new search with your query (e.g., "byggningsmaterialer", "paller")
    • Select the marketplace (Facebook Marketplace or FINN.no)
    • Choose search type:
      • material_request: Matches against open Material Requests
      • purchase_request: Also matches against open Material Requests
    • Mark as active
  2. The routine automatically:

    • Runs every hour via scheduled task
    • Fetches new items matching your saved searches
    • Compares items with open Material Requests and Tasks
    • Creates notifications when matches are found
    • Adds comments to matched documents with item details and links
  3. Manual Trigger:

    • Use API endpoint: assist.api.run_marketplace_hustle_routine
    • Or via MCP tools in AI assistants
  4. Monitor Status:

    • Use API endpoint: assist.api.get_marketplace_hustle_status
    • View saved searches to see last checked time and results found

πŸ§ͺ Development

Setup Development Environment

# Clone and setup
cd ~/frappe-bench/apps
git clone https://github.com/minfuel/assist.git
cd assist

# Install pre-commit hooks
pre-commit install

# Install in development mode
pip install -e ".[all]"

Code Quality Tools

Pre-commit runs these checks automatically:

  • ruff - Fast Python linter and formatter
  • eslint - JavaScript linting
  • prettier - Code formatting
  • pyupgrade - Python syntax modernization

Running Tests

# Run all tests
bench --site your-site-name run-tests --app assist

# Run specific test
bench --site your-site-name run-tests --app assist --module assist.tests.test_api

Running the MCP Server

# Development mode
cd apps/assist/assist/mcp_server
mcp dev server.py

# Production mode
mcp run server.py

Project Structure

assist/
β”œβ”€β”€ assist/              # Main app module
β”‚   β”œβ”€β”€ api.py          # API endpoints (18 methods)
β”‚   β”œβ”€β”€ hooks.py        # Frappe hooks configuration
β”‚   β”œβ”€β”€ assist_tools/   # Custom doctypes
β”‚   β”‚   └── doctype/
β”‚   β”‚       β”œβ”€β”€ assist_tool_draft/
β”‚   β”‚       β”œβ”€β”€ marketplace_listing/
β”‚   β”‚       └── ...
β”‚   β”œβ”€β”€ config/         # Desktop and module config
β”‚   β”œβ”€β”€ mcp_server/     # MCP server implementation
β”‚   β”œβ”€β”€ utils/          # Utility functions
β”‚   β”‚   └── image_processing.py
β”‚   β”œβ”€β”€ public/         # Static assets
β”‚   └── templates/      # Jinja templates
β”œβ”€β”€ pyproject.toml      # Python package configuration
β”œβ”€β”€ requirements.txt    # Python dependencies
└── README.md          # This file

πŸ“– Documentation

Additional Resources


🀝 Contributing

We welcome contributions! Here's how:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and linting (pre-commit run --all-files)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Coding Standards

  • Follow PEP 8 for Python code
  • Use type hints where applicable
  • Write docstrings for all public methods
  • Add tests for new features
  • Update documentation as needed

πŸ“‹ Roadmap

  • Enhanced AI model integration
  • Support for more marketplaces (eBay, Amazon)
  • Advanced inventory forecasting
  • Multi-language support
  • Mobile app companion
  • Real-time price tracking dashboard
  • Automated vendor negotiations

⚠️ Known Issues

  • Image processing requires significant memory for large images
  • Some Norwegian services may require additional authentication
  • MCP server needs separate port for AI model communication

πŸ”’ Security

  • Never commit API keys or credentials
  • Use environment variables for sensitive data
  • Follow ERPNext security best practices
  • Regularly update dependencies

To report security vulnerabilities, email: kontakt@drivstoffapp.no


πŸ“„ License

MIT License - see license.txt for details.


πŸ™ Credits & Acknowledgments

Current Maintainer: sm norge
Email: kontakt@drivstoffapp.no
Repository: https://github.com/minfuel/assist

Original Author (v0): samletnorge

Built With:

Special Thanks:

  • The Frappe/ERPNext community
  • Contributors to the MCP specification
  • Norwegian business standards organizations

⬆ back to top

Made with ❀️ in Norway πŸ‡³πŸ‡΄

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages