Introduction

Overview of the unified backend service powering the application with Move blockchain, IPFS storage, AI chat, and database functionality.

Created: 12/17/2025

The application utilizes a unified backend service (apps/ai) that consolidates all backend functionality into a single, cohesive Express server. This unified approach simplifies deployment, reduces operational complexity, and enables better integration between services.

Unified Backend Architecture

The consolidated backend (apps/ai) provides a comprehensive API that encompasses all backend functionality:

Core Services

  • Move Blockchain (/api/move): Handles interactions with the Movement testnet using the Aptos SDK
  • IPFS Storage (/api/ipfs): Manages decentralized file storage with Helia IPFS node
  • AI Chat (/api/ai): Provides streaming AI conversations using OpenAI GPT-4o-mini
  • Database (/api/database): Handles data synchronization and persistence with PostgreSQL + Drizzle ORM
  • Notifications (/api/notifications): Manages push notification delivery via Expo Server SDK
  • Authentication (/api/auth): User registration, device management, and Privy token validation
  • Activity Tracking (/api/heartbeat): Monitors user activity and device status

Key Features

  • Single Deployment: One Express server running on port 3005 (configurable)
  • Shared Authentication: Unified Privy-based authentication across all services
  • Performance Tracking: Built-in timing middleware for monitoring API performance
  • Database Integration: PostgreSQL database with user data, devices, and notification tokens
  • IPFS Node: Local Helia IPFS node for decentralized storage
  • Push Notifications: Expo Server SDK for cross-platform push delivery
  • Activity Monitoring: Automated cleanup of inactive devices and sessions

Deployment and Interaction

The unified backend is built as a single Express server, making deployment straightforward to cloud providers (e.g., Fly.io, Railway, or AWS).

Key Benefits

  1. Simplified Operations: Single deployment instead of multiple services
  2. Shared Resources: Common authentication, database, and performance monitoring
  3. Better Integration: Services can share data and coordinate through the database
  4. Reduced Latency: Local service communication instead of network calls
  5. Unified Logging: Centralized logging and error tracking

Security Considerations

The unified backend implements comprehensive security measures:

  • Privy Authentication: All API endpoints validate Privy access tokens
  • Database Security: Row Level Security (RLS) ensures users can only access their own data
  • IPFS Protection: API key authentication for IPFS operations
  • Rate Limiting: Recommended for production deployments
  • Activity Cleanup: Automatic removal of stale device tokens and sessions

Migration Notes

While the unified backend (apps/ai) is now the recommended approach, standalone backends still exist:

  • apps/backend: Legacy Move blockchain service
  • apps/ipfs: Legacy IPFS storage service

These can be used independently if needed, but the unified backend provides better integration and simpler operations.

The following sections detail the implementation and usage of each service within the unified backend.