Skip to content
TheChatArchiveThe Chat Archive
chatgpt-4o-latest-20250326· OpenAIHugging Face LMArena Human Preference 140K

I want a see a full stack preview

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Qwenqwen3-235b-a22b-no-thinking’s answer.
  1. User

    I want a see a full stack preview

  2. Assistant

    Absolutely! Let's walk through a working full-stack invoice parsing preview using basic technologies so you can see it in action locally. This version will:

    • Use a simple React frontend for uploading invoices
    • Have an Express.js backend to handle file uploads
    • Use a Python microservice to extract text from invoices using Tesseract OCR
    • Show parsed results on the frontend 🎉

    🌐 Project Structure Overview

    invoice-parser-app/
    │
    ├── frontend/             # React Frontend
    │
    ├── backend/              # Node.js + Express backend
    │
    └── parser-service/       # Python parsing (Flask + Tesseract)
    

    🔧 Step-by-Step Demo Setup


    1️⃣ Backend – Express.js API (Node.js)

    📁 invoice-parser-app/backend

    Install dependencies:

    mkdir backend && cd backend
    npm init -y
    npm install express multer cors axios
    

    ✅ Create index.js

    const express = require('express');
    const multer = require('multer');
    const cors = require('cors');
    const axios = require('axios');
    const fs = require('fs');
    const path = require('path');
    
    const app = express();
    app.use(cors());
    app.use(express.json());
    
    const upload = multer({ dest: 'uploads/' });
    
    app.post('/upload', upload.single('invoice'), async (req, res) => {
        const filePath = path.resolve(__dirname, req.file.path);
    
        try {
            const response = await axios.post('http://localhost:5000/parse', { path: filePath });
            res.json(response.data);
        } catch (err) {
            res.status(500).json({ error: 'Parsing Service Error', details: err.message });
        }
    });
    
    app.listen(4000, () => console.log("🚀 Backend running on http://localhost:4000"));
    

    2️⃣ Python Service – Invoice Parser (Flask + Tesseract)

    📁 invoice-parser-app/parser-service

    Create virtual env and install dependencies:

    cd ../parser-service
    python3 -m venv venv
    source venv/bin/activate
    pip install flask pytesseract pillow
    

    🔧 Make sure you have Tesseract installed:

    • Linux: sudo apt install tesseract-ocr
    • macOS: brew install tesseract
    • Windows: Use this guide

    ✅ Create app.py

    from flask import Flask, request, jsonify
    import pytesseract
    from PIL import Image
    import os
    
    app = Flask(__name__)
    
    @app.route('/parse', methods=['POST'])
    def parse_invoice():
        data = request.get_json()
        image_path = data.get('path')
    
        if not os.path.exists(image_path):
            return jsonify({"error": "File not found"}), 400
    
        text = pytesseract.image_to_string(Image.open(image_path))
    
        # Simple keyword extraction (can integrate NLP)
        invoice_data = {
            "invoice_number": "NA",
            "date": "NA",
            "total_amount": "NA",
            "raw_text": text
        }
    
        # Dummy rule-based parsing
        lines = text.split('\n')
        for line in lines:
            if 'invoice' in line.lower() and any(char.isdigit() for char in line):
                invoice_data["invoice_number"] = line.strip()
            if 'total' in line.lower() and '$' in line:
                invoice_data["total_amount"] = line.strip()
    
        return jsonify(invoice_data)
    
    if __name__ == '__main__':
        app.run(port=5000, host='0.0.0.0')
    

    3️⃣ Frontend – React App

    📁 invoice-parser-app/frontend

    npx create-react-app frontend
    cd frontend
    npm install axios
    

    ✅ Update src/App.js

    import React, { useState } from 'react';
    import axios from 'axios';
    import './App.css';
    
    function App() {
      const [file, setFile] = useState();
      const [data, setData] = useState(null);
    
      const handleUpload = async () => {
        const formData = new FormData();
        formData.append('invoice', file);
    
        const response = await axios.post('http://localhost:4000/upload', formData, {
          headers: { 'Content-Type': 'multipart/form-data' }
        });
    
        setData(response.data);
      };
    
      return (
        <div className="App">
          <h2>🧾 Invoice Parser</h2>
          <input type="file" onChange={(e) => setFile(e.target.files[0])} />
          <button onClick={handleUpload}>Upload Invoice</button>
    
          {data && (
            <div style={{ textAlign: 'left', marginTop: 20 }}>
              <p><strong>Invoice Number:</strong> {data.invoice_number}</p>
              <p><strong>Total Amount:</strong> {data.total_amount}</p>
              <pre style={{ background: "#f0f0f0", padding: "10px" }}>
                {data.raw_text}
              </pre>
            </div>
          )}
        </div>
      );
    }
    
    export default App;
    

    🚀 Running the Full Stack App Locally

    1. Start Python Flask service:

    cd parser-service
    source venv/bin/activate
    python app.py
    

    2. Start Express Backend

    cd ../backend
    node index.js
    

    3. Start React Frontend

    cd ../frontend
    npm start
    

    ✅ Final Outcome

    • Visit: http://localhost:3000
    • Upload an image invoice (PNG, JPG, etc.)
    • See extracted invoice number, total, and raw OCR text 🎉

    🧠 Next Steps (Optional Enhancements)

    FeatureDescription
    👓 Advanced NLPUse spaCy/transformers to extract structured fields
    📄 PDF ParsingUse pdf2image in Python to convert invoices into images
    📦 DockerizeMake the 3 services run in Docker containers
    💾 DatabaseStore invoice metadata like date, customer, total, etc.
    👤 Auth SupportUse Firebase/Auth0/JWT for user authentication

    Would you like this project packaged into a GitHub repo, or maybe a Docker Compose setup for easier running? I can provide that too.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.