Invoicelytics is a product that is meant to make it much easier working with invoices. All you need to do is uploading invoices in PDF format into Invoicelytics. Once that's done, you can ask questions about the invoices, such as:
- how much have I spent in the last 30 days?
- how many invoices coming from company ABC have been uploaded?
- how much money is due to company ABC?
In a nutshell, Invoicelytics is a monolithic app that, behind the scenes, runs an async AI inference pipeline, which is implemented using Temporal workflows.
- Make sure you have Python installed and Docker installed
- Open a shell, browse to this repository's root folder and run
docker compose up-d. This will spin up a local instance of Postgres. - Install and spin up Temporal
- Install Poetry
- Run
poetry install - Then run
poetry shellto activate the environment - Now let's initialize the database structure. Run
yoyo applyand keep hittingyuntil all database migrations are applied to your local database. - Notice that the migration scripts already created an initial entry in the
tenantstable for you. Let's also add a user, as you'll need credentials to enter the app. Open thescripts/insert_user.pyscript, adjust it to your emails address and preferred password, and run it withpython3 scripts/insert_user.py - Create a file called
.envto hold the environment variables. Copy the values provided in.env.example. Make sure to create a folder called/tmp/invoicelytics. - Still on
.env, you're gonna need to provide anOPENAI_API_KEY. You can follow these instructions to obtain an API key. - Before running the app, you'll also need to set up an environment variable in the shell:
export FLASK_APP=invoicelytics/run.py - To start the app, run
poetry run python -m flask run. The app should be available at http://127.0.0.1:5000 or http://localhost:5000 . - Use the credentials you created earlier and voilà, you're ready to use the product!
Due to personal budget restrictions, this repo is meant to be ran in local environments only
- Browse to http://127.0.0.1:5000/
- Login using the credentials you created earlier.
- Use the navigation menu and browse to
Invoices(top right corner of the screen). - In this screen, you'll see information about all invoices that have been uploaded into the system, as well as invoices that are pending approval.
- Click on
Upload an invoiceand select the invoice you'd like to work on (IMPORTANT: the system only accepts invoices in PDF format). - Once you upload the invoice, it's going to be processed in background. In the meanwhile, you can go back to the
Invoicespage while Emma, our Intelligent Assistant, works on it. - Once Emma finishes her job, you'll see the new invoice under the
Invoices pending approvalsection. You can click onReviewto check its details. - At the invoice detail page, you can review if Emma did a good job and extracted the data correctly from the invoice. You can edit the data and either approve or reject it.
- Once the invoice is approved, you can browse to
Chatand ask Emma questions about the approved invoices, such asHow many invoices are there in the system?, orHow many invoices from vendor X are due this week?or any other questions about the invoices. - If you're curious about the workflow execution on Temporal, you can browse to http://localhost:8233/namespaces/default/workflows as well
This is the main application directory containing the core logic and functionality of the Invoicelytics project. It includes various submodules and components such as blueprints, services, repositories, and integrations.
- assistants: Contains modules related to assistant functionalities, such as data extraction and chat assistants.
- blueprints: Houses the Flask blueprints for different parts of the application, including authentication, chat, home, invoice, and health check routes.
- data_structures: Defines data structures used within the application, such as invoice data points and uploaded files.
- entities: Contains the domain entities and ORM models representing the database tables.
- integrations: Manages integrations with external services, such as OpenAI.
- repository: Implements the data access layer, providing repositories for various entities.
- services: Includes service classes that encapsulate business logic and operations.
- static: Contains static files like CSS, JavaScript, and images.
- support: Provides utility functions and helper classes used across the application.
- templates: Stores HTML templates for rendering the web pages.
- temporal: Holds the AI inference pipeline (workflows and activities), which is implemented using Temporal
Contains SQL migration scripts for setting up and updating the database schema.
Houses static assets such as CSS, JavaScript, and image files used in the web application.
Includes HTML templates used by Flask to render the web pages.