Skip to content

A nestjs api wich handles transaction made from my iphone and pushes it into a database and speadsheet

Notifications You must be signed in to change notification settings

floriankyn/expense-api

Repository files navigation


NestJS Logo

A NestJS API for logging iPhone payments to MongoDB and Google Sheets
Efficient, serverless transaction tracking powered by Google Cloud Run and Shortcut automations.

NPM Version License Discord Twitter Follow


🚀 Overview

This NestJS API serves as a serverless backend that enables:

  • Generating access tokens via API keys.
  • Receiving transaction data from an iOS Shortcut automation after Apple Pay events.
  • Storing transactions in MongoDB.
  • Appending them to a Google Spreadsheet.

Hosted on Google Cloud Run, it's fully scalable and optimized for event-driven usage.


🧰 Tech Stack

  • Framework: NestJS
  • Database: MongoDB
  • Spreadsheet Integration: Google Sheets API
  • Hosting: Google Cloud Run
  • Automation Trigger: Apple Shortcuts (on iPhone)

📦 Installation

npm install

🛠️ Running the Project

# Development mode
npm run start

# Watch mode
npm run start:dev

# Production build
npm run start:prod

🧪 Testing

# Unit tests
npm run test

# End-to-end tests
npm run test:e2e

# Test coverage
npm run test:cov

🔐 Usage

  1. Request Access Token

Send a POST request with your API key:

POST /auth/login
Content-Type: application/json

{
  "secret_token": "your-api-key"
}

Response:

{
  "access_token": "eyJhbGciOiJIUzI1NiIs..."
}
  1. Send a Transaction

Your iOS Shortcut sends a POST request like this:

POST /transactions
Authorization: Bearer <access_token>
Content-Type: application/json

{
    "amount": 4.47,
    "card": "Swile",
    "currency": "EUR",
    "date": "2025-05-05",
    "location": "Dijon, Bourgogne-Franche-Compté",
    "store": "ALDI"
}

🧾 Data Flow

  1. Shortcut automation triggers payment event.
  2. Sends data with the access token to the API.
  3. Transaction is saved to MongoDB.
  4. A new row is appended to your Google Spreadsheet.

System Architecture Diagram

---

🚀 Deployment

This API runs on Google Cloud Run:

  1. Build Docker image:

    docker build -t gcr.io/YOUR_PROJECT_ID/your-app-name .
  2. Push to Google Container Registry:

    docker push gcr.io/YOUR_PROJECT_ID/your-app-name
  3. Deploy:

    gcloud run deploy your-app-name \
      --image gcr.io/YOUR_PROJECT_ID/your-app-name \
      --platform managed \
      --region YOUR_REGION \
      --allow-unauthenticated

📚 Resources


🤝 Contributing

Feel free to submit issues, suggest improvements, or fork and PR. The project welcomes any community input that improves reliability or usability.


📄 License

This project is MIT licensed.

About

A nestjs api wich handles transaction made from my iphone and pushes it into a database and speadsheet

Topics

Resources

Stars

Watchers

Forks