Skip to content

Commit bd5cd67

Browse files
danielhe4rtGabrielFVDevBrunaDominguescursoragentdavicbtoliveira
authored
feat: events module (#309)
## Summary Introduces the **events participation module** (`app-modules/events/`) with the full lifecycle: enrollment → check-in → attendance → closure. Ships three enrollment methods (RSVP, RSVP + check-in, Application with dynamic form builder), three check-in methods (manual, numeric code, QR), waitlist + capacity enforcement, an event-closure job, bot check-in integration, and full Admin/App panel UI with i18n (en + pt_BR). ## Sub-domains (`src/`) - **Event** — core aggregate (`Event`, `EventType`, `EventStatus`) - **Enrollment** — RSVP + Application flow, policies, transitions, waitlist/capacity - **CheckIn** — manual / numeric code / QR strategies, bot integration - **Closure** — closure job, attended/no-show, admin status override ## Closes Umbrella: - Closes #237 — participation module MVP Sub-issues: - Closes #239 — Foundation (schema, models, enum, Admin CRUD) - Closes #240 — RSVP enrollment end-to-end - Closes #241 — waitlist and capacity enforcement - Closes #242 — cancellation and waitlist promotion - Closes #243 — application enrollment with form builder - Closes #244 — manual check-in - Closes #245 — numeric code check-in - Closes #246 — QR code check-in - Closes #247 — event closure job (attended/no-show) - Closes #248 — bot check-in integration --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Daniel Reis <danielhe4rt@gmail.com> Signed-off-by: Sther <72408918+stherzada@users.noreply.github.com> Co-authored-by: Gabriel <gabrielvasco906@gmail.com> Co-authored-by: Bruna Domingues Leite <brunadomingues.dev@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Davi Castello Branco Tavares de Oliveira <davicbtoliveira@hotmail.com> Co-authored-by: davi.oliveira <davi.oliveira@ernestoborges.com.br> Co-authored-by: Yuri Souza <yurisouza.developer@gmail.com> Co-authored-by: Adryanne Kelly <72768888+AdryanneKelly@users.noreply.github.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Gabriel Vieira <48625433+gvieira18@users.noreply.github.com> Co-authored-by: BrunaDomingues <bruna@users.noreply.github.com> Co-authored-by: kaster <85951158+DiogoKaster@users.noreply.github.com> Co-authored-by: João Paulo Abdala Bohaczk <114778253+joaopabdala@users.noreply.github.com> Co-authored-by: Elves Santos <168841287+sirelves@users.noreply.github.com> Co-authored-by: Thales Machado <102062680+thalesmengue@users.noreply.github.com> Co-authored-by: Fernando Andrade <onanduandrade@gmail.com> Co-authored-by: Arthur Bazilio <arthurbazzz@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Henrique Leme de Brito <henriqueleme.brito@outlook.com> Co-authored-by: Cristopher Paiva <josuepaiva7@gmail.com> Co-authored-by: Jonatas Santos <jonatasskt18@gmail.com> Co-authored-by: Nathan Mota <nathansmota@gmail.com> Co-authored-by: Sther <72408918+stherzada@users.noreply.github.com> Co-authored-by: Tiago Góes <tiago.goes2009@gmail.com>
1 parent ecdabd1 commit bd5cd67

167 files changed

Lines changed: 11239 additions & 330 deletions

File tree

Some content is hidden

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

‎CONTEXT-MAP.md‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ This is a modular monorepo (`internachi/modular`). Each bounded context lives un
1515
| Bot Discord | `app-modules/bot-discord/` | Discord bot runtime (Laracord websocket, slash commands, event handlers) |
1616
| Integration Discord | `app-modules/integration-discord/` | Discord platform transport (REST API via Saloon), OAuth, ETL |
1717
| Identity | `app-modules/identity/` | Users, tenants, external identities, authentication |
18+
| Events | `app-modules/events/` | Event participation lifecycle — enrollment, check-in, attendance, XP dispatch |
19+
| Gamification | `app-modules/gamification/` | Character progression — XP, levels, badges, seasons, daily bonuses |
1820
| Panel Admin | `app-modules/panel-admin/` | Filament admin panel — dashboards, resources, moderation UI, marketing |
1921
| Integration Twitch | `app-modules/integration-twitch/` | Twitch platform transport (Helix API via Saloon), OAuth, EventSub webhooks |
2022
| Integration GitHub | `app-modules/integration-github/` | GitHub transport (REST via Saloon), OAuth, community contribution ingestion (backfill + webhooks) + event lake |
@@ -27,10 +29,24 @@ This is a modular monorepo (`internachi/modular`). Each bounded context lives un
2729
┌─────────────────┐ ┌──────────────────────┐
2830
│ Bot Discord │ │ Integration Discord │
2931
│ (runtime/ws) │────────▶│ (transport/rest) │
30-
└────────┬────────┘ └──────────┬───────────┘
31-
│ │
32-
│ listens to events │ provides DiscordConnector
33-
▼ │
32+
└───┬─────────┬───┘ └──────────┬───────────┘
33+
│ │ │
34+
│ │ dispatches │ provides DiscordConnector
35+
│ │ CheckInRequested │
36+
│ ▼ │
37+
│ ┌─────────────────┐ │
38+
│ │ Events │ │
39+
│ │ (participation) │────────────┼───── publishes domain events
40+
│ └────────┬────────┘ │ │
41+
│ │ │ ▼
42+
│ │ reads users │ ┌─────────────────┐
43+
│ │ │ │ Gamification │
44+
│ │ │ │ (XP/levels) │
45+
│ │ │ └────────┬────────┘
46+
│ │ │ │
47+
│ listens │ │ │ reads users
48+
│ to events │ │ │
49+
▼ ▼ │ ▼
3450
┌─────────────────┐ │
3551
│ Moderation │◀───────────────────┘
3652
│ (domain core) │
@@ -46,10 +62,12 @@ This is a modular monorepo (`internachi/modular`). Each bounded context lives un
4662
### Dependency rules
4763

4864
- **Moderation** is platform-agnostic. It never imports from `bot-discord`, `integration-discord`, or `integration-twitch`.
49-
- **Bot Discord** depends on Moderation (listens to domain events) and Integration Discord (uses transport).
65+
- **Bot Discord** depends on Moderation (listens to domain events) and Integration Discord (uses transport) and Events (dispatches check-in domain events)..
5066
- **Integration Discord** depends on Identity (OAuth user resolution). It never imports from Moderation.
5167
- **Integration Twitch** depends on Identity (OAuth user resolution, ExternalIdentity for tenant linking). It never imports from Moderation, Integration Discord, or Bot Discord.
5268
- **Integration GitHub** depends on Identity (OAuth user resolution; future `Character` seam via `ExternalIdentity`). It never imports from Activity, Economy, Moderation or any Bot/runtime module — it only emits the `GithubContributionRecorded` domain event. The community presentation (in `portal`) and the allowlist admin UI (in `panel-admin`) depend on it, never the reverse.
5369
- **Identity** has no upstream dependencies on other contexts listed here.
70+
- **Events** depends on Identity (reads Users and Tenants). Publishes domain events consumed by Gamification.
71+
- **Gamification** depends on Identity (Character belongs to User). Listens to Events domain events for XP.
5472
- **Onboarding** depends on Identity (User, tenant scoping, GitHub `ExternalIdentity` link) and listens to `integration-github`'s `GithubPullRequestApproved` domain event (reads the `challenge` repos in the allowlist). It never imports from `squads` — `squads` is a consumer of its completion gate, never the reverse.
5573
- **Squads** depends on Onboarding (reads the `Squads`-completion gate, "APTO") and Identity (users/tenants). It never imports from presentation; the panels depend on it.

‎app-modules/events/CONTEXT.md‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Events — Bounded Context
2+
3+
## Purpose
4+
5+
Manages event participation lifecycle: enrollment, check-in, attendance tracking, and XP reward dispatching. Covers in-person meetups, workshops, and multi-day conferences.
6+
7+
## Glossary
8+
9+
| Term | Definition | Not to be confused with |
10+
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
11+
| **Event** | A scheduled gathering (meetup, workshop, or conference) owned by a tenant. Defined by type, date range, location, and an enrollment policy. | "Event" as in Laravel Event (domain event) — use "domain event" for those. |
12+
| **Enrollment** | A single record representing one user's relationship with one event. Progresses through a strict state machine from entry to terminal state. One enrollment per (user, event). | "Registration" — we don't use this term. |
13+
| **Enrollment Policy** | A 1:1 configuration record attached to an event. Defines enrollment method, capacity, check-in method, waitlist behavior, cancellation deadline, XP rewards, and application form schema. | "Event settings" — policy specifically governs participation rules. |
14+
| **Enrollment Method** | How a user enters an event. One of: `rsvp` (1-click), `rsvp_checkin` (1-click + mandatory presence verification), `application` (form submission + organizer approval). | |
15+
| **Check-in** | Verification of physical/virtual presence at an event. One record per (enrollment, date). Methods: `manual`, `numeric_code`, `qr_code`. | "Enrollment" — check-in proves presence, enrollment proves intent. |
16+
| **Numeric Code** | A short-lived code announced by the organizer (projected on screen or spoken in stream). Bound to a specific event date. Has expiration window and optional max uses. Also used by Discord/Twitch bots as check-in trigger. | |
17+
| **QR Token** | A unique token generated per enrollment. Encoded in a QR code on the participant's badge/screen. Reusable across event days — each scan creates a new check-in record for that day. | |
18+
| **Waitlist** | Ordered queue of enrollments when event capacity is full. FIFO promotion when a confirmed participant cancels. | |
19+
| **Attendance Requirement** | Policy rule defining how many days of check-in are needed to achieve `attended` status. Values: `all_days`, `any_day`, `minimum_days(N)`. | |
20+
| **Transition** | An auditable state change on an enrollment. Every transition is recorded with actor, timestamp, and reason. Written by application code (Actions), never by database triggers. | |
21+
| **No-show** | Terminal state for a participant who confirmed but never checked in. Assigned automatically by a scheduled job after the event ends. No systemic consequences in MVP (future: may affect eligibility). | |
22+
| **Application** | An enrollment method where the participant submits a dynamic form (JSONB schema defined in policy) and waits for organizer approval. Results in `pending → confirmed` or `pending → rejected`. | "Submission" (CFP) — application is for participation, submission is for presenting (out of MVP scope). |
23+
24+
## State Machine — Enrollment
25+
26+
```
27+
[entry]
28+
├─ application → pending
29+
│ ├─ approve() → confirmed
30+
│ ├─ reject() → rejected (TERMINAL)
31+
│ └─ cancel() → cancelled (TERMINAL)
32+
│
33+
├─ rsvp/rsvp_checkin + capacity available → confirmed
34+
└─ rsvp/rsvp_checkin + full → waitlisted
35+
├─ slot_opens() → confirmed
36+
└─ cancel() → cancelled (TERMINAL)
37+
38+
confirmed
39+
├─ check_in() → checked_in
40+
├─ cancel(pre-deadline) → cancelled (TERMINAL)
41+
└─ [job] event_ended → no_show (TERMINAL)
42+
43+
checked_in
44+
└─ [job] event_ended + attendance_requirement met → attended (TERMINAL · SUCCESS)
45+
```
46+
47+
**States:** `pending`, `confirmed`, `waitlisted`, `checked_in`, `attended`, `cancelled`, `rejected`, `no_show`
48+
49+
**Terminal states:** `attended` (success), `cancelled`, `rejected`, `no_show`
50+
51+
## Actors
52+
53+
| Actor | Panel | Capabilities |
54+
| --------------- | ---------------- | ---------------------------------------------------------------------------------------------------- |
55+
| **Organizer** | Admin (`/admin`) | Creates events, configures policies, approves/rejects applications, manual check-in, status override |
56+
| **Participant** | App (`/app`) | Enrolls (RSVP/application), checks in (code/QR), cancels, views own events |
57+
58+
## Module Boundaries
59+
60+
- **Events → Gamification**: Events dispatches domain events (`EnrollmentConfirmed`, `ParticipantCheckedIn`, `ParticipantAttended`). Gamification listens and awards XP. Events does not know how XP works.
61+
- **Bot Discord → Events**: Bot dispatches domain events (e.g., `CheckInRequested`). Events module listens and processes. Bot is transport, Events owns the rules.
62+
- **Events → Identity**: Events reads User and Tenant models. No writes to Identity.
63+
64+
## Out of Scope (MVP)
65+
66+
- Networking between participants
67+
- Referral / invite links
68+
- Magic link and geolocation check-in
69+
- Sponsors association
70+
- Timeline / activity feed (listeners ready, no consumer yet)
71+
- Call for Papers / Submissions (CFP)
72+
- Agenda / schedule display
73+
- Paid events / payment integration
74+
- No-show penalties
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace He4rt\Events\Database\Factories;
6+
7+
use He4rt\Events\CheckIn\Models\CheckInCode;
8+
use He4rt\Events\Event\Models\Event;
9+
use Illuminate\Database\Eloquent\Factories\Factory;
10+
use Illuminate\Support\Facades\Date;
11+
12+
/** @extends Factory<CheckInCode> */
13+
final class CheckInCodeFactory extends Factory
14+
{
15+
protected $model = CheckInCode::class;
16+
17+
public function definition(): array
18+
{
19+
$startsAt = Date::now();
20+
21+
return [
22+
'event_id' => Event::factory(),
23+
'event_date' => Date::today(),
24+
'code' => fake()->numerify('######'),
25+
'starts_at' => $startsAt,
26+
'expires_at' => $startsAt->clone()->addHours(2),
27+
'max_uses' => null,
28+
'uses_count' => 0,
29+
'revoked_at' => null,
30+
];
31+
}
32+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace He4rt\Events\Database\Factories;
6+
7+
use He4rt\Events\CheckIn\Enums\CheckInMethod;
8+
use He4rt\Events\CheckIn\Models\CheckIn;
9+
use He4rt\Events\Enrollment\Models\Enrollment;
10+
use Illuminate\Database\Eloquent\Factories\Factory;
11+
use Illuminate\Support\Facades\Date;
12+
13+
/** @extends Factory<CheckIn> */
14+
final class CheckInFactory extends Factory
15+
{
16+
protected $model = CheckIn::class;
17+
18+
public function definition(): array
19+
{
20+
return [
21+
'enrollment_id' => Enrollment::factory(),
22+
'event_date' => Date::today(),
23+
'method' => fake()->randomElement(CheckInMethod::cases()),
24+
'payload' => null,
25+
'checked_in_at' => Date::now(),
26+
];
27+
}
28+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace He4rt\Events\Database\Factories;
6+
7+
use He4rt\Events\Enrollment\Enums\EnrollmentStatus;
8+
use He4rt\Events\Enrollment\Models\Enrollment;
9+
use He4rt\Events\Event\Models\Event;
10+
use He4rt\Identity\User\Models\User;
11+
use Illuminate\Database\Eloquent\Factories\Factory;
12+
13+
/** @extends Factory<Enrollment> */
14+
final class EnrollmentFactory extends Factory
15+
{
16+
protected $model = Enrollment::class;
17+
18+
public function definition(): array
19+
{
20+
return [
21+
'event_id' => Event::factory(),
22+
'user_id' => User::factory(),
23+
'status' => EnrollmentStatus::Pending,
24+
'is_public' => true,
25+
'waitlist_position' => null,
26+
'application_data' => null,
27+
'rejection_reason' => null,
28+
'enrolled_at' => null,
29+
'confirmed_at' => null,
30+
'checked_in_at' => null,
31+
'attended_at' => null,
32+
'cancelled_at' => null,
33+
];
34+
}
35+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace He4rt\Events\Database\Factories;
6+
7+
use He4rt\Events\CheckIn\Enums\CheckInMethod;
8+
use He4rt\Events\Enrollment\Enums\AttendanceRequirement;
9+
use He4rt\Events\Enrollment\Enums\EnrollmentMethod;
10+
use He4rt\Events\Enrollment\Models\EnrollmentPolicy;
11+
use He4rt\Events\Event\Models\Event;
12+
use Illuminate\Database\Eloquent\Factories\Factory;
13+
14+
/** @extends Factory<EnrollmentPolicy> */
15+
final class EnrollmentPolicyFactory extends Factory
16+
{
17+
protected $model = EnrollmentPolicy::class;
18+
19+
public function definition(): array
20+
{
21+
$requirement = fake()->randomElement(AttendanceRequirement::cases());
22+
23+
return [
24+
'event_id' => Event::factory(),
25+
'enrollment_method' => fake()->randomElement(EnrollmentMethod::cases()),
26+
'check_in_method' => fake()->randomElement(CheckInMethod::cases()),
27+
'capacity' => fake()->optional()->numberBetween(10, 200),
28+
'has_waitlist' => false,
29+
'attendance_requirement' => $requirement,
30+
'minimum_days' => $requirement === AttendanceRequirement::MinimumDays ? 1 : null,
31+
'cancellation_deadline_hours' => null,
32+
'xp_on_confirmed' => 0,
33+
'xp_on_checked_in' => 0,
34+
'xp_on_attended' => 0,
35+
'application_schema' => null,
36+
];
37+
}
38+
39+
public function rsvp(): static
40+
{
41+
return $this->state(fn (): array => [
42+
'enrollment_method' => EnrollmentMethod::Rsvp,
43+
]);
44+
}
45+
46+
public function application(?array $schema = null): static
47+
{
48+
return $this->state(fn (): array => [
49+
'enrollment_method' => EnrollmentMethod::Application,
50+
'application_schema' => $schema,
51+
]);
52+
}
53+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace He4rt\Events\Database\Factories;
6+
7+
use He4rt\Events\Enrollment\Enums\EnrollmentStatus;
8+
use He4rt\Events\Enrollment\Enums\TriggeredBy;
9+
use He4rt\Events\Enrollment\Models\Enrollment;
10+
use He4rt\Events\Enrollment\Models\EnrollmentTransition;
11+
use Illuminate\Database\Eloquent\Factories\Factory;
12+
13+
/** @extends Factory<EnrollmentTransition> */
14+
final class EnrollmentTransitionFactory extends Factory
15+
{
16+
protected $model = EnrollmentTransition::class;
17+
18+
public function definition(): array
19+
{
20+
return [
21+
'enrollment_id' => Enrollment::factory(),
22+
'from_status' => null,
23+
'to_status' => EnrollmentStatus::Pending,
24+
'actor_id' => null,
25+
'triggered_by' => TriggeredBy::User,
26+
'reason' => null,
27+
'metadata' => null,
28+
];
29+
}
30+
}

‎app-modules/events/database/factories/EventAgendaFactory.php‎

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)