1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236# Database Schema
Equalify uses PostgreSQL as its primary database, accessed via direct queries (serverless-postgres) and GraphQL (Hasura).
## Core Tables
### audits
Stores audit configurations and metadata.
| Column | Type | Description |
|--------|------|-------------|
| `id` | UUID | Primary key |
| `user_id` | UUID | Owner's user ID (FK) |
| `name` | TEXT | Audit display name |
| `interval` | TEXT | Scan frequency (manual, daily, weekly, etc.) |
| `scheduled_at` | TIMESTAMP | Next scheduled scan time |
| `status` | TEXT | Current status (draft, new, processing, complete, failed) |
| `payload` | JSONB | Full audit configuration |
| `response` | JSONB | Latest scan response |
| `email_notifications` | BOOLEAN | Enable email alerts |
| `created_at` | TIMESTAMP | Creation timestamp |
| `updated_at` | TIMESTAMP | Last update timestamp |
### urls
URLs associated with audits for scanning.
| Column | Type | Description |
|--------|------|-------------|
| `id` | UUID | Primary key |
| `user_id` | UUID | Owner's user ID (FK) |
| `audit_id` | UUID | Parent audit (FK) |
| `url` | TEXT | Full URL to scan |
| `type` | TEXT | Content type (html, pdf) |
| `created_at` | TIMESTAMP | Creation timestamp |
### scans
Individual scan runs for audits.
| Column | Type | Description |
|--------|------|-------------|
| `id` | UUID | Primary key |
| `audit_id` | UUID | Parent audit (FK) |
| `status` | TEXT | Scan status (processing, complete, failed) |
| `percentage` | INTEGER | Progress percentage (0-100) |
| `pages` | JSONB | Array of pages to scan |
| `processed_pages` | JSONB | Array of completed page IDs |
| `errors` | JSONB | Array of scan errors |
| `created_at` | TIMESTAMP | Scan start time |
| `updated_at` | TIMESTAMP | Last update timestamp |
### blockers
Individual accessibility issues found during scans.
| Column | Type | Description |
|--------|------|-------------|
| `id` | UUID | Primary key |
| `scan_id` | UUID | Parent scan (FK) |
| `url_id` | UUID | URL where found (FK) |
| `content` | TEXT | HTML snippet or context |
| `content_hash_id` | UUID | Hash for deduplication |
| `equalified` | BOOLEAN | Marked as resolved |
| `created_at` | TIMESTAMP | Discovery timestamp |
### messages
Accessibility rule definitions.
| Column | Type | Description |
|--------|------|-------------|
| `id` | UUID | Primary key |
| `content` | TEXT | Rule/message text |
| `category` | TEXT | Message category |
| `created_at` | TIMESTAMP | Creation timestamp |
### blocker_messages
Junction table linking blockers to messages.
| Column | Type | Description |
|--------|------|-------------|
| `id` | UUID | Primary key |
| `blocker_id` | UUID | Blocker reference (FK) |
| `message_id` | UUID | Message reference (FK) |
### tags
WCAG and other accessibility tags.
| Column | Type | Description |
|--------|------|-------------|
| `id` | UUID | Primary key |
| `content` | TEXT | Tag name (e.g., "wcag2aa") |
### message_tags
Junction table for message-tag relationships.
| Column | Type | Description |
|--------|------|-------------|
| `id` | UUID | Primary key |
| `message_id` | UUID | Message reference (FK) |
| `tag_id` | UUID | Tag reference (FK) |
### ignored_blockers
Blockers marked as ignored/resolved.
| Column | Type | Description |
|--------|------|-------------|
| `id` | UUID | Primary key |
| `audit_id` | UUID | Audit reference (FK) |
| `blocker_id` | UUID | Blocker reference (FK) |
| `created_at` | TIMESTAMP | When ignored |
### users
User accounts and profiles.
| Column | Type | Description |
|--------|------|-------------|
| `id` | UUID | Primary key (matches Cognito sub) |
| `email` | TEXT | User email address |
| `name` | TEXT | Display name |
| `role` | TEXT | User role (user, admin) |
| `team_id` | UUID | Team membership (FK) |
| `created_at` | TIMESTAMP | Account creation |
### teams
Organization/team groupings.
| Column | Type | Description |
|--------|------|-------------|
| `id` | UUID | Primary key |
| `name` | TEXT | Team name |
| `created_at` | TIMESTAMP | Creation timestamp |
### logs
Activity audit trail.
| Column | Type | Description |
|--------|------|-------------|
| `id` | UUID | Primary key |
| `user_id` | UUID | Acting user (FK) |
| `action` | TEXT | Action type |
| `details` | JSONB | Action details |
| `created_at` | TIMESTAMP | Action timestamp |
## Relationships
```
teams
โโโ users (many)
โโโ audits (many)
โโโ urls (many)
โโโ scans (many)
โโโ blockers (many)
โโโ blocker_messages (many)
โโโ messages (one)
โโโ message_tags (many)
โโโ tags (one)
```
## Content Hashing
Blockers use content hashing for deduplication:
```typescript
const contentHashId = hashStringToUuid(
`${urlId}-${messageContent}-${normalizedNode}`
);
```
This allows:
- Tracking blocker persistence across scans
- Identifying when blockers are resolved
- Preventing duplicate entries
## GraphQL Access (Hasura)
Hasura provides GraphQL access with row-level security:
```graphql
query GetAuditBlockers($audit_id: uuid!) {
audits_by_pk(id: $audit_id) {
scans(order_by: {created_at: desc}, limit: 1) {
blockers {
id
content
url_id
blocker_messages {
message {
content
category
message_tags {
tag {
content
}
}
}
}
}
}
}
}
```
## Row-Level Security
Hasura enforces row-level security based on JWT claims:
```json
{
"x-hasura-allowed-roles": ["user", "admin"],
"x-hasura-default-role": "user",
"x-hasura-user-id": "user-uuid"
}
```
Users can only access:
- Their own audits
- Audits shared with their team
- Admin access for team management
## Atomic Operations
Scan progress uses atomic PostgreSQL operations to prevent race conditions:
```sql
UPDATE "scans"
SET
"processed_pages" = CASE
WHEN NOT (COALESCE("processed_pages", '[]'::jsonb) @> $1::jsonb)
THEN COALESCE("processed_pages", '[]'::jsonb) || $1::jsonb
ELSE "processed_pages"
END
WHERE "id" = $2
RETURNING "pages", "processed_pages"
```
---
*For API usage examples, see the Backend API Reference.*