Skip to content

Commit 9ff91c5

Browse files
authored
Merge pull request #185 from AAdewunmi/chore/add-multi-surface-demo-script
Chore/add multi surface demo script
2 parents 9f62372 + 450db6f commit 9ff91c5

5 files changed

Lines changed: 186 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ media/
2121
!.env.example
2222
!.env.template
2323
!.env.sample
24+
.curl-auth
2425

2526
# Tooling
2627
.pytest_cache/

docs/DEMO_SCRIPT.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
```markdown
3+
# path: docs/DEMO_SCRIPT.md
4+
5+
# PolicyLens Sprint 7 demo script
6+
7+
This demo is a multi-surface proof. The goal is showing reviewer and customer surfaces behaving consistently, and showing pagination on page 2 as an explicit validation step. Evidence export is included as the audit-grade finish, and it is validated as both JSON and PDF.
8+
9+
The quickest path is running the demo shell script, because it seeds deterministic records and prints a claim id you can use for export checks. A manual path is included so the demo remains understandable even when run without automation.
10+
11+
## Automated path
12+
13+
Run the demo script from the repository root.
14+
15+
```bash
16+
bash scripts/demo.sh

sample-claim-changed.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"policy_id": 1,
3+
"claim_type": "CLAIM",
4+
"priority": "HIGH",
5+
"summary": "Idempotency demo claim changed payload."
6+
}

sample-claim.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"policy_id": 1,
3+
"claim_type": "CLAIM",
4+
"priority": "NORMAL",
5+
"summary": "Idempotency demo claim."
6+
}

scripts/demo.sh

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
COMPOSE_FILE="${COMPOSE_FILE:-docker/docker-compose.prod.yml}"
6+
PROXY_URL="${PROXY_URL:-http://localhost:8080}"
7+
8+
echo "PolicyLens Sprint 7 demo"
9+
echo ""
10+
echo "Compose file: ${COMPOSE_FILE}"
11+
echo "Public URL (proxy): ${PROXY_URL}"
12+
echo ""
13+
14+
command -v docker >/dev/null 2>&1 || { echo "docker is required"; exit 1; }
15+
docker compose version >/dev/null 2>&1 || { echo "docker compose is required"; exit 1; }
16+
17+
if [[ "${COMPOSE_FILE}" != *prod* ]]; then
18+
echo "This script is intended for prod-shaped compose files."
19+
echo "Use COMPOSE_FILE=docker/docker-compose.prod.yml (or prod.secure.yml)."
20+
exit 1
21+
fi
22+
23+
COMPOSE_CMD=(docker compose -f "${COMPOSE_FILE}")
24+
25+
echo "Starting prod-shaped stack"
26+
echo ""
27+
"${COMPOSE_CMD[@]}" up --build -d
28+
29+
echo ""
30+
echo "Applying migrations"
31+
echo ""
32+
"${COMPOSE_CMD[@]}" exec -T web python manage.py migrate --noinput
33+
34+
echo ""
35+
echo "Seeding baseline records"
36+
echo ""
37+
"${COMPOSE_CMD[@]}" exec -T web python manage.py seed_sample_data
38+
39+
echo ""
40+
echo "Creating deterministic demo data for pagination on both surfaces"
41+
echo ""
42+
43+
DEMO_OUTPUT="$(
44+
"${COMPOSE_CMD[@]}" exec -T web python manage.py shell -c '
45+
from __future__ import annotations
46+
47+
from django.contrib.auth import get_user_model
48+
from django.contrib.auth.models import Group
49+
from policylens.apps.claims.models import Claim, Policy, PolicyHolder
50+
51+
User = get_user_model()
52+
53+
customer_group, _ = Group.objects.get_or_create(name="customer")
54+
55+
u, _ = User.objects.get_or_create(
56+
username="demo_customer",
57+
defaults={"email": "demo_customer@example.com"},
58+
)
59+
u.set_password("pass-12345-strong")
60+
u.save()
61+
u.groups.add(customer_group)
62+
63+
holder, _ = PolicyHolder.objects.get_or_create(
64+
email="demo_customer@example.com",
65+
defaults={"full_name": "Demo Customer", "phone": ""},
66+
)
67+
policy, _ = Policy.objects.get_or_create(
68+
policy_number="PL-DEMO-CUST",
69+
defaults={
70+
"holder": holder,
71+
"product_type": "Home Insurance",
72+
"status": Policy.Status.ACTIVE,
73+
},
74+
)
75+
76+
customer_existing = Claim.objects.filter(created_by=u.username).count()
77+
customer_target = 25
78+
customer_needed = max(0, customer_target - customer_existing)
79+
80+
for i in range(customer_needed):
81+
Claim.objects.create(
82+
policy=policy,
83+
claim_type=Claim.Type.CLAIM,
84+
status=Claim.Status.NEW,
85+
priority=Claim.Priority.NORMAL,
86+
summary=f"Demo customer claim {i + 1 + customer_existing}",
87+
created_by=u.username,
88+
)
89+
90+
ops_existing = Claim.objects.count()
91+
ops_target = 35
92+
ops_needed = max(0, ops_target - ops_existing)
93+
94+
for i in range(ops_needed):
95+
Claim.objects.create(
96+
policy=policy,
97+
claim_type=Claim.Type.CLAIM,
98+
status=Claim.Status.NEW,
99+
priority=Claim.Priority.NORMAL,
100+
summary=f"Demo ops claim {i + 1}",
101+
created_by="demo_seed",
102+
)
103+
104+
claim_for_export = Claim.objects.order_by("-created_at", "id").first()
105+
print(f"DEMO_CUSTOMER=demo_customer")
106+
print(f"DEMO_CUSTOMER_PASSWORD=pass-12345-strong")
107+
print(f"DEMO_POLICY_NUMBER=PL-DEMO-CUST")
108+
print(f"DEMO_CLAIM_ID_FOR_EXPORT={claim_for_export.id if claim_for_export else 0}")
109+
'
110+
)"
111+
112+
echo "${DEMO_OUTPUT}"
113+
echo ""
114+
115+
DEMO_CLAIM_ID_FOR_EXPORT="$(echo "${DEMO_OUTPUT}" | awk -F= '/DEMO_CLAIM_ID_FOR_EXPORT/ {print $2}' | tr -d '\r')"
116+
117+
echo "Health check (proxy)"
118+
echo ""
119+
curl -i "${PROXY_URL}/api/health/" | head -n 20
120+
echo ""
121+
122+
echo "Routing proof for paginated URLs through proxy"
123+
echo ""
124+
curl -I "${PROXY_URL}/ops/queue/?page=2" | head -n 20
125+
echo ""
126+
curl -I "${PROXY_URL}/customer/?page=2" | head -n 20
127+
echo ""
128+
129+
echo "Reviewer surface URLs"
130+
echo ""
131+
echo "${PROXY_URL}/login/reviewer/"
132+
echo "${PROXY_URL}/ops/queue/?page=1"
133+
echo "${PROXY_URL}/ops/queue/?page=2"
134+
echo ""
135+
echo "Customer surface URLs"
136+
echo ""
137+
echo "${PROXY_URL}/login/customer/"
138+
echo "${PROXY_URL}/customer/?page=1"
139+
echo "${PROXY_URL}/customer/?page=2"
140+
echo ""
141+
142+
echo "Evidence export URLs for claim id ${DEMO_CLAIM_ID_FOR_EXPORT}"
143+
echo ""
144+
echo "JSON export"
145+
echo "curl -i -u reviewer1:password123 \"${PROXY_URL}/api/claims/${DEMO_CLAIM_ID_FOR_EXPORT}/audit-export/\""
146+
echo ""
147+
echo "Fetching JSON export into ./claim_${DEMO_CLAIM_ID_FOR_EXPORT}_audit_export.json"
148+
echo ""
149+
curl -sS -u reviewer1:password123 \
150+
"${PROXY_URL}/api/claims/${DEMO_CLAIM_ID_FOR_EXPORT}/audit-export/" \
151+
-o "claim_${DEMO_CLAIM_ID_FOR_EXPORT}_audit_export.json"
152+
153+
echo ""
154+
echo "PDF export is pending implementation in a follow-up issue."
155+
156+
echo ""
157+
echo "Done"

0 commit comments

Comments
 (0)