Appwrite Configuration
This guide explains how to configure Appwrite for Talent Finder.
Prerequisites
- An accessible Appwrite instance (self-hosted or Cloud)
- An administrator account on this instance
Environment Variables
Copy .env.example to .env and configure the values:
bash
# Redirect URL after authentication
PUBLIC_LOGIN_URL="http://localhost:5173"
# Appwrite
APPWRITE_ENDPOINT="https://your-instance.appwrite.io/v1"
APPWRITE_PROJECT="your-project-id"
APPWRITE_KEY="your-api-key"
APPWRITE_DATABASE_ID="your-database-id"
APPWRITE_CONSENT_EVENTS_COLLECTION_ID="consent-events"
APPWRITE_CURRENT_CONSENTS_COLLECTION_ID="current-consents"
# Allowed email domains (regex)
ALLOWED_DOMAINS_REGEXP="@your-domain\.com"Step-by-Step Configuration
1. Create a Project
- Log in to the Appwrite console
- Click on Create project
- Note the Project ID →
APPWRITE_PROJECT
2. Create an API Key
- In the project, go to Settings > API Keys
- Click on Create API Key
- Name:
talent-finder-server - Required scopes:
users.readusers.writedatabases.readdatabases.writecollections.readcollections.writedocuments.readdocuments.writeattributes.read
- Copy the key →
APPWRITE_KEY
3. Create the Database
- Go to Databases
- Click on Create database
- Name:
talent-finder(or another name) - Note the Database ID →
APPWRITE_DATABASE_ID
4. Create the Collections
Collection consent-events
This collection stores the immutable history of consents (audit log).
- In the database, click on Create collection
- Collection ID:
consent-events - Name:
Consent Events - Permissions: None (API access only)
Attributes to create:
| Attribute | Type | Size | Required | Description |
|---|---|---|---|---|
userId | String | 36 | Yes | Appwrite user ID |
consentType | Enum | - | Yes | Type of consent |
action | Enum | - | Yes | Action performed |
Enum values:
consentType:openalex_emailaction:grant,revoke
Indexes to create:
| Name | Type | Attributes |
|---|---|---|
userId_idx | Key | userId |
userId_type_idx | Key | userId, consentType |
Collection current-consents
This collection stores the current state of consents (one entry per user/type).
- Click on Create collection
- Collection ID:
current-consents - Name:
Current Consents - Permissions: None (API access only)
Attributes to create:
| Attribute | Type | Size | Required | Description |
|---|---|---|---|---|
userId | String | 36 | Yes | Appwrite user ID |
consentType | Enum | - | Yes | Type of consent |
granted | Boolean | - | Yes | Whether consent is granted |
Enum values:
consentType:openalex_email
Indexes to create:
| Name | Type | Attributes |
|---|---|---|
userId_type_idx | Unique | userId, consentType |
Verification
Once configured, the dashboard displays the system health status in the System Health card (visible for admins).
The /api/v1/health API returns:
json
{
"status": "healthy",
"timestamp": "2024-01-15T12:00:00.000Z",
"services": [
{
"name": "appwrite",
"status": "healthy",
"responseTimeMs": 150,
"database": {
"id": "your-database-id",
"name": "talent-finder",
"exists": true,
"apiKeyValid": true,
"collections": [
{
"id": "consent-events",
"name": "Consent Events",
"exists": true,
"attributes": [
{ "name": "userId", "exists": true, "type": "string" },
{ "name": "consentType", "exists": true, "type": "enum" },
{ "name": "action", "exists": true, "type": "enum" }
]
},
{
"id": "current-consents",
"name": "Current Consents",
"exists": true,
"attributes": [
{ "name": "userId", "exists": true, "type": "string" },
{ "name": "consentType", "exists": true, "type": "enum" },
{ "name": "granted", "exists": true, "type": "boolean" }
]
}
]
}
}
]
}Troubleshooting
Status "unhealthy"
| Error | Cause | Solution |
|---|---|---|
Invalid API key | API key incorrect or expired | Regenerate the key in Appwrite |
Project not found | Incorrect Project ID | Check APPWRITE_PROJECT |
Database not found | Incorrect Database ID | Check APPWRITE_DATABASE_ID |
Connection timeout | Appwrite unreachable | Check the URL and network |
Status "degraded"
| Error | Cause | Solution |
|---|---|---|
Missing collections: X | Collection not created | Create the missing collection |
Missing attributes: X.Y | Attribute not created | Add the missing attribute |
Architecture
Appwrite
└── Database: talent-finder
├── consent-events (audit log)
│ ├── userId (string)
│ ├── consentType (enum)
│ ├── action (enum)
│ └── $createdAt (system)
│
└── current-consents (current state)
├── userId (string)
├── consentType (enum)
├── granted (boolean)
└── $updatedAt (system)Fields prefixed with $ are automatically managed by Appwrite.