SmartSuite Integration
SmartSuite is used as a user directory/team management system that stores user information including names, emails, tags, and team assignments.
Overview
SmartSuite is integrated with sprout_backend to:
- Store user information (name, email, tag, teams)
- Provide team membership data (Acquisitions, Fulfillment)
- Supply user tags for identification
- Cache user data for quick lookups
Configuration
SmartSuite is configured via environment variables:
SMARTSUITE_WORKSPACE_ID- SmartSuite workspace identifierSMARTSUITE_API_KEY- API key for authentication
Integration Points
sprout_backend
The backend integrates with SmartSuite via SmartSuiteService:
Location: src/smartsuite/smartsuite.service.ts
Functionality:
- Fetches user data from SmartSuite
- Maps users to teams (Acquisitions, Fulfillment)
- Provides user tags for identification
- Caches user data for performance
API Integration
Endpoint: https://app.smartsuite.com/api/v1/applications/{tableId}/records/list/
Authentication:
account-idheader: Workspace IDAuthorizationheader:Token {API_KEY}
Table IDs:
- Users table:
67915e92e496f1b188008e8c - Team field:
sbdbe1af1f - Tag field:
s1548322a5 - Email field:
sbc2f61722
User Management
User Structure
interface SmartSuiteUser {
name: string;
email: string;
tag: string;
teams: string[];
}
Teams
Teams are mapped from SmartSuite team IDs:
9nZGP→Acquisitions0O85z→Fulfillment
Usage in Backend
The service provides:
getSmartSuiteUsers()- Get all users (cached)getUserTag(email)- Get user tag by emailgetTeamsForUser(email)- Get teams for a user
Caching
User data is cached in Redis to reduce API calls:
- Cache key:
smartSuiteUsers - Cache duration: Configured in CacheService
Development Users
For development, hardcoded users are included:
- Matthew Freire (
matthew@sproutproperties.co)- Tag:
smeyers - Teams:
['Acquisitions', 'Fulfillment']
- Tag:
Usage in Application
Authentication (auth.controller.ts)
The /auth/me endpoint uses SmartSuite to:
- Get user teams (returned as
roles) - Get user tag (username identifier)
- Enrich user profile data
Ticket Management (ticket.controller.ts)
Used when creating purchase assignments to:
- Get user tag (username) for the authenticated user
- Validate user exists in SmartSuite
- Associate purchases with user tags
Data Flow
- On Startup:
SmartSuiteService.onModuleInit()fetches all users from SmartSuite API - Caching: User data is stored in Redis cache (key:
smartSuiteUsers) - Lookups: All user queries use cached data for performance
- Refresh: Cache is refreshed on application restart
API Methods
getSmartSuiteUsers()- Get all users (from cache)fetchSmartSuiteUsers()- Fetch users from SmartSuite APIgetUserTag(email)- Get user tag by emailgetTeamsForUser(email)- Get teams for a user by email
Access
Access SmartSuite at: https://app.smartsuite.com
References
- Environment Variables - Configuration
- sprout_backend Repository - Backend integration