Skip to content

Commit 54fbecf

Browse files
committed
docs: update LICENSE, README, and SETUP_GUIDE
- LICENSE: change copyright to AutiSense (was incorrect name) - README: add CI badge, React badge, home.png screenshot, update live URL to custom domain, update Next.js/React versions, add Vitest test counts, update project structure - SETUP_GUIDE: strip infrastructure details (moved to external docs), replace with slim quickstart guide
1 parent 69731c3 commit 54fbecf

3 files changed

Lines changed: 47 additions & 249 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2026 Ahan Ghosh
3+
Copyright (c) 2026 AutiSense
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# AutiSense
22

3-
[![Next.js](https://img.shields.io/badge/Next.js-16-black?logo=next.js)](https://nextjs.org/)
3+
[![CI](https://github.com/Partha-dev01/AutiSense_2/actions/workflows/ci.yml/badge.svg)](https://github.com/Partha-dev01/AutiSense_2/actions/workflows/ci.yml)
4+
[![Next.js](https://img.shields.io/badge/Next.js-16.2-black?logo=next.js)](https://nextjs.org/)
5+
[![React](https://img.shields.io/badge/React-19.2-61DAFB?logo=react&logoColor=white)](https://react.dev/)
46
[![TypeScript](https://img.shields.io/badge/TypeScript-5-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
57
[![ONNX Runtime](https://img.shields.io/badge/ONNX_Runtime-Web-blue)](https://onnxruntime.ai/)
68
[![AWS](https://img.shields.io/badge/AWS-Bedrock%20%7C%20Polly%20%7C%20DynamoDB-FF9900?logo=amazon-web-services&logoColor=white)](https://aws.amazon.com/)
@@ -10,7 +12,9 @@
1012
1113
AutiSense is a web application that captures behavioral biomarkers using real-time on-device AI inference. Four ONNX models run entirely in the browser -- no video, audio, or inference data ever leaves the device during screening. Cloud services enrich the experience with generative AI reports, text-to-speech, and cross-device data sync, all with graceful offline fallbacks.
1214

13-
**Live**: [https://main.d2n7pu2vtgi8yc.amplifyapp.com](https://main.d2n7pu2vtgi8yc.amplifyapp.com)
15+
**Live**: [https://autisense.imaginaerium.in](https://autisense.imaginaerium.in)
16+
17+
![AutiSense Landing Page](public/home.png)
1418

1519
---
1620

@@ -30,7 +34,7 @@ AutiSense is a web application that captures behavioral biomarkers using real-ti
3034

3135
| Layer | Technology |
3236
|-------|-----------|
33-
| Framework | Next.js 16.1.6 (App Router, React 19) |
37+
| Framework | Next.js 16.2.2 (App Router, React 19.2.4) |
3438
| Language | TypeScript 5 |
3539
| Styling | Tailwind CSS v4 + CSS custom properties |
3640
| State | Zustand (global) + React useState (local) |
@@ -43,7 +47,8 @@ AutiSense is a web application that captures behavioral biomarkers using real-ti
4347
| Auth | Custom Google OAuth 2.0 + DynamoDB sessions |
4448
| Charts | Recharts (dashboard) + Chart.js (detector) |
4549
| PDF | pdf-lib (server-side generation) |
46-
| Testing | Playwright 1.58.2 |
50+
| E2E Testing | Playwright 1.58.2 (97 tests) |
51+
| Unit Testing | Vitest 3.2.4 (68 tests) |
4752
| Hosting | AWS Amplify (WEB_COMPUTE SSR) |
4853

4954
---
@@ -153,7 +158,8 @@ Open [http://localhost:3000](http://localhost:3000).
153158

154159
```bash
155160
npm run build
156-
npx playwright test # 32 Playwright tests
161+
npm run test:unit # 68 Vitest unit tests
162+
npx playwright test # 97 Playwright E2E tests
157163
```
158164

159165
---
@@ -185,7 +191,8 @@ AutiSense_2/
185191
│ └── types/ 6 type modules
186192
├── public/models/ 4 ONNX models (~47 MB total)
187193
├── server/ Lambda handler + DynamoDB setup script
188-
├── tests/ 2 Playwright spec files (32 tests)
194+
├── __tests__/ 7 Vitest unit test files (68 tests)
195+
├── tests/ 4 Playwright E2E spec files (97 tests)
189196
├── workers/ ONNX inference Web Worker
190197
└── docs/ DOCS.md, SETUP_GUIDE.md, Amazon_usage.md
191198
```

docs/SETUP_GUIDE.md

Lines changed: 33 additions & 242 deletions
Original file line numberDiff line numberDiff line change
@@ -1,266 +1,57 @@
1-
# AutiSense — Deployment Reference
1+
# AutiSense — Setup Guide
22

3-
> Quick reference for the deployed AWS infrastructure. No secrets stored here.
3+
## Quick Start
44

5-
---
6-
7-
## Live Application
8-
9-
| | |
10-
|---|---|
11-
| **URL** | https://main.d2n7pu2vtgi8yc.amplifyapp.com |
12-
| **Amplify App ID** | `d2n7pu2vtgi8yc` |
13-
| **Region** | ap-south-1 (Mumbai) |
14-
| **GitHub** | https://github.com/Partha-dev01/AutiSense_2 |
15-
| **Auto-deploy** | Pushes to `main` trigger automatic builds |
16-
17-
---
18-
19-
## AWS Resources
20-
21-
| Service | Resource | Region |
22-
|---------|----------|--------|
23-
| DynamoDB | 7 tables (`autisense-*`) | ap-south-1 |
24-
| S3 | `autisense-models-762099405044` (4 ONNX models) | ap-south-1 |
25-
| Bedrock | Nova Lite + Nova Pro | us-east-1 |
26-
| Polly | Joanna (Neural voice) | ap-south-1 |
27-
| Amplify | WEB_COMPUTE (Next.js SSR) | ap-south-1 |
28-
| IAM | `autisense-app` user + `AutiSenseAmplifyRole` | Global |
29-
| Budgets | $10/month alarm | Global |
30-
31-
---
5+
```bash
6+
git clone https://github.com/Partha-dev01/AutiSense_2.git
7+
cd AutiSense_2
8+
npm install
9+
cp .env.local.example .env.local
10+
# Fill in .env.local with your values
11+
npm run dev
12+
```
3213

3314
## Environment Variables
3415

35-
### CRITICAL: Amplify SSR Env Var Behavior
16+
See [`.env.local.example`](../.env.local.example) for the full list of required variables.
3617

37-
> **Amplify WEB_COMPUTE injects environment variables into the BUILD container but NOT into the SSR Lambda runtime.**
18+
The app works **without AWS credentials** — all API routes have template/fallback responses.
3819

39-
This means `process.env.MY_VAR` will be `undefined` at request time in API routes and server components unless you handle it explicitly.
20+
### Local Development
4021

41-
**How we solve this:** All non-AWS env vars are listed in `next.config.ts` under the `env` property. This tells Next.js to inline them at **build time** into the server bundle, so they're available when the Lambda handles requests.
42-
43-
```ts
44-
// next.config.ts
45-
env: {
46-
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID ?? "",
47-
GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET ?? "",
48-
// ... all 13 vars listed here
49-
},
22+
For local AWS access, configure the AWS CLI profile or set these in `.env.local`:
5023
```
51-
52-
**AWS credentials (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION`)** are NOT listed in `env` — Lambda provides these automatically via the IAM execution role (`AutiSenseAmplifyRole`).
53-
54-
### Adding a New Environment Variable
55-
56-
When you add a new env var to the app:
57-
58-
1. **Set it in Amplify Console** → App settings → Environment variables
59-
2. **Add it to `next.config.ts` `env` block** (unless it starts with `AWS_` or `NEXT_PUBLIC_`)
60-
3. **Add it to `.env.local`** for local development
61-
4. **Push and redeploy** — the build step will inline the value
62-
63-
If you skip step 2, the variable will be available during `npm run build` but **undefined** when handling requests.
64-
65-
### Current Environment Variables
66-
67-
| Variable | Set In | Purpose |
68-
|----------|--------|---------|
69-
| `GOOGLE_CLIENT_ID` | Amplify + next.config.ts | Google OAuth app ID |
70-
| `GOOGLE_CLIENT_SECRET` | Amplify + next.config.ts | Google OAuth secret |
71-
| `NEXT_PUBLIC_APP_URL` | Amplify + next.config.ts | App base URL (for OAuth redirects) |
72-
| `BEDROCK_REGION` | Amplify + next.config.ts | Bedrock model region (us-east-1) |
73-
| `POLLY_REGION` | Amplify + next.config.ts | Polly voice region (ap-south-1) |
74-
| `S3_MODELS_BUCKET` | Amplify + next.config.ts | S3 bucket for ONNX models |
75-
| `DYNAMODB_*` (7 tables) | Amplify + next.config.ts | DynamoDB table names |
76-
| `APP_ACCESS_KEY_ID` | Amplify + next.config.ts | IAM user access key (Amplify blocks `AWS_*`) |
77-
| `APP_SECRET_ACCESS_KEY` | Amplify + next.config.ts | IAM user secret key |
78-
| `APP_REGION` | Amplify + next.config.ts | AWS region for SDK clients |
79-
80-
### Google OAuth Setup
81-
82-
| Setting | Value |
83-
|---------|-------|
84-
| **Google Cloud Console** | APIs & Services → Credentials → OAuth 2.0 Client IDs |
85-
| **Authorized redirect URI** | `https://main.d2n7pu2vtgi8yc.amplifyapp.com/api/auth/callback/google` |
86-
| **Scopes** | `openid email profile` |
87-
88-
The redirect URI is constructed from `NEXT_PUBLIC_APP_URL` + `/api/auth/callback/google`. No separate `GOOGLE_REDIRECT_URI` env var is needed.
89-
90-
---
91-
92-
## AWS SDK Credential Handling
93-
94-
Amplify WEB_COMPUTE does **not** expose IAM role credentials to the SSR Lambda runtime. We use custom-named env vars (`APP_ACCESS_KEY_ID`, `APP_SECRET_ACCESS_KEY`, `APP_REGION`) because Amplify reserves the `AWS_*` prefix.
95-
96-
All SDK clients use the shared helper in `app/lib/aws/credentials.ts`:
97-
98-
```ts
99-
import { getAppCredentials, getAppRegion } from "@/app/lib/aws/credentials";
100-
101-
const credentials = getAppCredentials();
102-
new DynamoDBClient({
103-
region: getAppRegion("ap-south-1"),
104-
...(credentials && { credentials }),
105-
});
24+
AWS_REGION=ap-south-1
25+
AWS_ACCESS_KEY_ID=<your-key>
26+
AWS_SECRET_ACCESS_KEY=<your-secret>
10627
```
10728

108-
This falls back to the SDK default provider chain when `APP_*` vars are not set (e.g., local dev with `AWS_*` in `.env.local`).
29+
### Production (AWS Amplify)
10930

110-
---
31+
Environment variables are configured in the Amplify Console:
32+
- **App-level**: AWS credentials (`APP_*` prefix — Amplify blocks `AWS_*`)
33+
- **Branch-level**: Google OAuth, DynamoDB table names, Bedrock/Polly regions
11134

112-
## How to Redeploy
35+
> **Warning**: `aws amplify update-app --environment-variables` REPLACES the entire map. Always pass ALL vars when using the CLI. Use the Amplify Console UI for safer edits.
11336
114-
Push to `main` or run:
37+
## Testing
11538

11639
```bash
117-
aws amplify start-job --app-id d2n7pu2vtgi8yc --branch-name main --job-type RELEASE --region ap-south-1
40+
npm run test:unit # Vitest unit tests (68 tests)
41+
npx playwright test # Playwright E2E tests (97 tests)
42+
npm run lint # ESLint
43+
npm run type-check # TypeScript
11844
```
11945

120-
---
121-
122-
## Troubleshooting
123-
124-
### "Google OAuth is not configured" on deployed site
125-
126-
**Cause:** `process.env.GOOGLE_CLIENT_ID` is undefined in the Lambda runtime.
127-
128-
**Fix:** Ensure the variable is listed in both:
129-
1. Amplify Console → Environment variables
130-
2. `next.config.ts``env` block
131-
132-
Then redeploy.
133-
134-
### AWS API calls failing with "AccessDenied" or "InvalidIdentityToken"
135-
136-
**Cause:** Explicit credentials passed to SDK client without session token.
137-
138-
**Fix:** Remove `credentials: { accessKeyId, secretAccessKey }` from SDK client constructors. Let the SDK auto-detect credentials.
139-
140-
### Tests fail with "ERR_CONNECTION_REFUSED"
141-
142-
**Cause:** Another `next dev` process holds `.next/dev/lock`.
143-
144-
**Fix:** Kill all Node processes (`taskkill /f /im node.exe` on Windows) or delete `.next/dev/lock`.
145-
146-
### ESLint CI check fails
46+
## Deployment
14747

148-
**Cause:** React 19 strict lint rules (`react-hooks/*`) introduced in `eslint-config-next`.
48+
Pushes to `main` auto-deploy via GitHub webhook to AWS Amplify.
14949

150-
**Fix:** Rules are configured in `eslint.config.mjs`. If new violations appear after updating Next.js, check if hooks ordering or ref patterns need adjustment.
151-
152-
### Google sign-in enters a redirect loop
153-
154-
**Cause:** DynamoDB auth tables have wrong primary key names, or env vars were wiped.
155-
156-
**Fix:** Verify table schemas match what the code expects:
157-
- `autisense-users`: PK = `id` (string), GSI = `email-index` on `email`
158-
- `autisense-auth-sessions`: PK = `token` (string), TTL on `expiresAt`
159-
160-
Also verify all 16 Amplify env vars are set (see below).
161-
162-
---
163-
164-
## Critical Warnings
165-
166-
### `aws amplify update-app --environment-variables` REPLACES ALL vars
167-
168-
**The `--environment-variables` flag REPLACES the entire env var map.** It does not append.
169-
170-
If you run:
17150
```bash
172-
aws amplify update-app --environment-variables NEW_VAR=value
173-
```
174-
This **deletes every other env var** and sets only `NEW_VAR`. Always include ALL existing vars when updating.
175-
176-
**Safe pattern:**
177-
```bash
178-
aws amplify get-app --app-id d2n7pu2vtgi8yc --region ap-south-1 \
179-
--query "app.environmentVariables"
180-
# Copy all existing vars, add your new one, then update with the full list
181-
```
182-
183-
### DynamoDB Table Key Schema Must Match Code
184-
185-
The auth code in `app/lib/auth/dynamodb.ts` uses these exact key names:
186-
- `autisense-users` table: PK must be `id` (NOT `userId`)
187-
- `autisense-auth-sessions` table: PK must be `token` (NOT `sessionToken`)
188-
189-
If tables are created with different key names, all DynamoDB operations fail silently and auth falls back to in-memory (which doesn't persist across Lambda instances).
190-
191-
### All 16 Required Amplify Environment Variables
192-
51+
# Manual redeploy
52+
aws amplify start-job --app-id <APP_ID> --branch-name main --job-type RELEASE --region ap-south-1
19353
```
194-
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, NEXT_PUBLIC_APP_URL,
195-
BEDROCK_REGION, POLLY_REGION, S3_MODELS_BUCKET,
196-
DYNAMODB_SESSIONS_TABLE, DYNAMODB_BIOMARKERS_TABLE,
197-
DYNAMODB_USERS_TABLE, DYNAMODB_AUTH_SESSIONS_TABLE,
198-
DYNAMODB_CHILD_PROFILES_TABLE, DYNAMODB_SESSION_SUMMARIES_TABLE,
199-
DYNAMODB_FEED_POSTS_TABLE,
200-
APP_ACCESS_KEY_ID, APP_SECRET_ACCESS_KEY, APP_REGION
201-
```
202-
203-
---
204-
205-
## Changelog
206-
207-
### 2026-03-06 — Mobile UI Fixes, Emotion Quiz, Feed Redesign
208-
209-
**Issues fixed (8 items from mobile testing):**
210-
211-
1. **UserMenu dropdown overlap** — Added semi-transparent backdrop overlay behind dropdown for visual separation on mobile. Clicking backdrop closes menu.
212-
- `app/components/UserMenu.tsx`
213-
214-
2. **Emotion Match → Emotion Quiz** — Replaced card-flip matching game (identical to Memory game) with scenario-based Emotion Quiz. 20 scenarios, 5 emotion choices, adaptive difficulty, sound feedback. Now correctly saves game activity + updates streak.
215-
- `app/games/emotion-match/page.tsx` (full rewrite)
216-
- `app/kid-dashboard/games/page.tsx` (updated description)
217-
- `app/kid-dashboard/page.tsx` (updated card emoji/title)
218-
219-
3. **Streak not updating** — Fixed childId mismatch: dashboard used `""` fallback but games used `"default"`. Changed dashboard fallback to `"default"`.
220-
- `app/kid-dashboard/page.tsx`
221-
222-
4. **Chat mic + viewport + input reorder**:
223-
- Added `viewport` export in layout.tsx to prevent mobile zoom on input focus
224-
- Fixed SpeechRecognition: cleanup old instance before new one, 120ms delay for mic release, nullify ref on callbacks, cleanup on unmount
225-
- Reordered input bar: mic button first (64px, primary green), text input secondary
226-
- `app/kid-dashboard/chat/page.tsx`, `app/layout.tsx`
227-
228-
5. **Progress page** — Verified childId already uses `"default"` fallback; no change needed.
229-
230-
6. **BottomNav/navbar overlap** — Resolved by Fix 1 (backdrop overlay).
231-
232-
7. **Community Feed redesign**:
233-
- Posts displayed first, compose form behind "New Post" button + floating action button
234-
- Per-user reaction tracking via new `feedReactions` IndexedDB table (schema v5)
235-
- Reactions toggle on/off per user (filled/unfilled state)
236-
- Delete own posts with reaction cleanup
237-
- Cleaner card layout, category pills, empty state
238-
- `app/feed/page.tsx` (full rewrite), `app/lib/db/feed.repository.ts`, `app/lib/db/schema.ts`, `app/types/feedPost.ts`
239-
240-
**Files modified:** 10 files across components, games, pages, DB layer, and types.
241-
242-
### 2026-03-06 — Fix Google sign-in loop
243-
244-
**Root causes found:**
245-
1. `aws amplify update-app --environment-variables` replaced ALL env vars (wiped `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET`, `NEXT_PUBLIC_APP_URL`, etc.)
246-
2. DynamoDB `autisense-users` table had PK `userId` but code uses `id`
247-
3. DynamoDB `autisense-auth-sessions` table had PK `sessionToken` but code uses `token`
248-
4. `dynamoFailed` flag was permanent — one transient error disabled DynamoDB forever
249-
250-
**Fixes applied:**
251-
- Restored all 16 Amplify env vars
252-
- Recreated `autisense-users` table (PK=`id`, GSI=`email-index`)
253-
- Recreated `autisense-auth-sessions` table (PK=`token`, TTL on `expiresAt`)
254-
- Changed `dynamoFailed` from permanent boolean to 30-second cooldown timer
255-
256-
### 2026-03-05 — Fix AWS SDK credentials for Amplify
257-
258-
- Created shared credential helper (`app/lib/aws/credentials.ts`)
259-
- Updated all 8 SDK client locations to use `APP_*` env vars
260-
- Added `APP_ACCESS_KEY_ID`, `APP_SECRET_ACCESS_KEY`, `APP_REGION` to Amplify
261-
- Polly TTS confirmed working on deployed site
26254

263-
### 2026-03-05 — Fix COEP header for map tiles
55+
## Architecture
26456

265-
- Changed `Cross-Origin-Embedder-Policy` from `require-corp` to `credentialless`
266-
- Updated both `next.config.ts` and Amplify custom headers
57+
See [`DOCS.md`](DOCS.md) for the full architecture reference, and [`Amazon_usage.md`](Amazon_usage.md) for AWS service details.

0 commit comments

Comments
 (0)