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.
Redis is used for storing user sessions after authentication with Xero API.
- Node.js + Express.js
- TypeScript
- Xero API (OAuth2 authentication, invoice management)
- OpenAI API (AI-powered invoice analysis)
- Redis (Session storage)
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) |
To run the project locally:
-
Clone the repository:
git clone https://github.com/aleksandrvasilyev/xero-open-ai-redis.git
-
Open application folder:
cd xero-open-ai-redis
-
Install dependencies:
npm install
-
Copy file .env.example to .env:
cp .env.example .env
-
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
-
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
-
Start the server:
npm run dev
-
Open link in your browser - http://localhost:3008/api/xero/connect
-
Once authenticated, you can access other endpoints like:
- /api/xero/about
- /api/xero/invoices
- /api/xero/invoices/analyze