# Event Organizer Safety-Compliance Service (SQLAlchemy + httpx)

## PURPOSE
The transcript records two distinct police instructions: organizers conducting festival
celebrations must make *mandatory advance security arrangements*, and *emergency exits must
always be kept ready*. This service is the backend that enforces those two rules. It keeps
a durable record of every Dasara/Diwali event organizer, their submitted security plan, and
their exit-readiness status, and it pulls the official police advisory over HTTP so
organizers see the current warning alongside their compliance state.

## WHY THIS MATTERS
A verbal instruction is unenforceable at festival scale. Turning "mandatory advance
security" into a database with status transitions (submitted → verified → compliant →
lapsed) makes the rule auditable. The httpx client shows how a service integrates with an
external authority feed rather than duplicating advisory text by hand.

## HOW TO BUILD
1. `pip install sqlalchemy httpx pydantic`.
2. Define a `FestivalEvent` ORM model: organizer, venue, festival, event_date,
   `security_plan_submitted`, `exits_ready`, `verified_on`.
3. Add a `ComplianceResult` view model computed from those flags.
4. Use `httpx.Client(timeout=5)` to fetch the police advisory; fall back gracefully when
   offline so the service still reports local compliance.
5. Expose functions `register_event`, `verify_event`, `compliance_report`.

Key snippet:
```python
def compliance_report(session, event_id):
    ev = session.get(FestivalEvent, event_id)
    ok = ev.security_plan_submitted and ev.exits_ready
    return {"organizer": ev.organizer, "compliant": ok,
            "reason": None if ok else "mandatory advance security / exits not ready"}

def fetch_advisory(client, url):
    r = client.get(url)           # external police advisory feed
    r.raise_for_status()
    return r.json()
```

## WHEN TO USE IN PRODUCTION
Ideal for a district festival-permissions desk issuing and tracking event clearances, or a
municipal portal where organizers upload plans. Use a real database (Postgres) behind
SQLAlchemy and add auth before any public deployment. Do **not** use this as the live
safety system during the event — it tracks paperwork and readiness, not real-time crowd
state; pair it with sensors for that.

## HOW IT HELPS STUDENTS
You practice ORM modeling, session management, external API integration with timeouts and
error handling, and translating a written regulation into enforceable state — exactly the
backend work civic-tech roles need.

## STARTER CODE
See `starter/main.py` for the SQLAlchemy models, a deterministic advisory-fetch stub, and
`# TODO` markers for auth and the HTTP endpoint layer.
