Skip to content

Commit 1a558a4

Browse files
author
suhas
committed
new Jan26
1 parent 8f8cb8e commit 1a558a4

50 files changed

Lines changed: 3460 additions & 456 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ npm-debug.log*
55
yarn-error.log*
66
*.tmp
77
*.swp
8-
.reserverd_ngrok_domains
8+
99
# Environment
1010
.env
1111
.env.*
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cells": [],
3+
"metadata": {},
4+
"nbformat": 4,
5+
"nbformat_minor": 5
6+
}

03. Participant_Information.pdf

180 KB
Binary file not shown.

CLOUD_RUN_SINGLE_NGROK.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This file contains copy-paste friendly commands (PowerShell) to run all services
2323
# ============================
2424
# 0) Optional clean up (only if needed)
2525
# ============================
26-
# docker rm -f abacws-survey-mongo abacws-api abacws-visualiser rasa-frontend-bldg1 abacws-sender abacws-survey-ngrok
26+
# docker rm -f abacws-mongo abacws-api abacws-visualiser rasa-frontend-bldg1 abacws-sender abacws-survey-ngrok
2727
# docker network rm survey-network
2828
# docker volume rm mongo-data
2929
@@ -36,17 +36,18 @@ docker volume create mongo-data
3636
# ============================
3737
# 2) MongoDB
3838
# ============================
39-
docker run -d --name abacws-survey-mongo --network survey-network -p 27017:27017 `
39+
docker run -d --name abacws-mongo --network survey-network --network-alias mongo -p 27017:27017 `
4040
-v mongo-data:/data/db `
41-
--restart always mongo
41+
--restart always mongo:4.4
4242
4343
# ============================
4444
# 3) API
4545
# ============================
4646
docker build -t abacws-api-img ./api
4747
docker run -d --name abacws-api --network survey-network --hostname apihost -p 5000:5000 `
4848
-e API_PORT=5000 `
49-
-e MONGODB_URI=mongodb://abacws-survey-mongo:27017/abacws `
49+
-e MONGO_URL=mongodb://abacws-mongo:27017 `
50+
-e MONGODB_URI=mongodb://abacws-mongo:27017/abacws `
5051
-e JWT_SECRET=change-this-jwt-secret-in-production-use-strong-random-string `
5152
-e SESSION_SECRET=change-this-secret-in-production `
5253
-e API_KEY=V3rySecur3Pas3word `
@@ -114,7 +115,7 @@ docker logs --tail 200 abacws-api
114115
# 9) Useful logs
115116
# ============================
116117
docker logs -f abacws-api
117-
docker logs -f abacws-survey-mongo
118+
docker logs -f abacws-mongo
118119
docker logs -f abacws-visualiser
119120
docker logs -f rasa-frontend-bldg1
120121
docker logs -f abacws-sender
@@ -123,8 +124,8 @@ docker logs -f abacws-survey-ngrok
123124
# ============================
124125
# 10) Stop / Remove (when done)
125126
# ============================
126-
# docker stop abacws-survey-mongo abacws-api abacws-visualiser rasa-frontend-bldg1 abacws-sender abacws-survey-ngrok
127-
# docker rm abacws-survey-mongo abacws-api abacws-visualiser rasa-frontend-bldg1 abacws-sender abacws-survey-ngrok
127+
# docker stop abacws-mongo abacws-api abacws-visualiser rasa-frontend-bldg1 abacws-sender abacws-survey-ngrok
128+
# docker rm abacws-mongo abacws-api abacws-visualiser rasa-frontend-bldg1 abacws-sender abacws-survey-ngrok
128129
```
129130

130131
---

CLOUD_RUN_WITH_NGROK_API_ALT.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Notes
1111
# ============================
1212
# 0) Optional clean up (only if needed)
1313
# ============================
14-
# docker rm -f abacws-survey-mongo abacws-api abacws-visualiser rasa-frontend-bldg1 abacws-sender abacws-survey-ngrok
14+
# docker rm -f abacws-mongo abacws-api abacws-visualiser rasa-frontend-bldg1 abacws-sender abacws-survey-ngrok
1515
# docker network rm survey-network
1616
# docker volume rm mongo-data
1717
@@ -24,15 +24,16 @@ docker volume create mongo-data
2424
# ============================
2525
# 2) MongoDB
2626
# ============================
27-
docker run -d --name abacws-survey-mongo --network survey-network -p 27017:27017 -v mongo-data:/data/db --restart always mongo
27+
docker run -d --name abacws-mongo --network survey-network --network-alias mongo -p 27017:27017 -v mongo-data:/data/db --restart always mongo
2828
2929
# ============================
3030
# 3) API
3131
# ============================
3232
docker build -t abacws-api-img ./api
3333
docker run -d --name abacws-api --network survey-network --hostname apihost -p 5000:5000 `
3434
-e API_PORT=5000 `
35-
-e MONGO_URL=mongodb://abacws-survey-mongo:27017 `
35+
-e MONGO_URL=mongodb://abacws-mongo:27017 `
36+
-e MONGODB_URI=mongodb://abacws-mongo:27017/abacws-survey `
3637
-e JWT_SECRET=change-this-jwt-secret-in-production-use-strong-random-string `
3738
-e SESSION_SECRET=change-this-secret-in-production `
3839
-e API_KEY=V3rySecur3Pas3word `

README.md

Lines changed: 100 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,48 @@ Key endpoints (see full `api/openapi.yaml`):
307307
- GET /query/data — filter devices and last data
308308
- GET /query/history — filter devices and their history
309309

310+
### Survey data export via curl (users, questions, chat)
311+
312+
You can retrieve survey users and inputs through the Survey router. Admin endpoints are currently open (no auth), while per-user endpoints require a login cookie.
313+
314+
- All survey questions grouped by user (admin, no auth):
315+
316+
```sh
317+
curl -s http://localhost:5000/api/survey/admin/questions | jq '.'
318+
# via API ngrok (if enabled):
319+
curl -s https://swayable-katia-nondevelopmentally.ngrok-free.dev/api/survey/admin/questions | jq '.'
320+
```
321+
322+
- Survey stats (totals and top contributors) (admin, no auth):
323+
324+
```sh
325+
curl -s http://localhost:5000/api/survey/admin/stats | jq '.'
326+
# via API ngrok:
327+
curl -s https://swayable-katia-nondevelopmentally.ngrok-free.dev/api/survey/admin/stats | jq '.'
328+
```
329+
330+
- Per-user flows (login, then fetch that user’s data):
331+
332+
```sh
333+
# 1) Login and capture auth cookie
334+
curl -s -c cookies.txt -H 'Content-Type: application/json' \
335+
-d '{"username":"alice","password":"test123456"}' \
336+
http://localhost:5000/api/survey/login | jq '.'
337+
338+
# 2) Get this user’s submitted questions (requires cookie)
339+
curl -s -b cookies.txt http://localhost:5000/api/survey/questions | jq '.'
340+
341+
# 3) Get this user’s chat history (requires cookie)
342+
curl -s -b cookies.txt http://localhost:5000/api/survey/get_history | jq '.'
343+
```
344+
345+
Notes about “all Mongo users”:
346+
- A direct "list all registered users" endpoint isn’t exposed yet. Today, you can approximate the active user list from `/api/survey/admin/questions` keys (users who submitted questions).
347+
- If you need a complete list of registered users (including those with no questions), either:
348+
- Query Mongo directly (e.g. `mongosh` against DB `survey_db`, collection `users`), or
349+
- Add a small endpoint (e.g. `GET /api/survey/admin/users`) that returns `users` collection (we can implement this on request).
350+
351+
310352
Persistence engines:
311353
* MongoDB (container `abacws-mongo`). Historical data per device is stored in per-device collections.
312354
* PostgreSQL (container `abacws-postgres`). Tables:
@@ -505,35 +547,37 @@ With Docker:
505547

506548
```sh
507549
# Stop containers if present (ignore errors)
508-
docker stop rasa-frontend-bldg1 abacws-visualiser abacws-api abacws-survey-mongo abacws-survey-ngrok 2>/dev/null || true
550+
docker stop rasa-frontend-bldg1 abacws-visualiser abacws-api abacws-mongo abacws-survey-ngrok 2>/dev/null || true
509551

510552
# Remove containers (ignore errors)
511-
docker rm rasa-frontend-bldg1 abacws-visualiser abacws-api abacws-survey-mongo abacws-survey-ngrok 2>/dev/null || true
553+
docker rm rasa-frontend-bldg1 abacws-visualiser abacws-api abacws-mongo abacws-survey-ngrok 2>/dev/null || true
512554
```
513555

514-
### 1) Create Docker network and Mongo volume
556+
### 1) Create Docker network and Mongo data directory
515557

516558
```sh
517559
# Create app network if it does not exist
518560
docker network inspect survey-network >/dev/null 2>&1 || docker network create survey-network
519561

520-
# Create Mongo volume if it does not exist
521-
docker volume ls | grep -q "mongo-data" || docker volume create mongo-data
562+
# Create Mongo data directory if it does not exist
563+
mkdir -p Mongo/mongo-data
522564
```
523565

524566
### 2) Start MongoDB
525567

526568
```sh
527-
docker run -d --name abacws-survey-mongo \
569+
docker run -d --name abacws-mongo \
528570
--network survey-network \
571+
--network-alias mongo \
529572
-p 27017:27017 \
530-
-v mongo-data:/data/db \
573+
-v "$PWD/Mongo/mongo-data:/data/db" \
574+
--restart always \
531575
mongo:4.4
532576
```
533577

534578
Verify:
535579
```sh
536-
docker ps | grep abacws-survey-mongo
580+
docker ps | grep abacws-mongo
537581
```
538582

539583
### 3) Build images (API, Visualiser, Frontend)
@@ -557,7 +601,8 @@ With Docker:
557601
docker run -d --name abacws-api \
558602
--network survey-network \
559603
-p 5000:5000 \
560-
-e MONGODB_URI="mongodb://abacws-survey-mongo:27017/abacws-survey" \
604+
-e MONGO_URL="mongodb://abacws-mongo:27017" \
605+
-e MONGODB_URI="mongodb://abacws-mongo:27017/abacws-survey" \
561606
-e JWT_SECRET="<YOUR_JWT_SECRET>" \
562607
abacws-api-img
563608
```
@@ -656,16 +701,16 @@ With Docker:
656701

657702
```sh
658703
# Stop
659-
docker stop rasa-frontend-bldg1 abacws-visualiser abacws-api abacws-survey-ngrok abacws-survey-mongo
704+
docker stop rasa-frontend-bldg1 abacws-visualiser abacws-api abacws-survey-ngrok abacws-mongo
660705

661706
# Remove
662-
docker rm rasa-frontend-bldg1 abacws-visualiser abacws-api abacws-survey-ngrok abacws-survey-mongo
707+
docker rm rasa-frontend-bldg1 abacws-visualiser abacws-api abacws-survey-ngrok abacws-mongo
663708

664709
# Optional: remove images
665710
# docker rmi rasa-frontend-img abacws-visualiser-img abacws-api-img
666711

667-
# Optional: keep or remove Mongo data volume
668-
# docker volume rm mongo-data
712+
# Optional: archive or remove Mongo data directory
713+
# rm -rf Mongo/mongo-data
669714
```
670715

671716
---
@@ -683,25 +728,27 @@ With Docker:
683728

684729
set -e
685730

686-
# 0) Ensure network and volume
687-
echo "[0/10] Ensuring network and volume exist"
731+
# 0) Ensure network and data directory
732+
echo "[0/10] Ensuring network and data directory exist"
688733
docker network inspect survey-network >/dev/null 2>&1 || docker network create survey-network
689-
(docker volume ls | grep -q "mongo-data") || docker volume create mongo-data
734+
mkdir -p Mongo/mongo-data
690735

691736
# 1) Stop containers (ignore failures)
692737
echo "[1/10] Stopping containers (if any)"
693-
docker stop rasa-frontend-bldg1 abacws-visualiser abacws-api abacws-survey-mongo abacws-survey-ngrok 2>/dev/null || true
738+
docker stop rasa-frontend-bldg1 abacws-visualiser abacws-api abacws-mongo abacws-survey-ngrok 2>/dev/null || true
694739

695740
# 2) Remove containers (ignore failures)
696741
echo "[2/10] Removing containers"
697-
docker rm rasa-frontend-bldg1 abacws-visualiser abacws-api abacws-survey-mongo abacws-survey-ngrok 2>/dev/null || true
742+
docker rm rasa-frontend-bldg1 abacws-visualiser abacws-api abacws-mongo abacws-survey-ngrok 2>/dev/null || true
698743

699-
# 3) Start MongoDB (persistent volume)
744+
# 3) Start MongoDB (bind mount directory)
700745
echo "[3/10] Starting MongoDB"
701-
docker run -d --name abacws-survey-mongo \
746+
docker run -d --name abacws-mongo \
702747
--network survey-network \
748+
--network-alias mongo \
703749
-p 27017:27017 \
704-
-v mongo-data:/data/db \
750+
-v "$PWD/Mongo/mongo-data:/data/db" \
751+
--restart always \
705752
mongo:4.4
706753

707754
# 4) Build API (no cache)
@@ -721,7 +768,8 @@ With Docker:
721768
docker run -d --name abacws-api \
722769
--network survey-network \
723770
-p 5000:5000 \
724-
-e MONGODB_URI="mongodb://abacws-survey-mongo:27017/abacws-survey" \
771+
-e MONGO_URL="mongodb://abacws-mongo:27017" \
772+
-e MONGODB_URI="mongodb://abacws-mongo:27017/abacws-survey" \
725773
-e JWT_SECRET="your-secret-key-here" \
726774
abacws-api-img
727775

@@ -774,23 +822,23 @@ With Docker:
774822
# 1. Create network (required for inter-container communication)
775823
docker network create survey-network
776824
777-
# 2. Create named volume for MongoDB (persistent storage)
778-
docker volume create mongo-data
825+
# 2. Create host directory for MongoDB (persistent storage)
826+
mkdir -p Mongo/mongo-data
779827
780-
# 3. Start MongoDB with named volume
781-
docker run -d --name abacws-mongo --network survey-network -p 27017:27017 -v mongo-data:/data/db --restart always mongo
828+
# 3. Start MongoDB with bind mount
829+
docker run -d --name abacws-mongo --network survey-network --network-alias mongo -p 27017:27017 -v "$PWD/Mongo/mongo-data:/data/db" --restart always mongo:4.4
782830
783831
# 4. Build and run API (depends on mongo)
784832
docker build -t abacws-api-img ./api
785-
docker run -d --name abacws-api --network survey-network --hostname apihost -p 5000:5000 -e API_PORT=5000 -e MONGO_URL=mongodb://abacws-mongo:27017 -e JWT_SECRET=change-this-jwt-secret-in-production-use-strong-random-string -e SESSION_SECRET=change-this-secret-in-production -e API_KEY=V3rySecur3Pas3word -v "${PWD}/api/src/api/data:/api/src/api/data" --restart always abacws-api-img
833+
docker run -d --name abacws-api --network survey-network --hostname apihost -p 5000:5000 -e API_PORT=5000 -e MONGO_URL=mongodb://abacws-mongo:27017 -e MONGODB_URI=mongodb://abacws-mongo:27017/abacws-survey -e JWT_SECRET=change-this-jwt-secret-in-production-use-strong-random-string -e SESSION_SECRET=change-this-secret-in-production -e API_KEY=V3rySecur3Pas3word -v "${PWD}/api/src/api/data:/api/src/api/data" --restart always abacws-api-img
786834
787835
# 5. Build and run Visualiser (depends on api)
788836
docker build -t abacws-visualiser-img ./visualiser
789837
docker run -d --name abacws-visualiser --network survey-network --hostname visualiserhost -p 8090:80 -e WEB_PORT=80 -e API_HOST=abacws-api:5000 --restart always abacws-visualiser-img
790838
791839
# 6. Build and run Rasa Frontend (depends on api)
792840
docker build -t rasa-frontend-img ./rasa-frontend
793-
docker run -d --name rasa-frontend-bldg1 --network survey-network --hostname rasa-frontend-host-bldg1 -p 3000:3000 -e NODE_ENV=development -e REACT_APP_API_URL=http://localhost:5000/api -e REACT_APP_VISUALIZER_URL=http://localhost:8090 -v "${PWD}/rasa-frontend:/app" -v /app/node_modules --restart unless-stopped rasa-frontend-img npm start
841+
docker run -d --name rasa-frontend-bldg1 --network survey-network --hostname rasa-frontend-host-bldg1 -p 3000:3000 -e NODE_ENV=development -v "${PWD}/rasa-frontend:/app" -v /app/node_modules --restart unless-stopped rasa-frontend-img npm start
794842
795843
# 7. Build and run Sender/Telemetry service (depends on api and visualiser)
796844
docker build -t abacws-sender-img -f telemetry/Dockerfile .
@@ -802,23 +850,28 @@ docker run -d --name abacws-sender --network survey-network -p 8088:8088 -e API_
802850
docker run -d -it --name abacws-survey-ngrok --network survey-network -e NGROK_AUTHTOKEN=351mX4l1QmwIH9QNq3TatjyErTf_3os4QyqSDSX614JkForyL -e NGROK_REGION=Global -p 4046:4040 ngrok/ngrok:latest http rasa-frontend-bldg1:3000 --domain=wimpishly-premonarchical-keyla.ngrok-free.dev
803851
804852
853+
extra domain-
854+
353dwLAqYq3fDf4gvmEzVzoM1gR_22wwdveXaYWMhRduTnbWA
855+
swayable-katia-nondevelopmentally.ngrok-free.dev
805856
# View ngrok logs and get public URL
806857
docker logs -f abacws-ngrok
807858
808-
859+
# Alternative: Expose via ngrok without custom domain (free tier, auto-generated URL)
860+
# docker run -d --name abacws-ngrok --network survey-network -e NGROK_AUTHTOKEN=351mX4l1QmwIH9QNq3TatjyErTf_3os4QyqSDSX614JkForyL --restart unless-stopped ngrok/ngrok:latest http --region=us rasa-frontend-bldg1:3000
809861
810862
# Public URLs:
811863
# - Reserved domain: https://wimpishly-premonarchical-keyla.ngrok-free.dev
812864
# - TinyURL redirect: https://tinyurl.com/talk2abacws-survey
813865
```
814866
815-
**To restore MongoDB from local mongo/ folder** (if you have existing data):
867+
**To restore MongoDB from a saved Mongo/ folder** (if you have existing data):
816868
```pwsh
817869
# Stop mongo container
818870
docker stop abacws-mongo
819871
820-
# Copy local mongo/ files into the named volume
821-
docker run --rm -v mongo-data:/data/db -v "${PWD}/mongo:/backup" mongo cp -r /backup/. /data/db/
872+
# Replace contents of the bind mount with your backup
873+
rm -rf Mongo/mongo-data/*
874+
cp -a /path/to/backup/. Mongo/mongo-data/
822875
823876
# Start mongo again
824877
docker start abacws-mongo
@@ -844,54 +897,30 @@ docker stop abacws-mongo abacws-api abacws-visualiser rasa-frontend-bldg1 abacws
844897
docker rm abacws-mongo abacws-api abacws-visualiser rasa-frontend-bldg1 abacws-sender abacws-ngrok
845898
```
846899
847-
**Remove network and volume** (WARNING: deletes all MongoDB data):
900+
**Remove network and data directory** (WARNING: deletes all MongoDB data):
848901
```pwsh
849902
docker network rm survey-network
850-
docker volume rm mongo-data
903+
rm -rf Mongo/mongo-data
851904
```
852905
853-
### Survey data export via curl (users, questions, chat)
854-
855-
You can retrieve survey users and inputs through the Survey router. Admin endpoints are currently open (no auth), while per-user endpoints require a login cookie.
856-
857-
- All survey questions grouped by user (admin, no auth):
858-
859-
```sh
860-
curl -s http://localhost:5000/api/survey/admin/questions | jq '.'
861-
# via API ngrok (if enabled):
862-
curl -s https://swayable-katia-nondevelopmentally.ngrok-free.dev/api/survey/admin/questions | jq '.'
906+
**see all responses locally using curl**
907+
```curl -s http://localhost:5000/api/survey/admin/questions | head
863908
```
864-
865-
- Survey stats (totals and top contributors) (admin, no auth):
866-
867-
```sh
868-
curl -s http://localhost:5000/api/survey/admin/stats | jq '.'
869-
# via API ngrok:
870-
curl -s https://swayable-katia-nondevelopmentally.ngrok-free.dev/api/survey/admin/stats | jq '.'
909+
<!-- or prettier print -->
871910
```
872911
873-
- Per-user flows (login, then fetch that user’s data):
874-
875-
```sh
876-
# 1) Login and capture auth cookie
877-
curl -s -c cookies.txt -H 'Content-Type: application/json' \
878-
-d '{"username":"alice","password":"test123456"}' \
879-
http://localhost:5000/api/survey/login | jq '.'
880-
881-
# 2) Get this user’s submitted questions (requires cookie)
882-
curl -s -b cookies.txt http://localhost:5000/api/survey/questions | jq '.'
912+
curl -s http://localhost:5000/api/survey/admin/questions | jq '.'
883913
884-
# 3) Get this user’s chat history (requires cookie)
885-
curl -s -b cookies.txt http://localhost:5000/api/survey/get_history | jq '.'
886914
```
887-
888-
Notes about “all Mongo users”:
889-
- A direct "list all registered users" endpoint isn’t exposed yet. Today, you can approximate the active user list from `/api/survey/admin/questions` keys (users who submitted questions).
890-
- If you need a complete list of registered users (including those with no questions), either:
891-
- Query Mongo directly (e.g. `mongosh` against DB `survey_db`, collection `users`), or
892-
- Add a small endpoint (e.g. `GET /api/survey/admin/users`) that returns `users` collection (we can implement this on request).
893-
894-
915+
<!-- or paste as one line the following command-->
916+
```
917+
curl -s http://localhost:5000/api/survey/admin/questions \
918+
| jq -r '.questionsByUser
919+
| to_entries[]
920+
| "\(.key)
921+
- " + (.value | map(.question) | join("\n - "))'
922+
```
923+
895924
## Contributing
896925
897926
PRs and issues welcome. Please run builds locally and sanity-check Docker compose before submitting.

0 commit comments

Comments
 (0)