Skip to content

aleksandrvasilyev/xero-open-ai-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xero API + OpenAI + Redis + Typescript Demo

Overview

This is a backend API application that allows users to:

  • Authenticate via Xero API using OAuth2.
  • Retrieve information about their tenants (organizations in Xero).
  • Fetch a list of invoices from a specific tenant.
  • Analyze invoices using OpenAI API to suggest invoice categories based on descriptions.

Why Redis?

Redis is used for storing user sessions after authentication with Xero API.

Technologies Used

  • Node.js + Express.js
  • TypeScript
  • Xero API (OAuth2 authentication, invoice management)
  • OpenAI API (AI-powered invoice analysis)
  • Redis (Session storage)

List of endpoints

Method Endpoint Description
GET /api/xero/connect Start OAuth login with Xero
GET /api/xero/callback Handle OAuth callback, create session
GET /api/xero/about Get details about authenticated tenant
GET /api/xero/invoices Fetch list of invoices from Xero
GET /api/xero/invoices/analyze Analyze invoices using OpenAI (categorization)

Installation

To run the project locally:

  1. Clone the repository:

    git clone https://github.com/aleksandrvasilyev/xero-open-ai-redis.git
  2. Open application folder:

    cd xero-open-ai-redis
  3. Install dependencies:

    npm install
  4. Copy file .env.example to .env:

    cp .env.example .env
  5. Add your variables into the .env file:

    XERO_CLIENT_ID=your_xero_client_id
    XERO_CLIENT_SECRET=your_xero_client_secret
    OPENAI_API_KEY=your_openai_api_key
    XERO_REDIRECT_URI=http://localhost:3008/api/xero/callback
    PORT=3008
    SESSION_SECRET=test123
  6. Redis setup:

    Option 1: install redis manually:

    Mac OS:

    brew install redis
    redis-server

    Linux (Debian/Ubuntu):

    sudo apt-get install redis
    sudo systemctl enable redis
    sudo systemctl start redis

    Option 2: Run Redis using Docker:

    docker run --name redis -p 6379:6379 -d redis:latest
  7. Start the server:

    npm run dev
  8. Open link in your browser - http://localhost:3008/api/xero/connect

  9. Once authenticated, you can access other endpoints like:

  • /api/xero/about
  • /api/xero/invoices
  • /api/xero/invoices/analyze

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published