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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288# Frontend Guide
The Equalify frontend is a React single-page application built with Vite, providing an accessible interface for managing audits and viewing accessibility scan results.
## Technology Stack
- **React 19** - UI framework
- **TypeScript** - Type safety
- **Vite** - Build tool and dev server
- **TanStack Query** - Server state management
- **React Router v7** - Client-side routing
- **AWS Amplify** - Authentication
- **Radix UI** - Accessible component primitives
- **Recharts** - Data visualization
- **Zustand** - Client state management
- **SCSS Modules** - Scoped styling
## Project Structure
```
apps/frontend/
โโโ src/
โ โโโ main.tsx # Application entry point
โ โโโ App.tsx # Root component with routing
โ โโโ components/ # Reusable UI components
โ โโโ routes/ # Page-level components
โ โโโ queries/ # API query functions
โ โโโ hooks/ # Custom React hooks
โ โโโ utils/ # Helper functions
โ โโโ global-styles/ # Global SCSS styles
โโโ public/ # Static assets
โโโ index.html # HTML template
โโโ vite.config.ts # Vite configuration
```
## Key Pages
### Audits (`/audits`)
The main dashboard displaying all user audits with status indicators.
### Audit Detail (`/audit/:id`)
Displays scan results for a specific audit including:
- Blockers over time chart
- Blocker details table
- Scan progress indicator
- Re-scan functionality
### Build Audit (`/build-audit`)
Form for creating new audits with:
- Audit name and scan frequency
- URL input (manual or CSV upload)
- Email notification settings
### Account (`/account`)
User profile management and team administration for admins.
### Logs (`/logs`)
Activity history for compliance tracking.
## Authentication
### Cognito Authentication
```typescript
import { Amplify } from "aws-amplify";
import * as Auth from "aws-amplify/auth";
Amplify.configure({
Auth: {
Cognito: {
userPoolId: import.meta.env.VITE_USERPOOLID,
userPoolClientId: import.meta.env.VITE_USERPOOLWEBCLIENTID,
},
},
// ... API configuration
});
```
### SSO Authentication
For enterprise SSO via Azure AD:
```typescript
import { PublicClientApplication } from '@azure/msal-browser';
const msalInstance = new PublicClientApplication({
auth: {
clientId: import.meta.env.VITE_SSO_CLIENT_ID,
authority: import.meta.env.VITE_SSO_AUTHORITY,
redirectUri: window.location.origin + '/redirect.html',
},
});
```
### Token Handling
Tokens are automatically included in API requests:
```typescript
// Check for SSO token first
const ssoToken = localStorage.getItem('sso_token');
if (ssoToken) {
return { Authorization: `Bearer ${ssoToken}` };
}
// Fallback to Cognito session
```
## API Integration
### REST API
Using AWS Amplify REST client:
```typescript
import { get, post } from 'aws-amplify/api';
// GET request
const response = await get({
apiName: 'auth',
path: '/getAuditResults',
options: { queryParams: { id: auditId } }
}).response;
// POST request
const response = await post({
apiName: 'auth',
path: '/saveAudit',
options: { body: auditData }
}).response;
```
### GraphQL
For real-time updates and complex queries:
```typescript
import { generateClient } from 'aws-amplify/api';
const client = generateClient();
const result = await client.graphql({
query: /* GraphQL query */,
variables: { audit_id: id }
});
```
### TanStack Query
For caching and state management:
```typescript
import { useQuery, useMutation } from '@tanstack/react-query';
// Query with caching
const { data, isLoading } = useQuery({
queryKey: ['audit', auditId],
queryFn: () => fetchAuditDetails(auditId),
});
// Mutation with optimistic updates
const mutation = useMutation({
mutationFn: saveAudit,
onSuccess: () => {
queryClient.invalidateQueries(['audits']);
},
});
```
## Key Components
### Navigation
Global navigation with authentication-aware links.
### AuditsTable
Sortable, filterable table of all audits with status badges.
### BlockersTable
Paginated table of accessibility blockers with:
- Message content
- HTML snippet preview
- WCAG tag filtering
- URL filtering
### AuditPagesInput
URL entry component supporting:
- Manual URL input
- CSV file upload
- Sitemap detection
### Card
Consistent card layout component for content sections.
### StyledButton
Accessible button component with variants.
## State Management
### Global State (Zustand)
For cross-component state:
```typescript
import { create } from 'zustand';
const useGlobalStore = create((set) => ({
user: null,
setUser: (user) => set({ user }),
}));
```
### URL State
Route parameters for shareable views:
```typescript
import { useParams, useSearchParams } from 'react-router-dom';
const { id } = useParams();
const [searchParams, setSearchParams] = useSearchParams();
```
## Styling
### SCSS Modules
Component-scoped styles:
```scss
// Component.module.scss
.container {
padding: var(--spacing-md);
.title {
font-size: var(--font-size-lg);
}
}
```
```tsx
import styles from './Component.module.scss';
<div className={styles.container}>
<h1 className={styles.title}>Title</h1>
</div>
```
### CSS Custom Properties
Global design tokens in `global-styles/`.
## Environment Variables
| Variable | Description |
|----------|-------------|
| `VITE_USERPOOLID` | Cognito User Pool ID |
| `VITE_USERPOOLWEBCLIENTID` | Cognito Client ID |
| `VITE_API_URL` | Backend API base URL |
| `VITE_GRAPHQL_URL` | Hasura GraphQL endpoint |
| `VITE_SSO_CLIENT_ID` | Azure AD client ID |
| `VITE_SSO_AUTHORITY` | Azure AD authority URL |
## Build & Deployment
### Development
```bash
# Start dev server (staging)
yarn start:staging
# Start dev server (production)
yarn start:prod
```
### Production Build
```bash
# Build and deploy to staging
yarn build:staging
# Build and deploy to production
yarn build:prod
```
Deployment uses:
- AWS S3 for static hosting
- CloudFront for CDN and caching
## Accessibility
As an accessibility tool, the frontend follows strict accessibility standards:
- Radix UI primitives for accessible components
- Semantic HTML structure
- Keyboard navigation support
- Screen reader announcements
- Proper focus management
- Color contrast compliance
---
*For backend API details, see the Backend API Reference.*