diff --git a/backend/app/activity.py b/backend/app/activity.py
index 032b945..a063384 100644
--- a/backend/app/activity.py
+++ b/backend/app/activity.py
@@ -22,6 +22,11 @@
"connect_decline",
"connect_withdraw",
"question",
+ "group_propose",
+ "group_join",
+ "group_vote",
+ "group_fix",
+ "board_post",
)
DETAIL_CHARS = 60
diff --git a/backend/app/config.py b/backend/app/config.py
index 96dd9cb..f319d1d 100644
--- a/backend/app/config.py
+++ b/backend/app/config.py
@@ -26,6 +26,7 @@ class Settings(BaseSettings):
idx_agenda: str = "confox-agenda"
idx_transcripts: str = "confox-transcripts"
idx_activity: str = "confox-activity"
+ idx_groups: str = "confox-groups"
# The demo runs on Emma's Monday morning. Leave DEMO_NOW empty to use the real clock in Salt Lake City.
demo_now: str = "2026-11-09T08:40:00"
diff --git a/backend/app/data/groups.py b/backend/app/data/groups.py
new file mode 100644
index 0000000..28205f7
--- /dev/null
+++ b/backend/app/data/groups.py
@@ -0,0 +1,145 @@
+"""Sample meetup groups for the demo, all marked sample=True.
+
+Hosts and members are generated sample attendees who really share the group's value (the Bangladesh meetup is the
+exception: no generated attendee is from Bangladesh, so its two members are simply interested). Emma is in none of
+them, so she can join, vote and propose her own during the demo. Slots are real food and coffee breaks.
+Four hallway board posts by sample attendees, tagged with their own interests, run until late Monday morning.
+"""
+
+from datetime import datetime, timedelta
+
+from ..groups_store import new_group, new_post
+
+DEMO_MORNING = "2026-11-09T08:" # seeded created_at minutes are appended
+
+
+def _break(sessions: list[dict], day: str, word: str, nth: int = 0) -> dict:
+ found = [s for s in sessions if s.get("is_food") and s["day"] == day and word in s["title"].lower()]
+ return sorted(found, key=lambda s: s["starts_at"])[nth]
+
+
+def _sharing(attendees: list[dict], field: str, value: str, n: int) -> list[dict]:
+ out = []
+ for p in attendees:
+ if p["id"] in ("emma", "alice"):
+ continue
+ v = p.get(field)
+ if value == v or (isinstance(v, list) and value in v):
+ out.append(p)
+ return out[:n]
+
+
+def _group(gid, host, members, basis, value, title, description, slots, votes, minute):
+ g = new_group(gid, host, basis, value, title, description, slots, at=None, sample=True)
+ for m in members:
+ g["members"].append(m["id"])
+ g["member_names"].append(m["name"])
+ for slot_index, voters in votes.items():
+ g["votes"][g["proposed_slots"][slot_index]["session_id"]] = [p["id"] for p in voters]
+ return g | {"created_at": f"{DEMO_MORNING}{minute:02d}:00"}
+
+
+def sample_groups(sessions: list[dict], attendees: list[dict]) -> list[dict]:
+ mon, tue, wed = "2026-11-09", "2026-11-10", "2026-11-11"
+ mon_lunch, mon_coffee_pm = _break(sessions, mon, "lunch"), _break(sessions, mon, "coffee", 1)
+ tue_coffee, tue_lunch, tue_coffee_pm = (
+ _break(sessions, tue, "coffee"),
+ _break(sessions, tue, "lunch"),
+ _break(sessions, tue, "coffee", 1),
+ )
+ wed_lunch = _break(sessions, wed, "lunch")
+
+ utah = _sharing(attendees, "schools", "University of Utah", 5)
+ wicn = _sharing(attendees, "communities", "Women in Cloud Native", 4)
+ kubeflow = _sharing(attendees, "interests", "Kubeflow", 4)
+ brazil = _sharing(attendees, "country", "Brazil", 3)
+ others = [p for p in attendees if p["id"] not in ("emma", "alice")]
+ bangladesh = [others[-1], others[-2]]
+
+ return [
+ _group(
+ "sample-grp-utah",
+ utah[0],
+ utah[1:4],
+ "school",
+ "University of Utah",
+ "University of Utah alumni lunch",
+ "Utes at KubeCon in our home town. Grab lunch together and swap stories from campus.",
+ [mon_lunch, tue_lunch, wed_lunch],
+ {0: utah[:3], 1: utah[1:3]},
+ 5,
+ ),
+ _group(
+ "sample-grp-bangladesh",
+ bangladesh[0],
+ bangladesh[1:],
+ "country",
+ "Bangladesh",
+ "Bangladesh meetup",
+ "From Bangladesh, or with family there? Say hello over coffee.",
+ [mon_coffee_pm, tue_coffee],
+ {1: bangladesh[:1]},
+ 12,
+ ),
+ _group(
+ "sample-grp-wicn",
+ wicn[0],
+ wicn[1:4],
+ "community",
+ "Women in Cloud Native",
+ "Women in Cloud Native coffee",
+ "Informal coffee for members and allies. Newcomers to KubeCon very welcome.",
+ [mon_coffee_pm, tue_coffee, tue_coffee_pm],
+ {0: wicn[:2], 1: wicn[1:4]},
+ 18,
+ ),
+ _group(
+ "sample-grp-kubeflow",
+ kubeflow[0],
+ kubeflow[1:3],
+ "interest",
+ "Kubeflow",
+ "Kubeflow users",
+ "Running Kubeflow in production? Compare pipelines, notebooks and serving setups.",
+ [tue_lunch, wed_lunch],
+ {0: kubeflow[:2]},
+ 24,
+ ),
+ _group(
+ "sample-grp-brazil",
+ brazil[0],
+ brazil[1:3],
+ "country",
+ "Brazil",
+ "Brasileiros na KubeCon",
+ "Everyone from Brazil: lunch and a chat in Portuguese.",
+ [tue_lunch, wed_lunch],
+ {1: brazil[:3]},
+ 31,
+ ),
+ ]
+
+
+# (minutes after 08:00 on the demo Monday, lasting minutes, interest the author must have, text, place)
+POSTS = [
+ (5, 180, "Cilium", "At the Cilium booth till 11:00, come talk eBPF and network policy.", "Project Pavilion"),
+ (15, 180, "GPU scheduling", "Anyone else fighting GPU fragmentation? Saving seats near the front.", "Room 254"),
+ (25, 180, "OpenTelemetry", "Coffee and OpenTelemetry questions by the registration desk.", "Hall A foyer"),
+ (32, 180, "Kubeflow", "Kubeflow pipelines on spot nodes: happy to compare notes before lunch.", ""),
+]
+
+
+def sample_posts(attendees: list[dict]) -> list[dict]:
+ """Hallway board posts, each by the first sample attendee (not Emma or Alice) into the post's topic."""
+ out = []
+ for i, (minute, minutes, tag, text, place) in enumerate(POSTS):
+ author = next(
+ p
+ for p in attendees
+ if p["id"] not in ("emma", "alice")
+ and tag in p.get("interests", [])
+ and p["id"] not in {o["author_id"] for o in out}
+ )
+ at = datetime.fromisoformat(f"{DEMO_MORNING}00:00") + timedelta(minutes=minute)
+ out.append(new_post(f"sample-post-{i + 1}", author, text, place, minutes, [tag], at=at, sample=True))
+ return out
diff --git a/backend/app/groups_store.py b/backend/app/groups_store.py
new file mode 100644
index 0000000..5a7d5c5
--- /dev/null
+++ b/backend/app/groups_store.py
@@ -0,0 +1,457 @@
+"""Meetup groups: people who share a school, country, company, community or interest meet at a food break.
+
+One document per group in `confox-groups`:
+
+ { title, basis: "school" | "country" | "company" | "community" | "interest", value ("University of Utah"),
+ description, host_id, host_name, members [ids, host first], member_names (same order), max_members,
+ proposed_slots [{session_id, title, starts_at, ends_at, room}] (1 to 3 food or coffee breaks),
+ votes {session_id: [user ids]}, fixed_slot (one of the proposed slots, or null), status: "open" | "fixed",
+ created_at, sample }
+
+Hallway board posts share the index with `type: "post"`:
+
+ { type: "post", text (<= 140 chars), place, tags (from the author's interests), author_id, author_name,
+ created_at, expires_at (30 minutes, 1 hour or 3 hours later), sample }
+
+When the host fixes a time every member gets a confirmed agenda meeting "Meetup:
" with the id
+"{user_id}-g-{group_id}", so joining or leaving a fixed group adds or removes exactly that one item.
+
+The rules are pure functions, tested without Elasticsearch; they raise GroupError with the HTTP status to answer.
+"""
+
+import secrets
+from datetime import datetime, timedelta
+
+from elasticsearch import NotFoundError
+
+from .agenda_store import meeting_title, stamp
+from .clock import now
+from .config import settings
+from .es import es
+
+BASES = ("school", "country", "company", "community", "interest")
+# Ranking and suggestion order: alumni ties first (the demo's headline), then where people are from.
+BASIS_ORDER = {b: i for i, b in enumerate(("school", "country", "community", "company", "interest"))}
+MAX_SLOTS = 3
+DEFAULT_MAX_MEMBERS = 12
+MAX_MEMBERS_CAP = 50
+TITLE_CHARS = 80
+DESCRIPTION_CHARS = 280
+MAX_SUGGESTIONS = 6
+
+# How each basis reads in a match reason and in a suggestion.
+MATCH_LABEL = {
+ "school": "You studied at {v}",
+ "country": "You are from {v}",
+ "company": "You work or worked at {v}",
+ "community": "You are in {v}",
+ "interest": "You are into {v}",
+}
+SUGGEST_TITLE = {
+ "school": "{v} alumni meetup",
+ "country": "{v} meetup",
+ "company": "{v} folks meetup",
+ "community": "{v} meetup",
+ "interest": "{v} meetup",
+}
+
+
+class GroupError(Exception):
+ def __init__(self, status: int, detail: str):
+ super().__init__(detail)
+ self.status = status
+ self.detail = detail
+
+
+# ---------- pure rules ----------
+
+
+def _list(v) -> list[str]:
+ if v is None or v == "":
+ return []
+ return [x for x in v if x] if isinstance(v, list) else [v]
+
+
+def profile_values(user: dict) -> dict[str, list[str]]:
+ """The user's own values per basis, in profile order. Company is the current one, then past ones."""
+ return {
+ "school": _list(user.get("schools")),
+ "country": _list(user.get("country")),
+ "company": list(dict.fromkeys(_list(user.get("company")) + _list(user.get("past_companies")))),
+ "community": _list(user.get("communities")),
+ "interest": _list(user.get("interests")),
+ }
+
+
+def group_id() -> str:
+ return f"grp-{secrets.token_hex(4)}"
+
+
+def agenda_item_id(user_id: str, gid: str) -> str:
+ return f"{user_id}-g-{gid}"
+
+
+def clean(text: str | None, limit: int) -> str:
+ return " ".join((text or "").split())[:limit]
+
+
+def slot_of(session: dict) -> dict:
+ """A proposed slot from a food or coffee break session (with `id`)."""
+ return {
+ "session_id": session["id"],
+ "title": meeting_title(session.get("title", "")),
+ "starts_at": session["starts_at"],
+ "ends_at": session["ends_at"],
+ "room": session.get("room"),
+ }
+
+
+def new_group(
+ gid: str,
+ host: dict,
+ basis: str,
+ value: str,
+ title: str,
+ description: str,
+ slots: list[dict],
+ max_members: int = DEFAULT_MAX_MEMBERS,
+ at: datetime | None = None,
+ sample: bool = False,
+) -> dict:
+ """A new open group with the host as its first member. `host` needs `id` and `name`; `slots` are break sessions."""
+ if basis not in BASES:
+ raise GroupError(422, f"basis must be one of {', '.join(BASES)}")
+ value = clean(value, TITLE_CHARS)
+ if not value:
+ raise GroupError(422, "value is required")
+ ids = [s["id"] for s in slots]
+ if not 1 <= len(ids) <= MAX_SLOTS or len(set(ids)) != len(ids):
+ raise GroupError(422, f"pick 1 to {MAX_SLOTS} different times")
+ proposed = sorted((slot_of(s) for s in slots), key=lambda s: (s["starts_at"], s["session_id"]))
+ return {
+ "id": gid,
+ "type": "group",
+ "title": clean(title, TITLE_CHARS) or SUGGEST_TITLE[basis].format(v=value),
+ "basis": basis,
+ "value": value,
+ "description": clean(description, DESCRIPTION_CHARS),
+ "host_id": host["id"],
+ "host_name": host.get("name") or host["id"],
+ "members": [host["id"]],
+ "member_names": [host.get("name") or host["id"]],
+ "max_members": max(2, min(int(max_members or DEFAULT_MAX_MEMBERS), MAX_MEMBERS_CAP)),
+ "proposed_slots": proposed,
+ "votes": {s["session_id"]: [] for s in proposed},
+ "fixed_slot": None,
+ "status": "open",
+ "created_at": stamp(at),
+ "sample": sample,
+ }
+
+
+def match_reason(group: dict, user: dict) -> dict | None:
+ """Why this group is relevant to the user: the group's value is one of theirs for the same basis."""
+ basis, value = group.get("basis"), group.get("value")
+ if basis in BASIS_ORDER and value in profile_values(user)[basis]:
+ return {"basis": basis, "value": value, "label": MATCH_LABEL[basis].format(v=value)}
+ return None
+
+
+def is_member(group: dict, user_id: str) -> bool:
+ return user_id in (group.get("members") or [])
+
+
+def tally(group: dict, user_id: str = "") -> list[dict]:
+ """Proposed slots in time order, each with its vote count and whether `user_id` voted for it."""
+ votes = group.get("votes") or {}
+ out = []
+ for s in sorted(group.get("proposed_slots") or [], key=lambda s: (s["starts_at"], s["session_id"])):
+ voters = votes.get(s["session_id"]) or []
+ out.append(s | {"votes": len(voters), "voted": user_id in voters})
+ return out
+
+
+def leading_slot(group: dict) -> str | None:
+ """The slot with most votes (earliest on a tie), or None when nobody has voted."""
+ ranked = sorted(tally(group), key=lambda s: (-s["votes"], s["starts_at"]))
+ return ranked[0]["session_id"] if ranked and ranked[0]["votes"] else None
+
+
+def view(group: dict, user_id: str, user: dict | None = None) -> dict:
+ """The group as the API returns it to one user."""
+ members = group.get("members") or []
+ return group | {
+ "member_count": len(members),
+ "spots_left": max(0, (group.get("max_members") or DEFAULT_MAX_MEMBERS) - len(members)),
+ "is_member": user_id in members,
+ "is_host": group.get("host_id") == user_id,
+ "match": match_reason(group, user) if user else None,
+ "tally": tally(group, user_id),
+ "leading": leading_slot(group),
+ }
+
+
+def _rank_key(group: dict, user: dict) -> tuple:
+ reason = match_reason(group, user)
+ return (
+ reason is None, # groups sharing one of the user's values first
+ BASIS_ORDER[reason["basis"]] if reason else 0,
+ group.get("status") != "open", # still deciding before already fixed
+ -len(group.get("members") or []),
+ group.get("created_at") or "",
+ group.get("id") or "",
+ )
+
+
+def rank(groups: list[dict], user_id: str, user: dict) -> dict:
+ """{"groups": others ranked for the user, "mine": groups they host or joined, earliest fixed time first}."""
+ mine = [g for g in groups if is_member(g, user_id)]
+ others = [g for g in groups if not is_member(g, user_id)]
+ others.sort(key=lambda g: _rank_key(g, user))
+ mine.sort(key=lambda g: ((g.get("fixed_slot") or {}).get("starts_at") or "9", g.get("created_at") or ""))
+ return {"groups": [view(g, user_id, user) for g in others], "mine": [view(g, user_id, user) for g in mine]}
+
+
+def join(group: dict, user_id: str, name: str) -> dict:
+ """The group with the user added. Joining twice is a no-op; a full group refuses (409)."""
+ if is_member(group, user_id):
+ return group
+ members = group.get("members") or []
+ if len(members) >= (group.get("max_members") or DEFAULT_MAX_MEMBERS):
+ raise GroupError(409, "this group is full")
+ return group | {"members": members + [user_id], "member_names": (group.get("member_names") or []) + [name]}
+
+
+def leave(group: dict, user_id: str) -> dict:
+ """The group without the user, their votes removed too. The host cannot leave their own group (409)."""
+ if group.get("host_id") == user_id:
+ raise GroupError(409, "the host cannot leave their own group")
+ members = group.get("members") or []
+ if user_id not in members:
+ return group
+ i = members.index(user_id)
+ names = list(group.get("member_names") or [])
+ votes = {sid: [u for u in voters if u != user_id] for sid, voters in (group.get("votes") or {}).items()}
+ return group | {
+ "members": members[:i] + members[i + 1 :],
+ "member_names": names[:i] + names[i + 1 :],
+ "votes": votes,
+ }
+
+
+def proposed(group: dict, session_id: str) -> dict:
+ slot = next((s for s in group.get("proposed_slots") or [] if s["session_id"] == session_id), None)
+ if slot is None:
+ raise GroupError(422, f"{session_id} is not one of this group's proposed times")
+ return slot
+
+
+def vote(group: dict, user_id: str, session_id: str, on: bool = True) -> dict:
+ """Mark (or unmark) one proposed time the member can make. Members may vote for several times."""
+ if group.get("status") != "open":
+ raise GroupError(409, "the time is already fixed")
+ if not is_member(group, user_id):
+ raise GroupError(403, "join the group to vote")
+ proposed(group, session_id)
+ votes = {sid: list(voters) for sid, voters in (group.get("votes") or {}).items()}
+ voters = [u for u in votes.get(session_id, []) if u != user_id]
+ votes[session_id] = voters + [user_id] if on else voters
+ return group | {"votes": votes}
+
+
+def fix(group: dict, user_id: str, session_id: str) -> dict:
+ """The host fixes one of the proposed times; the group becomes `fixed` (once)."""
+ if group.get("host_id") != user_id:
+ raise GroupError(403, "only the host can fix the time")
+ if group.get("status") != "open":
+ raise GroupError(409, "the time is already fixed")
+ return group | {"status": "fixed", "fixed_slot": proposed(group, session_id)}
+
+
+def agenda_item(group: dict, user_id: str, at: datetime | None = None) -> dict:
+ """The confirmed agenda meeting a member gets once the time is fixed."""
+ slot = group["fixed_slot"]
+ return {
+ "id": agenda_item_id(user_id, group["id"]),
+ "user_id": user_id,
+ "kind": "meeting",
+ "status": "confirmed",
+ "group_id": group["id"],
+ "with_id": group["id"],
+ "with_name": group["title"],
+ "session_id": slot["session_id"],
+ "title": f"Meetup: {group['title']}",
+ "starts_at": slot["starts_at"],
+ "ends_at": slot["ends_at"],
+ "room": slot.get("room"),
+ "sample": bool(group.get("sample")) and user_id != settings.demo_user,
+ "created_at": stamp(at),
+ }
+
+
+def suggest_aggs(user_id: str, user: dict) -> dict:
+ """One filters aggregation per basis, a bucket per value of the user's; the user is excluded in the query."""
+ fields = {"school": ["schools"], "country": ["country"], "community": ["communities"], "interest": ["interests"]}
+ fields["company"] = ["company", "past_companies"]
+ aggs = {}
+ for basis, values in profile_values(user).items():
+ if not values:
+ continue
+ buckets = {}
+ for v in values:
+ clauses = [{"term": {f: v}} for f in fields[basis]]
+ buckets[v] = clauses[0] if len(clauses) == 1 else {"bool": {"should": clauses, "minimum_should_match": 1}}
+ aggs[basis] = {"filters": {"filters": buckets}}
+ return aggs
+
+
+def suggestions(user: dict, aggs: dict, groups: list[dict], limit: int = MAX_SUGGESTIONS) -> list[dict]:
+ """Values the user shares with others, most telling basis first, then by how many people share them.
+
+ Each says how many open groups already exist for it, so the page can point at them instead of a duplicate.
+ """
+ out = []
+ for basis, values in profile_values(user).items():
+ buckets = aggs.get(basis, {}).get("buckets", {})
+ for order, v in enumerate(values):
+ count = buckets.get(v, {}).get("doc_count", 0)
+ if not count:
+ continue
+ existing = [g["id"] for g in groups if g.get("basis") == basis and g.get("value") == v]
+ out.append(
+ {
+ "basis": basis,
+ "value": v,
+ "count": count,
+ "label": f"{v} · {count} {'person' if count == 1 else 'people'} here",
+ "title": SUGGEST_TITLE[basis].format(v=v),
+ "existing": existing,
+ "_order": (BASIS_ORDER[basis], -count, order),
+ }
+ )
+ out.sort(key=lambda s: s.pop("_order"))
+ return out[:limit]
+
+
+# ---------- hallway board ----------
+
+POST_CHARS = 140
+PLACE_CHARS = 60
+POST_MINUTES = (30, 60, 180)
+MAX_TAGS = 3
+BOARD_SIZE = 40
+
+
+def post_id() -> str:
+ return f"post-{secrets.token_hex(4)}"
+
+
+def new_post(
+ pid: str,
+ author: dict,
+ text: str,
+ place: str = "",
+ minutes: int = 60,
+ tags: list[str] | None = None,
+ at: datetime | None = None,
+ sample: bool = False,
+) -> dict:
+ """A board post. Tags are kept only when they are the author's own interests (at most three)."""
+ text = clean(text, POST_CHARS)
+ if not text:
+ raise GroupError(422, "write something to post")
+ if minutes not in POST_MINUTES:
+ raise GroupError(422, "a post lasts 30, 60 or 180 minutes")
+ start = (at or now()).replace(microsecond=0)
+ own = profile_values(author)["interest"]
+ return {
+ "id": pid,
+ "type": "post",
+ "text": text,
+ "place": clean(place, PLACE_CHARS),
+ "tags": [t for t in own if t in set(tags or [])][:MAX_TAGS],
+ "author_id": author["id"],
+ "author_name": author.get("name") or author["id"],
+ "created_at": stamp(start),
+ "expires_at": stamp(start + timedelta(minutes=minutes)),
+ "sample": sample,
+ }
+
+
+def board(posts: list[dict], groups: list[dict], user_id: str, user: dict, at: datetime) -> list[dict]:
+ """The hallway feed, newest first: live posts (each says if it matches the viewer's interests and if it is
+ theirs) and meetup groups still to happen (open, or fixed and not yet over)."""
+ at_iso = stamp(at)
+ mine = {i.lower() for i in profile_values(user)["interest"]}
+ items = []
+ for p in posts:
+ if (p.get("expires_at") or "") <= at_iso:
+ continue
+ matching = [t for t in p.get("tags") or [] if t.lower() in mine]
+ items.append(
+ p | {"kind": "post", "for_you": bool(matching), "matching": matching, "mine": p["author_id"] == user_id}
+ )
+ for g in groups:
+ fixed = g.get("fixed_slot") or {}
+ if g.get("status") == "fixed" and (fixed.get("ends_at") or "") <= at_iso:
+ continue
+ reason = match_reason(g, user)
+ items.append(
+ {
+ "kind": "group",
+ "id": g["id"],
+ "title": g.get("title"),
+ "basis": g.get("basis"),
+ "value": g.get("value"),
+ "status": g.get("status"),
+ "fixed_slot": g.get("fixed_slot"),
+ "member_count": len(g.get("members") or []),
+ "author_name": g.get("host_name"),
+ "created_at": g.get("created_at"),
+ "for_you": reason is not None,
+ "is_member": is_member(g, user_id),
+ "sample": bool(g.get("sample")),
+ }
+ )
+ items.sort(key=lambda i: (i.get("created_at") or "", i["id"]), reverse=True)
+ return items[:BOARD_SIZE]
+
+
+def remove_check(post: dict, user_id: str) -> None:
+ if post.get("type") != "post":
+ raise GroupError(404, "no such post")
+ if post.get("author_id") != user_id:
+ raise GroupError(403, "only the author can remove a post")
+
+
+# ---------- Elasticsearch ----------
+
+
+def get(gid: str, kind: str = "group") -> tuple[dict, dict]:
+ """The group (or, with kind "post", the board post) and its concurrency token ({if_seq_no, if_primary_term});
+ 404 when missing or of the other kind."""
+ try:
+ doc = es.get(index=settings.idx_groups, id=gid)
+ except NotFoundError as exc:
+ raise GroupError(404, f"no {kind} {gid}") from exc
+ if (doc["_source"].get("type") == "post") != (kind == "post"):
+ raise GroupError(404, f"no {kind} {gid}")
+ return doc["_source"] | {"id": doc["_id"]}, {"if_seq_no": doc["_seq_no"], "if_primary_term": doc["_primary_term"]}
+
+
+def save(group: dict, token: dict | None = None) -> None:
+ """Write the group; with a token only if nobody changed it since it was read (ConflictError otherwise)."""
+ body = {k: v for k, v in group.items() if k != "id"}
+ es.index(index=settings.idx_groups, id=group["id"], document=body, refresh="wait_for", **(token or {}))
+
+
+def all_posts(size: int = 200) -> list[dict]:
+ r = es.search(index=settings.idx_groups, query={"term": {"type": "post"}}, sort=[{"created_at": "desc"}], size=size)
+ return [h["_source"] | {"id": h["_id"]} for h in r["hits"]["hits"]]
+
+
+def all_groups(size: int = 200) -> list[dict]:
+ """Every meetup group (hallway posts share the index and are left out)."""
+ query = {"bool": {"must_not": [{"term": {"type": "post"}}]}}
+ r = es.search(index=settings.idx_groups, query=query, sort=[{"created_at": "asc"}], size=size)
+ return [h["_source"] | {"id": h["_id"]} for h in r["hits"]["hits"]]
diff --git a/backend/app/indices.py b/backend/app/indices.py
index 82bea84..1c65ec3 100644
--- a/backend/app/indices.py
+++ b/backend/app/indices.py
@@ -85,6 +85,37 @@
"message": {"type": "text"},
"request_id": {"type": "keyword"},
"created_at": LOCAL_TIME,
+ # Groups: the meetup group a confirmed "Meetup: ..." item belongs to.
+ "group_id": {"type": "keyword"},
+ }
+ },
+ # Meetup groups (app/groups_store.py). Slots and votes are kept as stored objects, not indexed: they are only
+ # ever read back with their group, and break ids as field names would grow the mapping with every break.
+ settings.idx_groups: {
+ "properties": {
+ "type": {"type": "keyword"}, # "group", or "post" for a hallway board post
+ "title": TEXT_KW,
+ "basis": {"type": "keyword"},
+ "value": {"type": "keyword"},
+ "description": {"type": "text"},
+ "host_id": {"type": "keyword"},
+ "host_name": {"type": "keyword"},
+ "members": {"type": "keyword"},
+ "member_names": {"type": "keyword"},
+ "max_members": {"type": "integer"},
+ "proposed_slots": {"type": "object", "enabled": False},
+ "votes": {"type": "object", "enabled": False},
+ "fixed_slot": {"type": "object", "enabled": False},
+ "status": {"type": "keyword"},
+ "created_at": LOCAL_TIME,
+ "sample": {"type": "boolean"},
+ # Hallway board posts (type "post"): short-lived lines like "At the Cilium booth till 15:00".
+ "text": {"type": "text"},
+ "place": {"type": "keyword"},
+ "tags": {"type": "keyword"},
+ "expires_at": LOCAL_TIME,
+ "author_id": {"type": "keyword"},
+ "author_name": {"type": "keyword"},
}
},
# Sample keynote transcripts in ~200-word chunks (doc_type "chunk"), plus one cached Claude summary per talk
diff --git a/backend/app/load.py b/backend/app/load.py
index db46f79..45a8c98 100644
--- a/backend/app/load.py
+++ b/backend/app/load.py
@@ -1,4 +1,4 @@
-"""Load the schedule snapshot, speakers, sample attendees and Emma's Monday into Elasticsearch.
+"""Load the schedule snapshot, speakers, sample attendees, Emma's Monday and sample meetup groups into Elasticsearch.
uv run python -m app.load # everything
uv run python -m app.load --only sessions # one index; the others are left alone
@@ -15,6 +15,7 @@
from .config import RAW_SCHEDULE, settings
from .data.demo import emma_monday
+from .data.groups import sample_groups, sample_posts
from .data.people import sample_attendees, speakers
from .data.samples import attendee_agendas, sample_activity
from .data.sessions import build_sessions
@@ -66,8 +67,9 @@ def _index(index: str, docs: list[dict]) -> int:
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument("--only", choices=["sessions", "people", "agenda", "activity"], action="append")
- only = set(parser.parse_args().only or ["sessions", "people", "agenda", "activity"])
+ indices = ["sessions", "people", "agenda", "activity", "groups"]
+ parser.add_argument("--only", choices=indices, action="append")
+ only = set(parser.parse_args().only or indices)
setup_telemetry(service_name="confox-load")
try:
@@ -84,6 +86,9 @@ def main() -> None:
if "activity" in only:
# Rebuilding drops recorded real events too; that is the point of a reload before a demo.
_index(settings.idx_activity, sample_activity(attendees, agendas))
+ if "groups" in only:
+ # Sample meetup groups (and hallway posts); groups created during a demo are dropped.
+ _index(settings.idx_groups, sample_groups(sessions, attendees) + sample_posts(attendees))
finally:
shutdown_telemetry()
diff --git a/backend/app/routers/groups.py b/backend/app/routers/groups.py
new file mode 100644
index 0000000..dea58ca
--- /dev/null
+++ b/backend/app/routers/groups.py
@@ -0,0 +1,300 @@
+"""Groups: meetups for people who share a school, country, company, community or interest.
+
+Someone proposes a group with up to three food or coffee breaks they are free for, others join and vote for the
+times they can make, and the host fixes one; every member then has a confirmed "Meetup: " on their agenda.
+The rules live in app/groups_store.py; this module reads and writes Elasticsearch around them.
+"""
+
+from collections.abc import Callable
+
+from elasticsearch import ConflictError, NotFoundError
+from fastapi import APIRouter, HTTPException, Query
+from opentelemetry import metrics, trace
+from pydantic import BaseModel, Field
+
+from .. import activity
+from .. import agenda_store as agenda
+from .. import groups_store as store
+from ..clock import now
+from ..config import settings
+from ..es import es
+from .connect import _food_sessions
+
+router = APIRouter(prefix="/api/groups", tags=["groups"])
+changes = metrics.get_meter("confox.groups").create_counter(
+ "confox.groups.changes", unit="{change}", description="Meetup groups proposed, joined, left, voted on and fixed"
+)
+PROPOSE_SLOTS = 6 # free breaks offered when proposing; the host picks up to store.MAX_SLOTS of them
+
+
+def _user_id() -> str:
+ return Query(default_factory=lambda: settings.demo_user, min_length=1)
+
+
+class Propose(BaseModel):
+ user_id: str = Field(default_factory=lambda: settings.demo_user, min_length=1)
+ basis: str
+ value: str = Field(min_length=1, max_length=200)
+ title: str = Field(default="", max_length=200)
+ description: str = Field(default="", max_length=1000)
+ session_ids: list[str] = Field(min_length=1, max_length=store.MAX_SLOTS)
+ max_members: int = store.DEFAULT_MAX_MEMBERS
+
+
+class SlotChoice(BaseModel):
+ user_id: str = Field(default_factory=lambda: settings.demo_user, min_length=1)
+ session_id: str = Field(min_length=1)
+ vote: bool = True # false takes the vote back
+
+
+def _http(exc: store.GroupError) -> HTTPException:
+ return HTTPException(status_code=exc.status, detail=exc.detail)
+
+
+def _profile(user_id: str) -> dict:
+ try:
+ doc = es.get(index=settings.idx_people, id=user_id, source_excludes=["embedding", "bio"])
+ except NotFoundError as exc:
+ raise HTTPException(status_code=404, detail=f"unknown user {user_id}") from exc
+ return doc["_source"] | {"id": doc["_id"]}
+
+
+def _free_breaks(user_id: str, limit: int = PROPOSE_SLOTS) -> list[dict]:
+ """Food and coffee breaks the user is free for (today, then the next day with breaks), same rules as Meet."""
+ items = agenda.user_items(user_id)
+ kinds = agenda.session_kinds([i.get("session_id") or "" for i in items])
+ return agenda.free_slots(_food_sessions(), items, kinds, "", now(), limit=limit)
+
+
+def _write_agenda(group: dict, user_ids: list[str]) -> None:
+ for uid in user_ids:
+ item = store.agenda_item(group, uid)
+ es.index(index=settings.idx_agenda, id=item.pop("id"), document=item)
+ agenda.refresh()
+
+
+def _busy_at(user_id: str, slot: dict | None, group_id: str) -> dict | None:
+ """The user's confirmed item that overlaps the meetup slot (co-located days aside), other than this meetup."""
+ if not slot:
+ return None
+ items = [i for i in agenda.user_items(user_id) if i.get("id") != store.agenda_item_id(user_id, group_id)]
+ kinds = agenda.session_kinds([i.get("session_id") or "" for i in items])
+ return next(
+ (
+ i
+ for i in agenda.blocking(items, kinds)
+ if agenda.overlaps(slot["starts_at"], slot["ends_at"], i["starts_at"], i["ends_at"])
+ ),
+ None,
+ )
+
+
+def _drop_agenda(group_id: str, user_id: str) -> None:
+ try:
+ es.delete(index=settings.idx_agenda, id=store.agenda_item_id(user_id, group_id))
+ except NotFoundError:
+ return
+ agenda.refresh()
+
+
+def _change(group_id: str, user_id: str, action: str, rule: Callable[[dict], dict]) -> tuple[dict, dict]:
+ """Read the group, apply a pure rule, write it back only if nobody changed it meanwhile. Returns (before, after)."""
+ span = trace.get_current_span()
+ span.set_attribute("confox.groups.id", group_id)
+ span.set_attribute("confox.groups.action", action)
+ try:
+ before, token = store.get(group_id)
+ after = rule(before)
+ if after is not before:
+ store.save(after, token)
+ except store.GroupError as exc:
+ raise _http(exc) from exc
+ except ConflictError as exc:
+ # Two people joined or voted at the same moment; the page reloads and the user tries again.
+ span.record_exception(exc)
+ raise HTTPException(status_code=409, detail="the group just changed, try again") from exc
+ changes.add(1, {"action": action})
+ return before, after
+
+
+@router.get("")
+def groups(user_id: str = _user_id()) -> dict:
+ """{"groups": groups the user is not in, ranked (sharing one of their values first, each with `match`),
+ "mine": groups they host or joined}. Every group carries member_count, spots_left, tally and leading."""
+ user = _profile(user_id)
+ out = store.rank(store.all_groups(), user_id, user)
+ trace.get_current_span().set_attribute("confox.groups.count", len(out["groups"]) + len(out["mine"]))
+ return out
+
+
+@router.get("/suggest")
+def suggest(user_id: str = _user_id()) -> dict:
+ """Groups worth proposing: values the user shares with others and how many people share each,
+ e.g. {"basis": "school", "value": "University of Utah", "count": 8, "label": "University of Utah · 8 people here"}.
+ """
+ user = _profile(user_id)
+ aggs = store.suggest_aggs(user_id, user)
+ if not aggs:
+ return {"suggestions": []}
+ r = es.search(
+ index=settings.idx_people, size=0, query={"bool": {"must_not": [{"ids": {"values": [user_id]}}]}}, aggs=aggs
+ )
+ open_groups = [g for g in store.all_groups() if g.get("status") == "open"]
+ found = store.suggestions(user, r.get("aggregations", {}), open_groups)
+ trace.get_current_span().set_attribute("confox.groups.suggestions", len(found))
+ return {"suggestions": found}
+
+
+@router.get("/slots")
+def slots(user_id: str = _user_id()) -> dict:
+ """Breaks the user is free for, to choose a group's candidate times from: {"slots": [...]}, at most 6."""
+ found = _free_breaks(user_id)
+ trace.get_current_span().set_attribute("confox.groups.slots", len(found))
+ return {"slots": found}
+
+
+@router.post("")
+def propose(body: Propose) -> dict:
+ """Create an open group hosted by the user. Every chosen time must be a break the host is free for (422)."""
+ host = _profile(body.user_id)
+ free = {s["session_id"] for s in _free_breaks(body.user_id, limit=50)}
+ if missing := [sid for sid in body.session_ids if sid not in free]:
+ raise HTTPException(status_code=422, detail=f"not a free break for you: {', '.join(missing)}")
+ sessions = [agenda.get_session(sid) for sid in dict.fromkeys(body.session_ids)]
+ try:
+ group = store.new_group(
+ store.group_id(),
+ host,
+ body.basis,
+ body.value,
+ body.title,
+ body.description,
+ [s for s in sessions if s],
+ body.max_members,
+ )
+ except store.GroupError as exc:
+ raise _http(exc) from exc
+ store.save(group)
+ trace.get_current_span().set_attribute("confox.groups.id", group["id"])
+ changes.add(1, {"action": "propose"})
+ activity.record("group_propose", body.user_id, f"{group['basis']} {group['value']}")
+ return store.view(group, body.user_id, host)
+
+
+@router.post("/{group_id}/join")
+def join(group_id: str, user_id: str = _user_id()) -> dict:
+ """Join a group (idempotent). If its time is already fixed, the meetup goes straight onto the user's agenda."""
+ user = _profile(user_id)
+ try:
+ current, _ = store.get(group_id)
+ except store.GroupError as exc:
+ raise _http(exc) from exc
+ if current.get("status") == "fixed":
+ busy = _busy_at(user_id, current.get("fixed_slot"), group_id)
+ if busy: # the meetup would be a second confirmed item at the same time
+ raise HTTPException(status_code=409, detail=f"you already have {busy.get('title') or 'something'} then")
+ before, after = _change(group_id, user_id, "join", lambda g: store.join(g, user_id, user.get("name") or user_id))
+ if after is not before:
+ activity.record("group_join", user_id, group_id)
+ if after.get("status") == "fixed":
+ # Also for members skipped at fix time because they were busy: once free, joining again adds the meetup.
+ _write_agenda(after, [user_id])
+ return store.view(after, user_id, user)
+
+
+@router.post("/{group_id}/leave")
+def leave(group_id: str, user_id: str = _user_id()) -> dict:
+ """Leave a group and take back the user's votes; a fixed meetup leaves their agenda. The host cannot leave."""
+ user = _profile(user_id)
+ try:
+ store.get(group_id)
+ except store.GroupError as exc:
+ if exc.status != 404:
+ raise _http(exc) from exc
+ # The group is gone (for example after a reload of the groups seed): clear its meetup off the agenda.
+ _drop_agenda(group_id, user_id)
+ return {"id": group_id, "removed": True}
+ before, after = _change(group_id, user_id, "leave", lambda g: store.leave(g, user_id))
+ if after is not before and after.get("status") == "fixed":
+ _drop_agenda(group_id, user_id)
+ return store.view(after, user_id, user)
+
+
+@router.post("/{group_id}/vote")
+def vote(group_id: str, body: SlotChoice) -> dict:
+ """Vote for (or, with vote false, un-vote) one proposed time. Voting on a group joins it first."""
+ user = _profile(body.user_id)
+ name = user.get("name") or body.user_id
+
+ def rule(g: dict) -> dict:
+ return store.vote(store.join(g, body.user_id, name), body.user_id, body.session_id, body.vote)
+
+ before, after = _change(group_id, body.user_id, "vote", rule)
+ if not store.is_member(before, body.user_id):
+ activity.record("group_join", body.user_id, group_id)
+ if body.vote:
+ activity.record("group_vote", body.user_id, group_id)
+ return store.view(after, body.user_id, user)
+
+
+@router.post("/{group_id}/fix")
+def fix(group_id: str, body: SlotChoice) -> dict:
+ """The host fixes one proposed time: the group becomes `fixed` and each member gets a confirmed agenda meeting."""
+ user = _profile(body.user_id)
+ _, after = _change(group_id, body.user_id, "fix", lambda g: store.fix(g, body.user_id, body.session_id))
+ members = after.get("members") or []
+ # Never double-book: members already busy at that time do not get the meetup on their agenda.
+ busy = [m for m in members if _busy_at(m, after.get("fixed_slot"), group_id)]
+ _write_agenda(after, [m for m in members if m not in busy])
+ activity.record("group_fix", body.user_id, group_id)
+ names = dict(zip(members, after.get("member_names") or [], strict=False))
+ return store.view(after, body.user_id, user) | {"busy_members": [names.get(m, m) for m in busy]}
+
+
+# ---------- hallway board ----------
+
+
+class NewPost(BaseModel):
+ user_id: str = Field(default_factory=lambda: settings.demo_user, min_length=1)
+ text: str = Field(min_length=1, max_length=400)
+ place: str = Field(default="", max_length=200)
+ minutes: int = 60
+ tags: list[str] = Field(default_factory=list, max_length=10)
+
+
+@router.get("/board")
+def board(user_id: str = _user_id()) -> dict:
+ """The hallway board: {"items": live posts and upcoming meetup groups, newest first, each with `for_you`
+ when it matches the viewer's interests (posts) or values (groups)}, plus the viewer's `interests` to tag with."""
+ user = _profile(user_id)
+ items = store.board(store.all_posts(), store.all_groups(), user_id, user, now())
+ trace.get_current_span().set_attribute("confox.board.items", len(items))
+ return {"items": items, "interests": store.profile_values(user)["interest"], "minutes": store.POST_MINUTES}
+
+
+@router.post("/board")
+def post(body: NewPost) -> dict:
+ """Post a short line to the board for 30, 60 or 180 minutes. Tags not among the author's interests are dropped."""
+ author = _profile(body.user_id)
+ try:
+ item = store.new_post(store.post_id(), author, body.text, body.place, body.minutes, body.tags)
+ except store.GroupError as exc:
+ raise _http(exc) from exc
+ store.save(item)
+ changes.add(1, {"action": "post"})
+ activity.record("board_post", body.user_id, " ".join(item["tags"]))
+ return item | {"kind": "post", "for_you": bool(item["tags"]), "matching": item["tags"], "mine": True}
+
+
+@router.delete("/board/{post_id}")
+def remove(post_id: str, user_id: str = _user_id()) -> dict:
+ """The author takes their post down (403 for anyone else, 404 if it is not a post)."""
+ trace.get_current_span().set_attribute("confox.board.post_id", post_id)
+ try:
+ item, token = store.get(post_id, kind="post")
+ store.remove_check(item, user_id)
+ except store.GroupError as exc:
+ raise _http(exc) from exc
+ es.delete(index=settings.idx_groups, id=post_id, refresh="wait_for", **token)
+ changes.add(1, {"action": "unpost"})
+ return {"id": post_id, "deleted": True}
diff --git a/backend/tests/test_groups.py b/backend/tests/test_groups.py
new file mode 100644
index 0000000..2e2dcca
--- /dev/null
+++ b/backend/tests/test_groups.py
@@ -0,0 +1,389 @@
+"""Meetup group rules on hand-written documents: ranking, suggestions, votes, joining, fixing. No Elasticsearch."""
+
+from datetime import datetime
+
+import pytest
+
+from app.data.groups import sample_groups, sample_posts
+from app.groups_store import (
+ GroupError,
+ agenda_item,
+ board,
+ fix,
+ join,
+ leading_slot,
+ leave,
+ match_reason,
+ new_group,
+ new_post,
+ rank,
+ remove_check,
+ suggest_aggs,
+ suggestions,
+ tally,
+ view,
+ vote,
+)
+
+AT = datetime.fromisoformat("2026-11-09T08:40:00")
+EMMA = {
+ "id": "emma",
+ "name": "Emma Carter",
+ "company": "Wasatch Cloud",
+ "past_companies": ["Copperleaf"],
+ "schools": ["University of Utah"],
+ "communities": ["Women in Cloud Native"],
+ "interests": ["AI inference", "Kubeflow"],
+ "country": "United States",
+}
+HOST = {"id": "att-002", "name": "Maya Okafor"}
+
+
+def brk(sid, start, end, title="Coffee Break"):
+ return {"id": sid, "title": title, "starts_at": f"2026-11-09T{start}:00", "ends_at": f"2026-11-09T{end}:00"}
+
+
+LUNCH = brk("lunch", "12:46", "13:30", "Lunch | On Own") | {"room": "Ballroom"}
+COFFEE = brk("coffee-pm", "14:48", "15:03")
+EARLY = brk("coffee-am", "10:48", "11:03")
+
+
+def group(gid="g1", basis="school", value="University of Utah", slots=(LUNCH, COFFEE), **kw):
+ return new_group(gid, HOST, basis, value, "", "", list(slots), at=AT, **kw)
+
+
+# ---------- creating ----------
+
+
+def test_new_group_sorts_slots_names_itself_and_starts_open_with_the_host():
+ g = group(slots=(COFFEE, LUNCH))
+ assert [s["session_id"] for s in g["proposed_slots"]] == ["lunch", "coffee-pm"]
+ assert g["proposed_slots"][0] == {
+ "session_id": "lunch",
+ "title": "Lunch",
+ "starts_at": "2026-11-09T12:46:00",
+ "ends_at": "2026-11-09T13:30:00",
+ "room": "Ballroom",
+ }
+ assert g["title"] == "University of Utah alumni meetup"
+ assert g["members"] == ["att-002"] and g["member_names"] == ["Maya Okafor"]
+ assert g["status"] == "open" and g["fixed_slot"] is None
+ assert g["votes"] == {"lunch": [], "coffee-pm": []}
+ assert g["created_at"] == "2026-11-09T08:40:00"
+
+
+@pytest.mark.parametrize(
+ "kwargs",
+ [
+ {"basis": "planet"},
+ {"value": " "},
+ {"slots": ()},
+ {"slots": (LUNCH, LUNCH)},
+ {"slots": (EARLY, LUNCH, COFFEE, brk("x", "16:00", "16:30"))},
+ ],
+)
+def test_new_group_refuses_bad_input(kwargs):
+ with pytest.raises(GroupError) as err:
+ group(**kwargs)
+ assert err.value.status == 422
+
+
+def test_max_members_is_clamped():
+ assert group(max_members=1)["max_members"] == 2
+ assert group(max_members=999)["max_members"] == 50
+
+
+# ---------- ranking ----------
+
+
+def test_match_reason_needs_the_same_basis():
+ assert match_reason(group(), EMMA) == {
+ "basis": "school",
+ "value": "University of Utah",
+ "label": "You studied at University of Utah",
+ }
+ assert match_reason(group(basis="company", value="Copperleaf"), EMMA)["label"] == "You work or worked at Copperleaf"
+ assert match_reason(group(basis="country", value="University of Utah"), EMMA) is None
+ assert match_reason(group(basis="country", value="Bangladesh"), EMMA) is None
+
+
+def test_rank_puts_matching_groups_first_by_basis_then_size_and_splits_mine():
+ bangladesh = group("bd", "country", "Bangladesh")
+ bangladesh = join(join(join(bangladesh, "a", "A"), "b", "B"), "c", "C") # biggest, but no match
+ kubeflow = group("kf", "interest", "Kubeflow")
+ wicn = group("wicn", "community", "Women in Cloud Native")
+ utah = group("utah")
+ mine = join(group("us", "country", "United States"), "emma", "Emma Carter")
+ out = rank([bangladesh, kubeflow, wicn, utah, mine], "emma", EMMA)
+ assert [g["id"] for g in out["groups"]] == ["utah", "wicn", "kf", "bd"]
+ assert [g["id"] for g in out["mine"]] == ["us"]
+ assert out["groups"][0]["match"]["label"] == "You studied at University of Utah"
+ assert out["groups"][-1]["match"] is None and out["groups"][-1]["member_count"] == 4
+ assert out["mine"][0]["is_member"] and not out["mine"][0]["is_host"]
+
+
+def test_suggestions_count_people_per_value_most_telling_basis_first():
+ aggs = suggest_aggs("emma", EMMA)
+ assert set(aggs) == {"school", "country", "company", "community", "interest"}
+ assert aggs["company"]["filters"]["filters"]["Copperleaf"]["bool"]["should"][1] == {
+ "term": {"past_companies": "Copperleaf"}
+ }
+ counts = {
+ "school": {"University of Utah": 8},
+ "country": {"United States": 40},
+ "company": {"Wasatch Cloud": 12, "Copperleaf": 0},
+ "community": {"Women in Cloud Native": 20},
+ "interest": {"AI inference": 30, "Kubeflow": 15},
+ }
+ result = {b: {"buckets": {v: {"doc_count": c} for v, c in vs.items()}} for b, vs in counts.items()}
+ existing = [group("utah")]
+ out = suggestions(EMMA, result, existing)
+ assert [s["value"] for s in out] == [
+ "University of Utah",
+ "United States",
+ "Women in Cloud Native",
+ "Wasatch Cloud",
+ "AI inference",
+ "Kubeflow",
+ ]
+ assert out[0]["label"] == "University of Utah · 8 people here"
+ assert out[0]["existing"] == ["utah"] and out[1]["existing"] == []
+ assert "_order" not in out[0]
+ assert len(suggestions(EMMA, result, [], limit=2)) == 2
+
+
+# ---------- votes ----------
+
+
+def test_vote_tally_and_leading_slot():
+ g = join(join(group(), "emma", "Emma Carter"), "b", "B")
+ assert leading_slot(g) is None
+ g = vote(g, "emma", "coffee-pm")
+ g = vote(g, "b", "coffee-pm")
+ g = vote(g, "b", "lunch")
+ g = vote(g, "b", "lunch") # voting twice counts once
+ assert [(s["session_id"], s["votes"], s["voted"]) for s in tally(g, "emma")] == [
+ ("lunch", 1, False),
+ ("coffee-pm", 2, True),
+ ]
+ assert leading_slot(g) == "coffee-pm"
+ g = vote(g, "emma", "coffee-pm", on=False)
+ assert leading_slot(g) == "lunch" # tie at one vote each: the earlier time leads
+
+
+def test_vote_does_not_mutate_the_original():
+ g = join(group(), "emma", "Emma Carter")
+ vote(g, "emma", "lunch")
+ assert g["votes"]["lunch"] == []
+
+
+@pytest.mark.parametrize(
+ ("user", "session", "status"),
+ [("stranger", "lunch", 403), ("emma", "nope", 422)],
+)
+def test_vote_rules(user, session, status):
+ g = join(group(), "emma", "Emma Carter")
+ with pytest.raises(GroupError) as err:
+ vote(g, user, session)
+ assert err.value.status == status
+
+
+def test_no_votes_once_fixed():
+ g = fix(join(group(), "emma", "Emma Carter"), "att-002", "lunch")
+ with pytest.raises(GroupError) as err:
+ vote(g, "emma", "coffee-pm")
+ assert err.value.status == 409
+
+
+# ---------- join and leave ----------
+
+
+def test_join_is_idempotent_and_respects_the_limit():
+ g = group(max_members=2)
+ g = join(g, "emma", "Emma Carter")
+ assert join(g, "emma", "Emma Carter") is g
+ with pytest.raises(GroupError) as err:
+ join(g, "c", "C")
+ assert err.value.status == 409
+ assert view(g, "emma")["spots_left"] == 0
+
+
+def test_leave_removes_member_name_and_votes_but_not_the_host():
+ g = vote(join(group(), "emma", "Emma Carter"), "emma", "lunch")
+ g = leave(g, "emma")
+ assert g["members"] == ["att-002"] and g["member_names"] == ["Maya Okafor"]
+ assert g["votes"]["lunch"] == []
+ assert leave(g, "emma") is g
+ with pytest.raises(GroupError) as err:
+ leave(g, "att-002")
+ assert err.value.status == 409
+
+
+# ---------- fixing ----------
+
+
+def test_only_the_host_fixes_once_and_only_a_proposed_time():
+ g = join(group(), "emma", "Emma Carter")
+ for user, session, status in [("emma", "lunch", 403), ("att-002", "coffee-am", 422)]:
+ with pytest.raises(GroupError) as err:
+ fix(g, user, session)
+ assert err.value.status == status
+ fixed = fix(g, "att-002", "lunch")
+ assert fixed["status"] == "fixed" and fixed["fixed_slot"]["session_id"] == "lunch"
+ with pytest.raises(GroupError) as err:
+ fix(fixed, "att-002", "coffee-pm")
+ assert err.value.status == 409
+
+
+def test_fixed_group_gives_members_a_confirmed_agenda_meeting():
+ g = fix(join(group(sample=True), "emma", "Emma Carter"), "att-002", "lunch")
+ item = agenda_item(g, "emma", at=AT)
+ assert item == {
+ "id": "emma-g-g1",
+ "user_id": "emma",
+ "kind": "meeting",
+ "status": "confirmed",
+ "group_id": "g1",
+ "with_id": "g1",
+ "with_name": "University of Utah alumni meetup",
+ "session_id": "lunch",
+ "title": "Meetup: University of Utah alumni meetup",
+ "starts_at": "2026-11-09T12:46:00",
+ "ends_at": "2026-11-09T13:30:00",
+ "room": "Ballroom",
+ "sample": False, # Emma's own item is real; sample members' items are sample
+ "created_at": "2026-11-09T08:40:00",
+ }
+ assert agenda_item(g, "att-002", at=AT)["sample"] is True
+
+
+# ---------- seed ----------
+
+
+def _session(sid, day, start, end, title):
+ return {"id": sid, "day": day, "is_food": True, "title": title, "starts_at": f"{day}T{start}:00",
+ "ends_at": f"{day}T{end}:00", "room": "Hall"} # fmt: skip
+
+
+def test_sample_groups_are_labelled_and_consistent():
+ sessions = []
+ for day in ("2026-11-09", "2026-11-10", "2026-11-11"):
+ sessions += [
+ _session(f"{day}-c1", day, "10:30", "11:00", "Coffee Break"),
+ _session(f"{day}-l", day, "12:30", "13:30", "Lunch"),
+ _session(f"{day}-c2", day, "15:00", "15:30", "Coffee Break"),
+ ]
+ attendees = [{"id": "emma", "name": "Emma"}, {"id": "alice", "name": "Alice"}]
+ attendees += [
+ {
+ "id": f"att-{i:03d}",
+ "name": f"Person {i}",
+ "schools": ["University of Utah"],
+ "communities": ["Women in Cloud Native"],
+ "interests": ["Kubeflow"],
+ "country": "Brazil",
+ }
+ for i in range(1, 7)
+ ]
+ groups = sample_groups(sessions, attendees)
+ assert [g["title"] for g in groups][:4] == [
+ "University of Utah alumni lunch",
+ "Bangladesh meetup",
+ "Women in Cloud Native coffee",
+ "Kubeflow users",
+ ]
+ for g in groups:
+ assert g["sample"] is True and g["status"] == "open"
+ assert "emma" not in g["members"] and len(g["members"]) == len(g["member_names"])
+ assert g["members"][0] == g["host_id"]
+ assert all(set(v) <= set(g["members"]) for v in g["votes"].values())
+ assert set(g["votes"]) == {s["session_id"] for s in g["proposed_slots"]}
+
+
+# ---------- hallway board ----------
+
+
+def test_new_post_trims_keeps_only_own_interests_and_expires():
+ author = EMMA | {"interests": ["AI inference", "Kubeflow", "KServe", "vLLM", "GPU scheduling"]}
+ p = new_post("p1", author, " At the Kubeflow booth " + "x" * 200, "Hall B", 30, ["Kubeflow", "Cilium"], at=AT)
+ assert p["text"].startswith("At the Kubeflow booth x") and len(p["text"]) == 140
+ assert p["tags"] == ["Kubeflow"]
+ assert (p["type"], p["author_id"], p["place"]) == ("post", "emma", "Hall B")
+ assert (p["created_at"], p["expires_at"]) == ("2026-11-09T08:40:00", "2026-11-09T09:10:00")
+ many = new_post("p2", author, "hi", tags=["vLLM", "KServe", "AI inference", "Kubeflow"], at=AT)
+ assert many["tags"] == ["AI inference", "Kubeflow", "KServe"] # profile order, at most three
+
+
+@pytest.mark.parametrize(("text", "minutes"), [(" ", 60), ("hi", 45)])
+def test_new_post_refuses_empty_text_and_odd_lengths(text, minutes):
+ with pytest.raises(GroupError) as err:
+ new_post("p", EMMA, text, minutes=minutes, at=AT)
+ assert err.value.status == 422
+
+
+def test_board_highlights_matches_hides_expired_and_mixes_in_groups():
+ later = datetime.fromisoformat("2026-11-09T08:50:00")
+ mine = new_post("p-mine", EMMA, "Here", minutes=30, tags=["Kubeflow"], at=AT)
+ other = new_post(
+ "p-other", HOST | {"interests": ["Cilium"]}, "Cilium booth", minutes=180, tags=["Cilium"], at=later
+ )
+ gone = new_post("p-gone", HOST, "Old news", minutes=30, at=datetime.fromisoformat("2026-11-09T08:00:00"))
+ done = fix(group("done", slots=(EARLY,)), "att-002", "coffee-am")
+ feed = board(
+ [mine, other, gone], [group("utah"), done], "emma", EMMA, datetime.fromisoformat("2026-11-09T12:00:00")
+ )
+ assert [i["id"] for i in feed] == ["utah"] # posts expired, fixed group over; the open group stays
+ feed = board([mine, other, gone], [group("utah"), done], "emma", EMMA, later)
+ assert [(i["id"], i["kind"], i["for_you"]) for i in feed] == [
+ ("p-other", "post", False), # newest first; same-minute items by id
+ ("utah", "group", True),
+ ("p-mine", "post", True),
+ ("done", "group", True),
+ ]
+ assert feed[2]["mine"] and not feed[0]["mine"] and feed[2]["matching"] == ["Kubeflow"]
+
+
+def test_only_the_author_removes_a_post():
+ p = new_post("p", EMMA, "hi", at=AT)
+ remove_check(p, "emma")
+ with pytest.raises(GroupError) as err:
+ remove_check(p, "att-002")
+ assert err.value.status == 403
+ with pytest.raises(GroupError) as err:
+ remove_check(group(), "att-002")
+ assert err.value.status == 404
+
+
+def test_sample_posts_are_tagged_with_their_authors_interests():
+ attendees = [{"id": "emma", "name": "Emma", "interests": ["Kubeflow"]}]
+ attendees += [
+ {"id": f"att-{i}", "name": f"P{i}", "interests": ["Cilium", "GPU scheduling", "OpenTelemetry", "Kubeflow"]}
+ for i in range(4)
+ ]
+ posts = sample_posts(attendees)
+ assert len(posts) == 4 and all(p["sample"] and p["type"] == "post" for p in posts)
+ assert len({p["author_id"] for p in posts}) == 4 and "emma" not in {p["author_id"] for p in posts}
+ assert all(p["tags"] and p["expires_at"] > "2026-11-09T08:40:00" for p in posts)
+
+
+def test_busy_at_finds_a_confirmed_item_at_the_meetup_time(monkeypatch):
+ from app.routers import groups as router
+
+ slot = {"starts_at": "2026-11-09T14:48:00", "ends_at": "2026-11-09T15:03:00"}
+ items = [
+ {"id": "emma-g-g1", "status": "confirmed", "starts_at": slot["starts_at"], "ends_at": slot["ends_at"]},
+ {
+ "id": "emma-colocated",
+ "status": "confirmed",
+ "session_id": "day",
+ "starts_at": "2026-11-09T09:00:00",
+ "ends_at": "2026-11-09T17:30:00",
+ }, # fmt: skip
+ ]
+ monkeypatch.setattr(router.agenda, "user_items", lambda uid: items)
+ monkeypatch.setattr(router.agenda, "session_kinds", lambda ids: {"day": "colocated"})
+ # Its own meetup item and the co-located day do not count, so the user is free.
+ assert router._busy_at("emma", slot, "g1") is None
+ coffee = {"id": "emma-coffee", "status": "confirmed", "title": "Coffee", **slot}
+ monkeypatch.setattr(router.agenda, "user_items", lambda uid: [*items, coffee])
+ assert router._busy_at("emma", slot, "g1")["title"] == "Coffee"
diff --git a/docs/architecture.md b/docs/architecture.md
index b1427f8..ba22657 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -19,19 +19,20 @@ flowchart LR
|---|---|---|
| Browser app | Pages, navigation, browser telemetry | Pull request 2b |
| API | One service; every endpoint traced | Pull requests 0, 1 |
-| Elasticsearch | Sessions, people, agendas, transcripts, connections | Pull requests 2, 3 |
+| Elasticsearch | Sessions, people, agendas, transcripts, connections, meetup groups | Pull requests 2, 3 |
| LLM | Ask and Catch up answers, grounded in retrieved documents | Pull requests 8, 9 |
| Telemetry | OpenTelemetry to Dash0: traces, metrics, logs, RUM | Pull requests 1, 12 |
## Data (pull request 2)
-`uv run python -m app.load` reads the snapshot in `data/raw/` and fills three indices. `--only sessions|people|agenda` rebuilds one index and leaves the others alone.
+`uv run python -m app.load` reads the snapshot in `data/raw/` and fills three indices. `--only sessions|people|agenda|activity|groups` rebuilds one index and leaves the others alone.
| Index | Holds | Count |
|---|---|---|
| `confox-sessions` | Every scheduled session: time (local, no offset), day, room, venue, track, level, CNCF projects, speakers, kind, `is_food` | 600 |
| `confox-people` | 712 public speaker profiles from the schedule, plus 80 generated attendees marked `sample: true` (Emma and Alice first, then University of Utah alumni) | 792 |
| `confox-agenda` | Emma's Monday: the co-located AI day, a confirmed coffee with Alice, a pending lunch request (all `sample: true`) | 3 |
+| `confox-groups` | 5 sample meetup groups and 4 hallway board posts (`--only groups`), all `sample: true`; see Groups and connections | 9 |
Session kinds come from the track and the cleaned title: `keynote`, `talk`, `lightning`, `tutorial`, `contribfest`, `poster`, `showcase`, `colocated`, `break`, `registration`. Titles are stripped of emoji first, so "☕ Coffee Break" inside the Project Lightning Talks track is a `break` with `is_food`.
@@ -213,6 +214,41 @@ Ids: `{user}-s-{session_id}` for added sessions, `{user}-m-{8 hex}` for new requ
- **Writes.** Every write refreshes the agenda index so the next read sees it. Counters: `confox.agenda.changes` (attribute `action`: add, remove) and `confox.connect.requests` (`action`: send, accept, decline); the request spans carry the session or person id.
- **Schedule.** Each day-view row except breaks and registration has an "Agenda" / "Added" toggle; it writes, then reloads the day and the agenda ids, so For you, clashes and the count update together. Search results get the same toggle through the `SessionCard` aside, with state from `GET /api/agenda`. Outgoing requests show as "Request sent".
- **People.** Every card has a primary "Meet" button that opens an inline panel: the free slots as a native radio group (first one chosen and focused), an optional line, "Send request". After sending, the card says "Request sent for 14:48 · Coffee" and the button becomes a disabled "Requested" (warn colours, since it is pending); people with a pending outgoing request show "Requested" on load, and a confirmed meeting shows as a green chip. Escape closes the panel and returns focus to the button.
+## Groups and connections
+
+The People page has three tabs, kept in the address as `?tab=connections|groups` (Match is the default): **Match** (above), **Connections** and **Groups**. Groups live in `backend/app/routers/groups.py` with the pure rules in `backend/app/groups_store.py`; the UI is `src/components/groups/`, `src/components/connect/ConnectionsTab.tsx` and `src/styles/groups.css`.
+
+**Connections** reads `GET /api/connect`: requests to the user with Accept and Decline, requests they sent with Withdraw, and confirmed meetings (group meetups show as "Group meetup"). It adds no endpoint.
+
+**Groups.** A meetup for people who share a school, country, company, community or interest. Someone proposes it with up to three food or coffee breaks they are free for, others join and vote for the times they can make, and the host fixes one. One document per group in `confox-groups`:
+
+| Field | Meaning |
+|---|---|
+| `type` | `group` (board posts share the index as `post`) |
+| `basis`, `value` | `school`, `country`, `company`, `community` or `interest`, and the shared value ("University of Utah") |
+| `title`, `description` | At most 80 and 280 characters; the title defaults to "University of Utah alumni meetup" and so on |
+| `host_id`, `host_name`, `members`, `member_names`, `max_members` | Host first; names kept in member order so cards need no join; 12 members by default |
+| `proposed_slots`, `votes`, `fixed_slot` | 1 to 3 breaks `{session_id, title, starts_at, ends_at, room}`; `{session_id: [user ids]}`; the chosen slot or null. Stored but not indexed (`enabled: false`), so break ids never become mapping fields |
+| `status`, `created_at`, `sample` | `open` or `fixed`; local time; `true` for seeded groups |
+
+| Endpoint | Returns |
+|---|---|
+| `GET /api/groups?user_id` | `{groups, mine}`: groups the user is not in, ranked, and groups they host or joined. Each adds `member_count`, `spots_left`, `is_member`, `is_host`, `match`, `tally` (slots with `votes` and `voted`) and `leading` |
+| `GET /api/groups/suggest?user_id` | `{suggestions: [{basis, value, count, label, title, existing}]}`, at most 6: "University of Utah · 7 people here", with ids of open groups already formed around it |
+| `GET /api/groups/slots?user_id` | Up to 6 breaks the user is free for (the Meet rules from `agenda_store.free_slots`, no other person) |
+| `POST /api/groups {user_id, basis, value, title, description, session_ids}` | The new open group; 422 if a time is not a free break for the host or the input is invalid |
+| `POST /api/groups/{id}/join?user_id`, `/leave?user_id` | The group. Join is idempotent, 409 when full; leaving drops the user's votes; the host cannot leave (409) |
+| `POST /api/groups/{id}/vote {user_id, session_id, vote}` | The group. A member may vote for several times; `vote: false` takes one back; voting on a group joins it first; 422 for a time not proposed, 409 once fixed |
+| `POST /api/groups/{id}/fix {user_id, session_id}` | The fixed group; host only (403), once (409), one of the proposed times (422) |
+
+- **Ranking.** Groups whose value is one of the user's own for the same basis come first, with a `match` reason ("You studied at University of Utah"); then by basis (school, country, community, company, interest), open before fixed, more members first. Suggestions use one `size: 0` search on `confox-people` with a `filters` aggregation per basis over the user's values (company matches current or past), excluding the user, in the same basis order and then by count.
+- **Fixing.** Every member gets a confirmed agenda meeting `{user}-g-{group}` (`kind: meeting`, `group_id`, `with_id` the group, `title` "Meetup: ", the break's time and room), so it shows in Agenda, My brief and Connections and blocks that break for Meet. Joining a fixed group writes the joiner's item; leaving deletes it.
+- **Concurrency.** Changes read the group, apply a pure rule and write back with `if_seq_no`/`if_primary_term`; a clash answers 409 and the page reloads.
+- **UI.** "Suggested for you" cards open the Propose dialog (native `