This coding challenge asks you to build an intelligent invoice parser using the OpenAI API. Your task is to develop a TypeScript application that can extract structured data from raw invoice text using OpenAI's language models.
- Create a TypeScript application that parses invoice text using OpenAI.
- Implement a solution that extracts structured data including:
- Invoice number
- Invoice date
- Due date
- Vendor information
- Customer information
- Line items (description, quantity, unit price, amount)
- Invoice totals (subtotal, tax, total amount)
- Currency
- Payment terms
- Handle various invoice formats gracefully.
- Include proper error handling and validation.
- Must use TypeScript with proper typing.
- Must use OpenAI's API with structured outputs (JSON response format).
- Write clean, maintainable code with appropriate documentation.
- Include comprehensive unit tests using Jest.
- Provide clear instructions for running your application.
- Node.js (v14 or higher)
- npm or yarn
- OpenAI API key
# Clone the repository
git clone [repository-url]
cd invoice-parser-challenge
# Install dependencies
npm install
# Set up your OpenAI API key
# Copy the .env.template to .env and add your API key
cp .env.template .env
# Edit the .env file to add your actual API key
# OPENAI_API_KEY=your_api_key_here
# Build the TypeScript code
npm run build
# Run the application
npm start
# Run in development mode (with ts-node)
npm run dev
npm test
An example implementation is provided in the src
directory with a basic invoice parser class and corresponding unit tests. This is intended to give you a starting point, but you should extend and improve upon it to create a robust solution.
Your submission will be evaluated based on:
- Correctness: Does the parser accurately extract invoice data?
- Code Quality: Is the code well-structured, cleanly written, and properly documented?
- TypeScript Usage: Is TypeScript properly utilized with appropriate typing?
- Error Handling: How well does the application handle edge cases and errors?
- Testing: Are there comprehensive tests that cover the functionality?
- API Usage: Is the OpenAI API used efficiently and effectively?
- Create a private GitHub repository with your implementation.
- Include a README with instructions for running your code and any additional notes.
- Share access with [reviewer's GitHub username].
This challenge is designed to be completed within a 45-minute interview session. Focus on a simple, functioning solution that demonstrates your understanding of TypeScript and the OpenAI API.