How ricartesamuel/cassaco-scan works
Project type and purpose
• Cassaco Scan is a single-page web application (SPA) that runs entirely in the browser.
• It captures or uploads an image of a menu, performs OCR on that image with Tesseract.js, and then sends the extracted text to the OpenAI GPT-4 API to receive a structured JSON response.
• There is no custom backend server; Node.js is used only for local development, build and CSS processing.
File structure
• Root
• index.html: entry point / UI skeleton
• package.json, postcss.config.js, tailwind.config.js: build and CSS pipeline configs
• assets/: static images (logo)
• src/
– app.js: main application logic (UI event handling, OCR invocation, API calls)
– util.js: helper functions (e.g., image preprocessing, fetch wrappers)
– styles.css: Tailwind-based styling
• Dist (not shown above but mentioned in README) contains the compiled CSS for production.
Key architectural insights from README
• Front-end technologies: HTML, CSS (Tailwind + PostCSS), vanilla JS
• OCR engine: Tesseract.js running in the client
• External AI service: OpenAI GPT-4 API via HTTPS
• Local dev: Node.js + npm for “npm run dev” and “npm run build”
a. Main components
• Browser / Client
• UI Layer (HTML + CSS + JS)
• OCR Engine (Tesseract.js library)
• OpenAI GPT-4 API (external service)
• Build Pipeline (Node.js, PostCSS, Tailwind CSS, dev server)
b. Relationships & interactions
1. User opens index.html in browser
2. UI layer loads app.js, styles.css
3. User clicks “Take Photo” or “Upload Image” → browser camera/File API
4. app.js passes image blob to Tesseract.js → OCR text
5. app.js formats text and POSTs to OpenAI API endpoint → receives JSON metadata
6. UI displays JSON; user may copy or reset
c. Architectural patterns / design principles
– Client-centric processing: all business logic and OCR run in the browser
– External API integration: thin client uses fetch() for AI calls
– Build pipeline separated from runtime: dev/build with Node.js, production ship static files
d. Key technologies
– Tailwind CSS & PostCSS (style preprocessing)
– Tesseract.js (in-browser OCR)
– OpenAI REST API (GPT-4)
– Vanilla JS modules (app.js, util.js)