This web application allows users to upload multiple receipt images simultaneously. It leverages the Moonshot AI API to analyze each receipt, extract key data, and display the results in a structured, interactive table.
- User Authentication: Secure login with a default username and password.
- Multi-File Upload: Drag-and-drop interface for easy receipt image uploads.
- AI-Powered Extraction: Integrates with Moonshot AI for intelligent data extraction.
- Interactive Data Table: Displays extracted data in a structured, Excel-friendly format.
- Robust Error Handling: Manages API failures and malformed receipt data gracefully.
- Optimized for Vercel: Ready for easy deployment.
- Framework: Next.js (App Router)
- UI: React, Shadcn UI
- Styling: Tailwind CSS
- AI Integration: OpenAI SDK (for Moonshot AI compatibility)
- Deployment: Vercel
Follow these steps to set up and run the project locally.
- Node.js (v18 or later)
- npm, pnpm, or yarn
First, clone the repository and install the dependencies:
git clone <repository-url>
cd nextjs_documents
npm installCreate a .env.local file in the root of your project and add the following variables:
KIMI_API_KEY="your_moonshot_api_key_here"
KIMI_BASE_URL="https://api.moonshot.ai/v1"
KIMI_MODEL="your_moonshot_vision_model_name_here" # e.g., moonshot-v1-32k
DEFAULT_USERNAME="your_default_username"
DEFAULT_PASSWORD="your_default_password"To start the development server:
npm run devOpen http://localhost:3000/login in your browser to log in and start using the application.
npm run dev: Starts the development server with Turbopack.npm run build: Builds the application for production.npm run start: Starts the production server.npm run lint: Runs the ESLint code linter.
This project is optimized for deployment on Vercel.
Click the button above to deploy this project to Vercel. You will be prompted to enter the environment variables during the setup process.
AI Prompt Details
Task: Accurately extract structured information from receipt images and return it in a standardized JSON format.
Output Format: Return the output as a JSON object with the following structure:
{
"store_name": "string",
"country": "string",
"receipt_type": "string",
"address": "string",
"datetime": "YYYY.MM.DD HH:MM:SS",
"currency": "string",
"sub_total_amount": 0.00,
"total_price": 0.00,
"total_discount": 0.00,
"all_items_price_with_tax": true,
"payment_method": "card" | "cash" | "unknown",
"rounding": 0.00,
"tax": 0.00,
"taxes_not_included_sum": 0.00,
"tips": 0.00,
"items": [
{
"name": "string",
"quantity": 0.000,
"measurement_unit": "string",
"total_price_without_discount": 0.00,
"unit_price": 0.00,
"total_price_with_discount": 0.00,
"discount": 0.00,
"category": "string",
"item_price_with_tax": "True" | "False"
}
],
"taxs_items": [
{
"tax_name": "string",
"percentage": 0.00,
"tax_from_amount": 0.00,
"tax": 0.00,
"total": 0.00,
"tax_included": "True" | "False"
}
]
}Key Instructions:
- If no receipt is detected, return "Receipt not found."
- Handle multiple languages and scripts.
- Use "unknown" or "not available" for missing information.
- Concatenate multi-line item names.
- Extract only the main menu item name, not its components (e.g., for a McDonald's meal).
- Sum all tips and charity donations into the
tipsfield. - Standardize
datetimetoYYYY.MM.DD HH:MM:SS. - Item prices can be negative (e.g., for returns).
- Define tax details in the
taxs_itemsarray.