TatvaScan is a web application that lets users scan ingredients from images using OCR (Tesseract.js) and checks them for safety or allergens using a powerful LLM backend like Gemini.
- 📁 Upload image or 📸 capture via camera
- 🔍 OCR-based ingredient extraction
- 🧠 LLM-powered ingredient safety check
- 🧼 Clean UI with Markdown rendering
- 📱 Mobile-friendly and responsive
- Frontend: HTML, JSP, Bootstrap, JavaScript, Tesseract.js, Marked.js
- Backend: Java Servlet
- OCR Engine: Tesseract.js (browser-based)
- LLM Integration: Gemini (via API in Servlet)
- Server: Apache Tomcat
- Build Tool: Maven
Make sure you have the following installed:
- Java JDK 8 or later
- Apache Maven
- Apache Tomcat (v9 or v10 recommended)
- Git (optional, for cloning)
git clone https://github.com/0xVish/tatvascan.git
cd tatvascan
Instead of using a
.env
file, this project uses system environment variables for API keys and other secrets.
Set these environment variables in your terminal session or OS-level settings:
export TATVASCAN_GEMINI_API_KEY=your_gemini_api_key
set TATVASCAN_GEMINI_API_KEY=your_gemini_api_key
Make sure this is set before running the app. You can also add it permanently via .bashrc
, .zshrc
, or Windows Environment Variable GUI.
mvn clean package
This will generate a .war
file in the target/
directory.
- Copy the generated WAR file (
target/tatvascan.war
) into your Tomcat'swebapps/
directory. - Start/restart the Tomcat server.
- Copy the entire
target/tatvascan/
folder into Tomcat'swebapps/
directory. - Ensure the structure remains intact (
WEB-INF
,index.jsp
, etc.).
After starting Tomcat, visit:
http://localhost:8080/tatvascan
Upload & Capture | Ingredient Analysis |
---|---|
GeminiServlet.java
: Handles POST request with OCR text and queries the Gemini API for analysis.- Tesseract.js runs completely in-browser for privacy and speed.
- Ingredients are sanitized and passed as Markdown for rich output formatting.
- OCR not working? Check console for
Tesseract
errors. - No response from backend? Ensure environment variable
GEMINI_API_KEY
is set and servlet is mapped correctly. - Tomcat not deploying? Make sure the WAR or folder is correctly placed under
webapps
.
Made with ☕, 🧠 and 💡 by 0xVish
MIT License