Overview
Appwrite is an open-source backend-as-a-service platform providing auth, database, storage, functions, and messaging for web, mobile, and Flutter applications. It's self-hostable and has a cloud offering.
Capabilities
- Authentication (email, phone, OAuth2, anonymous, magic links)
- Database with documents, collections, and relationships
- File storage with antivirus scanning
- Serverless functions (Node, Python, PHP, Ruby, Swift, Dart, Go, .NET, Java, Kotlin, Bun, Deno)
- Realtime subscriptions via WebSocket
- Messaging (push, email, SMS)
- Teams and permissions
- Locale and avatars services
When to Use
Trigger phrases:
"appwrite patterns"
"Appwrite backend-as-a-service — auth, database, storage, functions, realtime for"
Full-featured BaaS without building from scratch
Flutter/mobile-first applications
Need self-hosted backend control
Multi-platform (web, iOS, Android, Flutter) applications
When NOT to Use
- Task is about deployment, not development (use deploy skills)
- Task is about code review, not writing (use review skills)
- You need to understand existing code first (use research skills)
- Task is about testing only (use test skills)
- Requirements are unclear (clarify first)
- Task is trivially simple (single line fix)
Pseudo Code
The appwrite-patterns workflow follows a standard pipeline pattern.
Core flow:
# appwrite-patterns primary flow
input = prepare(raw_data)
result = process(input, config={appwrite, auth, backend, database, desktop})
validate(result)
deliver(result)
Error handling:
on error:
log(error_details)
retry_with_backoff(max=3)
if still_failing: alert_and_escalate()
Setup (Web SDK)
import { Client, Account, Databases, Storage, Functions } from 'appwrite';
const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1')
.setProject('your-project-id');
const account = new Account(client);
const databases = new Databases(client);
const storage = new Storage(client);
const functions = new Functions(client);
Authentication
// Email/password
await account.create(ID.unique(), 'alice@example.com', 'password', 'Alice');
const session = await account.createEmailPasswordSession('alice@example.com', 'password');
// OAuth2
await account.createOAuth2Session('google', 'https://app.com/success', 'https://app.com/fail');
// Magic link
await account.createMagicURLSession(ID.unique(), 'alice@example.com', 'https://app.com/verify');
// Get current user
const user = await account.get();
Database CRUD
import { ID, Query } from 'appwrite';
// Create
await databases.createDocument('mydb', 'posts', ID.unique(), {
title: 'Hello World',
content: 'My first post',
author: userId,
});
// Read with queries
const posts = await databases.listDocuments('mydb', 'posts', [
Query.equal('status', 'published'),
Query.orderDesc('$createdAt'),
Query.limit(20),
]);
// Update
await databases.updateDocument('mydb', 'posts', documentId, {
title: 'Updated Title',
});
// Delete
await databases.deleteDocument('mydb', 'posts', documentId);
Storage
// Upload file
const file = await storage.createFile('bucket-id', ID.unique(), fileInput);
// Get file URL
const url = storage.getFileView('bucket-id', fileId);
// Delete file
await storage.deleteFile('bucket-id', fileId);
Realtime
// Subscribe to collection changes
client.subscribe('databases.mydb.collections.posts.documents', (response) => {
console.log(response.events); // ['databases.*.collections.*.documents.*.create']
console.log(response.payload);
});
// Subscribe to user's own channel
client.subscribe('account', (response) => { /* auth events */ });
Functions
// Execute function
const result = await functions.createExecution('function-id', JSON.stringify({ key: 'value' }));
console.log(result.stdout, result.stderr);
Common Patterns
- Permissions: Use
Permission.read(Role.user(userId)) for fine-grained access control
- Relationships: Use relationship attributes for document linking
- Migrations: Use Appwrite CLI (
appwrite push/pull) for collection schemas
- Docker: Self-host with
docker compose up -d
How to Use
- Understand the requirement and existing codebase patterns
- Design the solution with error handling and testability in mind
- Implement incrementally with tests for each change
- Verify against expected outcomes (manual and automated)
- Document usage, edge cases, and integration points
- Review with team before merging to shared branches
Red Flags
- Skipping tests to ship faster: Untested code breaks in production when you least expect it
- No error handling in production code: Unhandled errors crash services and lose user data
- Hardcoded configuration values: Hardcoded values prevent environment switching and leak secrets
- Ignoring security implications: Missing input validation, auth bypasses, and injection vulnerabilities
- Over-engineering simple solutions: Premature abstraction adds complexity without proportional benefit
Verification
Process
- Analyze the task requirements
- Apply domain expertise
- Verify output quality
Anti-Rationalization Table
| Rationalization |
Reality |
| "Tests slow me down" |
Bugs slow you down 10x more. Tests are speed, not overhead. |
| "I will refactor later" |
Technical debt compounds. Refactor as you go. |
| "It works on my machine" |
If it is not in CI, it does not work. Ship proof, not claims. |
1---2name: appwrite-patterns3description: Use when appwrite backend-as-a-service — auth, database, storage, functions,4 realtime for web/mobile/desktop. Use when working with appwrite patterns.5domain: development6author: oyi777license: Apache-2.08subdomain: software-development9tags:10- appwrite11- coding12- patterns13- software-engineering14- testing15version: 1.0.016category: development17metadata:18 source: https://skillmd.com/skills/oyi77/appwrite-patterns19---20212223## Overview2425Appwrite is an open-source backend-as-a-service platform providing auth, database, storage, functions, and messaging for web, mobile, and Flutter applications. It's self-hostable and has a cloud offering.2627## Capabilities2829- Authentication (email, phone, OAuth2, anonymous, magic links)30- Database with documents, collections, and relationships31- File storage with antivirus scanning32- Serverless functions (Node, Python, PHP, Ruby, Swift, Dart, Go, .NET, Java, Kotlin, Bun, Deno)33- Realtime subscriptions via WebSocket34- Messaging (push, email, SMS)35- Teams and permissions36- Locale and avatars services3738## When to Use39**Trigger phrases:**40- "appwrite patterns"41- "Appwrite backend-as-a-service — auth, database, storage, functions, realtime for"424344- Full-featured BaaS without building from scratch45- Flutter/mobile-first applications46- Need self-hosted backend control47- Multi-platform (web, iOS, Android, Flutter) applications4849## When NOT to Use5051- Task is about deployment, not development (use deploy skills)52- Task is about code review, not writing (use review skills)53- You need to understand existing code first (use research skills)54- Task is about testing only (use test skills)55- Requirements are unclear (clarify first)56- Task is trivially simple (single line fix)575859## Pseudo Code6061The appwrite-patterns workflow follows a standard pipeline pattern.6263Core flow:64```65# appwrite-patterns primary flow66input = prepare(raw_data)67result = process(input, config={appwrite, auth, backend, database, desktop})68validate(result)69deliver(result)70```7172Error handling:73```74on error:75 log(error_details)76 retry_with_backoff(max=3)77 if still_failing: alert_and_escalate()78```798081### Setup (Web SDK)82```typescript83import { Client, Account, Databases, Storage, Functions } from 'appwrite';8485const client = new Client()86 .setEndpoint('https://cloud.appwrite.io/v1')87 .setProject('your-project-id');8889const account = new Account(client);90const databases = new Databases(client);91const storage = new Storage(client);92const functions = new Functions(client);93```9495### Authentication96```typescript97// Email/password98await account.create(ID.unique(), 'alice@example.com', 'password', 'Alice');99const session = await account.createEmailPasswordSession('alice@example.com', 'password');100101// OAuth2102await account.createOAuth2Session('google', 'https://app.com/success', 'https://app.com/fail');103104// Magic link105await account.createMagicURLSession(ID.unique(), 'alice@example.com', 'https://app.com/verify');106107// Get current user108const user = await account.get();109```110111### Database CRUD112```typescript113import { ID, Query } from 'appwrite';114115// Create116await databases.createDocument('mydb', 'posts', ID.unique(), {117 title: 'Hello World',118 content: 'My first post',119 author: userId,120});121122// Read with queries123const posts = await databases.listDocuments('mydb', 'posts', [124 Query.equal('status', 'published'),125 Query.orderDesc('$createdAt'),126 Query.limit(20),127]);128129// Update130await databases.updateDocument('mydb', 'posts', documentId, {131 title: 'Updated Title',132});133134// Delete135await databases.deleteDocument('mydb', 'posts', documentId);136```137138### Storage139```typescript140// Upload file141const file = await storage.createFile('bucket-id', ID.unique(), fileInput);142143// Get file URL144const url = storage.getFileView('bucket-id', fileId);145146// Delete file147await storage.deleteFile('bucket-id', fileId);148```149150### Realtime151```typescript152// Subscribe to collection changes153client.subscribe('databases.mydb.collections.posts.documents', (response) => {154 console.log(response.events); // ['databases.*.collections.*.documents.*.create']155 console.log(response.payload);156});157158// Subscribe to user's own channel159client.subscribe('account', (response) => { /* auth events */ });160```161162### Functions163```typescript164// Execute function165const result = await functions.createExecution('function-id', JSON.stringify({ key: 'value' }));166console.log(result.stdout, result.stderr);167```168169## Common Patterns170171- **Permissions**: Use `Permission.read(Role.user(userId))` for fine-grained access control172- **Relationships**: Use relationship attributes for document linking173- **Migrations**: Use Appwrite CLI (`appwrite push/pull`) for collection schemas174- **Docker**: Self-host with `docker compose up -d`175176## How to Use1771781. Understand the requirement and existing codebase patterns1792. Design the solution with error handling and testability in mind1803. Implement incrementally with tests for each change1814. Verify against expected outcomes (manual and automated)1825. Document usage, edge cases, and integration points1836. Review with team before merging to shared branches184185## Red Flags186187- **Skipping tests to ship faster**: Untested code breaks in production when you least expect it188- **No error handling in production code**: Unhandled errors crash services and lose user data189- **Hardcoded configuration values**: Hardcoded values prevent environment switching and leak secrets190- **Ignoring security implications**: Missing input validation, auth bypasses, and injection vulnerabilities191- **Over-engineering simple solutions**: Premature abstraction adds complexity without proportional benefit192193## Verification194195- [ ] Skill output matches expected behavior196197## Process1981991. Analyze the task requirements2002. Apply domain expertise2013. Verify output quality202203## Anti-Rationalization Table204205| Rationalization | Reality |206|---|---|207| "Tests slow me down" | Bugs slow you down 10x more. Tests are speed, not overhead. |208| "I will refactor later" | Technical debt compounds. Refactor as you go. |209| "It works on my machine" | If it is not in CI, it does not work. Ship proof, not claims. |