AppFolio Reference Architecture
Overview
Production architecture for property management integrations with the AppFolio Stack API. Designed for multi-property portfolios requiring real-time vacancy tracking, tenant lifecycle management, work order routing, and accounting reconciliation. Key design drivers: data freshness for leasing decisions, idempotent sync for financial accuracy, and tenant-facing portal responsiveness.
Prerequisites
- A provider-verified contract for endpoints, authentication, events (if any),
rate limits, data residency, and permitted downstream accounting/CRM effects.
- Separate staging and production environments with managed secrets, synthetic
fixtures, durable queues/idempotency stores, and named reconciliation owners.
- Data classification that limits dashboard and cache models to the smallest
permitted fields; tenant contact, payment, and balance data require separate
encrypted stores and access controls.
Instructions
- Build the contract-bound client and safe-read service layer first, with
endpoint budgets, minimized cache entries, and observability before adding
write or event processing.
- Enable provider events only after the contract and durable raw-body,
signature, persistence, and replay boundaries have been proven; otherwise
use bounded incremental reconciliation.
- Persist an idempotency/reconciliation record before any work-order,
accounting, tenant, or lease mutation and require explicit authorization.
- Validate the architecture in staging with synthetic data, a forced provider
failure, duplicate event/retry, and rollback rehearsal before promotion.
Architecture Diagram
Dashboard (React) ──→ Property Service ──→ Redis Cache ──→ AppFolio Stack API
↓ /properties
Queue (Bull) ──→ Sync Worker /tenants
↓ /leases
Event Handler ←── Provider events* /work-orders
↓ /bills
Accounting Sync ──→ QuickBooks/Xero
* Use provider events only when the active contract confirms their delivery
and security semantics; otherwise feed the queue from bounded reconciliation.
Service Layer
class PropertyService {
constructor(private client: AppFolioClient, private cache: CacheLayer) {}
async getPortfolioSummary(propertyIds: string[]): Promise<PortfolioSummary> {
const properties = await Promise.all(
propertyIds.map(id => this.cache.getOrFetch(`prop:${id}`, () => this.client.get(`/properties/${id}`)))
);
return { totalUnits: properties.reduce((sum, p) => sum + p.units.length, 0),
vacancyRate: this.calcVacancy(properties), pendingWorkOrders: await this.getPendingOrders(propertyIds) };
}
async routeWorkOrder(order: WorkOrderRequest): Promise<string> {
const property = await this.client.get(`/properties/${order.propertyId}`);
const vendor = this.selectVendor(property.region, order.category);
return this.client.post('/work-orders', { ...order, assigned_vendor: vendor });
}
}
Caching Strategy
const CACHE_CONFIG = {
properties: { ttl: 300, prefix: 'prop' }, // 5 min — changes infrequently
tenants: { ttl: 120, prefix: 'tenant' }, // 2 min — moderate churn
leases: { ttl: 60, prefix: 'lease' }, // 1 min — financial accuracy
workOrders: { ttl: 30, prefix: 'wo' }, // 30s — real-time tracking
vacancies: { ttl: 15, prefix: 'vacancy' }, // 15s — leasing speed matters
};
// Webhook-driven invalidation: AppFolio events flush matching cache keys immediately
Event Pipeline
class PropertyEventPipeline {
private queue = new Bull('appfolio-events', { redis: process.env.REDIS_URL });
async onWebhook(event: AppFolioEvent): Promise<void> {
await this.queue.add(event.type, event, { attempts: 3, backoff: { type: 'exponential', delay: 2000 } });
}
async processLeaseEvent(event: LeaseEvent): Promise<void> {
if (event.type === 'lease.signed') await this.updateVacancy(event.propertyId);
if (event.type === 'lease.terminated') await this.triggerMoveOutWorkflow(event);
}
async processWorkOrderEvent(event: WorkOrderEvent): Promise<void> {
if (event.status === 'completed') await this.reconcileVendorInvoice(event);
}
}
Data Model
interface Property { id: string; name: string; address: Address; units: Unit[]; region: string; }
interface TenantRef { id: string; leaseId: string; contactCiphertextRef: string; }
interface Lease { id: string; propertyId: string; unitId: string; tenantId: string; startDate: string; endDate: string; monthlyRent: number; status: 'active' | 'pending' | 'terminated'; }
interface WorkOrder { id: string; propertyId: string; unitId: string; category: 'plumbing' | 'electrical' | 'hvac' | 'general'; status: string; assignedVendor: string; }
Scaling Considerations
- Partition sync workers by property region to avoid cross-region API rate limits
- Use read replicas for dashboard queries; write path goes through event pipeline
- Batch tenant notifications (rent reminders, maintenance updates) via queue to avoid email rate limits
- Cache vacancy data aggressively — leasing agents hit this endpoint 10x more than any other
- Shard work order routing by property portfolio to enable independent scaling per management group
Error Handling
| Component |
Failure Mode |
Recovery |
| Property sync |
AppFolio 429 rate limit |
Exponential backoff with jitter, per-property circuit breaker |
| Lease webhook |
Duplicate event delivery |
Idempotency key on lease ID + event timestamp |
| Work order routing |
Vendor API timeout |
Queue retry with fallback to manual assignment |
| Accounting sync |
Balance mismatch |
Reconciliation queue with human review flag |
| Tenant portal |
Cache miss storm |
Stale-while-revalidate pattern, circuit breaker on API layer |
Output
- A contract-bound, staged architecture with service, cache, queue, data, and
reconciliation ownership explicitly separated
- Minimized dashboard references and encrypted/controlled boundaries for tenant
contact, payment, and balance data
- A deployment decision supported by staging failure, duplicate/replay, rate,
rollback, and reconciliation evidence
Examples
For a vacancy-dashboard rollout, start with synthetic property and unit IDs,
one bounded safe-read, and a cache that exposes data age. Inject a duplicate
event or reconciliation record, a 429, and a downstream accounting timeout
to prove the queue and idempotency store prevent duplicate effects. Promote
only when results remain complete and authorized and the rollback/reconciliation
owners can demonstrate their paths. If event support, data classification,
durable state, or a write outcome is unverified, keep the corresponding path
disabled and use operator-led reconciliation.
Resources
Next Steps
See appfolio-deploy-integration.
1---2name: appfolio-reference-architecture3description: Reference architecture for AppFolio property management integration. Trigger: "appfolio architecture".4license: MIT5---6# AppFolio Reference Architecture
7
8## Overview
9
10Production architecture for property management integrations with the AppFolio Stack API. Designed for multi-property portfolios requiring real-time vacancy tracking, tenant lifecycle management, work order routing, and accounting reconciliation. Key design drivers: data freshness for leasing decisions, idempotent sync for financial accuracy, and tenant-facing portal responsiveness.
11
12## Prerequisites
13
14- A provider-verified contract for endpoints, authentication, events (if any),
15 rate limits, data residency, and permitted downstream accounting/CRM effects.
16- Separate staging and production environments with managed secrets, synthetic
17 fixtures, durable queues/idempotency stores, and named reconciliation owners.
18- Data classification that limits dashboard and cache models to the smallest
19 permitted fields; tenant contact, payment, and balance data require separate
20 encrypted stores and access controls.
21
22## Instructions
23
241. Build the contract-bound client and safe-read service layer first, with
25 endpoint budgets, minimized cache entries, and observability before adding
26 write or event processing.
272. Enable provider events only after the contract and durable raw-body,
28 signature, persistence, and replay boundaries have been proven; otherwise
29 use bounded incremental reconciliation.
303. Persist an idempotency/reconciliation record before any work-order,
31 accounting, tenant, or lease mutation and require explicit authorization.
324. Validate the architecture in staging with synthetic data, a forced provider
33 failure, duplicate event/retry, and rollback rehearsal before promotion.
34
35## Architecture Diagram
36
37```
38Dashboard (React) ──→ Property Service ──→ Redis Cache ──→ AppFolio Stack API
39 ↓ /properties
40 Queue (Bull) ──→ Sync Worker /tenants
41 ↓ /leases
42 Event Handler ←── Provider events* /work-orders
43 ↓ /bills
44 Accounting Sync ──→ QuickBooks/Xero
45```
46
47`*` Use provider events only when the active contract confirms their delivery
48and security semantics; otherwise feed the queue from bounded reconciliation.
49
50## Service Layer
51
52```typescript
53class PropertyService {
54 constructor(private client: AppFolioClient, private cache: CacheLayer) {}
55
56 async getPortfolioSummary(propertyIds: string[]): Promise<PortfolioSummary> {
57 const properties = await Promise.all(
58 propertyIds.map(id => this.cache.getOrFetch(`prop:${id}`, () => this.client.get(`/properties/${id}`)))
59 );
60 return { totalUnits: properties.reduce((sum, p) => sum + p.units.length, 0),
61 vacancyRate: this.calcVacancy(properties), pendingWorkOrders: await this.getPendingOrders(propertyIds) };
62 }
63
64 async routeWorkOrder(order: WorkOrderRequest): Promise<string> {
65 const property = await this.client.get(`/properties/${order.propertyId}`);
66 const vendor = this.selectVendor(property.region, order.category);
67 return this.client.post('/work-orders', { ...order, assigned_vendor: vendor });
68 }
69}
70```
71
72## Caching Strategy
73
74```typescript
75const CACHE_CONFIG = {
76 properties: { ttl: 300, prefix: 'prop' }, // 5 min — changes infrequently
77 tenants: { ttl: 120, prefix: 'tenant' }, // 2 min — moderate churn
78 leases: { ttl: 60, prefix: 'lease' }, // 1 min — financial accuracy
79 workOrders: { ttl: 30, prefix: 'wo' }, // 30s — real-time tracking
80 vacancies: { ttl: 15, prefix: 'vacancy' }, // 15s — leasing speed matters
81};
82// Webhook-driven invalidation: AppFolio events flush matching cache keys immediately
83```
84
85## Event Pipeline
86
87```typescript
88class PropertyEventPipeline {
89 private queue = new Bull('appfolio-events', { redis: process.env.REDIS_URL });
90
91 async onWebhook(event: AppFolioEvent): Promise<void> {
92 await this.queue.add(event.type, event, { attempts: 3, backoff: { type: 'exponential', delay: 2000 } });
93 }
94
95 async processLeaseEvent(event: LeaseEvent): Promise<void> {
96 if (event.type === 'lease.signed') await this.updateVacancy(event.propertyId);
97 if (event.type === 'lease.terminated') await this.triggerMoveOutWorkflow(event);
98 }
99
100 async processWorkOrderEvent(event: WorkOrderEvent): Promise<void> {
101 if (event.status === 'completed') await this.reconcileVendorInvoice(event);
102 }
103}
104```
105
106## Data Model
107
108```typescript
109interface Property { id: string; name: string; address: Address; units: Unit[]; region: string; }
110interface TenantRef { id: string; leaseId: string; contactCiphertextRef: string; }
111interface Lease { id: string; propertyId: string; unitId: string; tenantId: string; startDate: string; endDate: string; monthlyRent: number; status: 'active' | 'pending' | 'terminated'; }
112interface WorkOrder { id: string; propertyId: string; unitId: string; category: 'plumbing' | 'electrical' | 'hvac' | 'general'; status: string; assignedVendor: string; }
113```
114
115## Scaling Considerations
116
117- Partition sync workers by property region to avoid cross-region API rate limits
118- Use read replicas for dashboard queries; write path goes through event pipeline
119- Batch tenant notifications (rent reminders, maintenance updates) via queue to avoid email rate limits
120- Cache vacancy data aggressively — leasing agents hit this endpoint 10x more than any other
121- Shard work order routing by property portfolio to enable independent scaling per management group
122
123## Error Handling
124
125| Component | Failure Mode | Recovery |
126|-----------|-------------|----------|
127| Property sync | AppFolio 429 rate limit | Exponential backoff with jitter, per-property circuit breaker |
128| Lease webhook | Duplicate event delivery | Idempotency key on lease ID + event timestamp |
129| Work order routing | Vendor API timeout | Queue retry with fallback to manual assignment |
130| Accounting sync | Balance mismatch | Reconciliation queue with human review flag |
131| Tenant portal | Cache miss storm | Stale-while-revalidate pattern, circuit breaker on API layer |
132
133## Output
134
135- A contract-bound, staged architecture with service, cache, queue, data, and
136 reconciliation ownership explicitly separated
137- Minimized dashboard references and encrypted/controlled boundaries for tenant
138 contact, payment, and balance data
139- A deployment decision supported by staging failure, duplicate/replay, rate,
140 rollback, and reconciliation evidence
141
142## Examples
143
144For a vacancy-dashboard rollout, start with synthetic property and unit IDs,
145one bounded safe-read, and a cache that exposes data age. Inject a duplicate
146event or reconciliation record, a `429`, and a downstream accounting timeout
147to prove the queue and idempotency store prevent duplicate effects. Promote
148only when results remain complete and authorized and the rollback/reconciliation
149owners can demonstrate their paths. If event support, data classification,
150durable state, or a write outcome is unverified, keep the corresponding path
151disabled and use operator-led reconciliation.
152
153## Resources
154
155- [AppFolio Stack APIs](https://www.appfolio.com/stack/partners/api)
156- [AppFolio Engineering Blog](https://engineering.appfolio.com)
157
158## Next Steps
159
160See `appfolio-deploy-integration`.