development #14

Merged
jselesan merged 102 commits from development into main 2026-11-07 13:21:43 +00:00
812 changed files with 99919 additions and 1203 deletions
Showing only changes of commit ff885bddfc - Show all commits

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,448 @@
{
"schema_version": 1,
"diagram_type": "architecture",
"meta": {
"title": "Arquitectura de Gruperly",
"locale": "es",
"output": ".archify/architecture-gruperly-20261103-121500/arquitectura-gruperly.html",
"quality_profile": "showcase",
"repository": {
"url": "https://git.2pidev.com/jselesan/gruperly.git",
"link_mode": "local-only",
"revision": "d21e1c37302d8d3f2ff8b0af05f4df21284bffe3"
},
"views": [
{
"id": "request",
"label": "Pedido del profe",
"focus": [
"teacher",
"web",
"nginx",
"guards",
"api",
"db"
],
"note": "Mismo dominio: nginx sirve el bundle y hace proxy de /api al contenedor api."
},
{
"id": "students",
"label": "App de alumnos",
"focus": [
"student",
"web",
"guards",
"storage"
],
"note": "Sin Better Auth: cookie y middleware propios; comprobantes en S3 privado."
},
{
"id": "integrations",
"label": "Integraciones",
"focus": [
"api",
"mp",
"stripe",
"whatsapp",
"smtp",
"storage"
],
"note": "Cada proveedor detrás de un puerto; sin credenciales responde 503 y el resto sigue andando."
}
]
},
"components": [
{
"id": "teacher",
"type": "external",
"label": "Profesor",
"sublabel": "navegador / PWA",
"icon": "person",
"pos": [
40,
60
],
"size": [
120,
60
],
"sources": [
{
"path": "apps/web/src/routes/_authenticated.tsx",
"line": 1
}
]
},
{
"id": "web",
"type": "frontend",
"label": "Web PWA",
"sublabel": "React 19 · Vite",
"pos": [
230,
56
],
"size": [
140,
68
],
"sources": [
{
"path": "apps/web/vite.config.ts",
"line": 12,
"label": "VitePWA"
}
]
},
{
"id": "student",
"type": "external",
"label": "Alumno / tutor",
"sublabel": "/i/:token · /student",
"icon": "person",
"pos": [
230,
240
],
"size": [
140,
60
],
"sources": [
{
"path": "apps/web/src/routes/i.$token.tsx",
"line": 1
},
{
"path": "apps/web/src/routes/_student.tsx",
"line": 1
}
]
},
{
"id": "nginx",
"type": "cloud",
"label": "nginx",
"sublabel": "bundle + proxy /api",
"pos": [
450,
60
],
"size": [
140,
60
],
"sources": [
{
"path": "apps/web/nginx.conf",
"line": 14,
"end_line": 26
},
{
"path": "docker-compose.yml",
"line": 1,
"end_line": 8
}
]
},
{
"id": "guards",
"type": "security",
"label": "Guards de sesión",
"sublabel": "Better Auth · alumno",
"pos": [
680,
56
],
"size": [
150,
68
],
"sources": [
{
"path": "apps/backend/src/http/session-auth.ts",
"line": 23,
"end_line": 48
},
{
"path": "apps/backend/src/modules/student-portal/middleware.ts",
"line": 50
}
]
},
{
"id": "api",
"type": "backend",
"label": "API Hono + jobs",
"sublabel": "Bun.serve :4000 · cron",
"pos": [
880,
56
],
"size": [
150,
68
],
"sources": [
{
"path": "apps/backend/src/server.ts",
"line": 14,
"end_line": 23
},
{
"path": "apps/backend/src/app.ts",
"line": 44,
"end_line": 73
}
]
},
{
"id": "db",
"type": "database",
"label": "PostgreSQL",
"sublabel": "Prisma 7 · adapter-pg",
"pos": [
1090,
60
],
"size": [
140,
60
],
"sources": [
{
"path": "apps/backend/src/lib/prisma.ts",
"line": 14,
"end_line": 18
}
]
},
{
"id": "mp",
"type": "external",
"label": "Mercado Pago",
"sublabel": "OAuth · Checkout Pro",
"pos": [
610,
320
],
"size": [
130,
60
],
"sources": [
{
"path": "apps/backend/src/modules/mp/lib/mp-oauth.ts",
"line": 3,
"end_line": 4
},
{
"path": "apps/backend/src/modules/mp/lib/mp-http.ts",
"line": 4
}
]
},
{
"id": "stripe",
"type": "external",
"label": "Stripe",
"sublabel": "Pro fuera de AR",
"pos": [
760,
320
],
"size": [
110,
60
],
"sources": [
{
"path": "apps/backend/src/modules/billing/providers/index.ts",
"line": 24,
"end_line": 31
}
]
},
{
"id": "whatsapp",
"type": "external",
"label": "WhatsApp",
"sublabel": "OpenWA / Kapso",
"pos": [
890,
320
],
"size": [
130,
60
],
"sources": [
{
"path": "apps/backend/src/modules/whatsapp/providers/index.ts",
"line": 26,
"end_line": 40
}
]
},
{
"id": "smtp",
"type": "external",
"label": "SMTP",
"sublabel": "mails",
"pos": [
1040,
320
],
"size": [
100,
60
],
"sources": [
{
"path": "apps/backend/src/lib/email.ts",
"line": 181,
"end_line": 187
}
]
},
{
"id": "storage",
"type": "cloud",
"label": "S3 (RustFS)",
"sublabel": "comprobantes",
"pos": [
1160,
320
],
"size": [
130,
60
],
"sources": [
{
"path": "apps/backend/src/lib/storage.ts",
"line": 38,
"end_line": 54
}
]
}
],
"boundaries": [
{
"kind": "region",
"label": "Dokploy",
"wraps": [
"nginx",
"guards",
"api",
"db"
]
},
{
"kind": "security-group",
"label": "contenedor api",
"wraps": [
"guards",
"api"
]
}
],
"connections": [
{
"id": "teacher-web",
"from": "teacher",
"to": "web",
"label": "HTTPS",
"variant": "emphasis"
},
{
"id": "student-web",
"from": "student",
"to": "web",
"label": "link de WhatsApp"
},
{
"id": "web-nginx",
"from": "web",
"to": "nginx",
"label": "/api/v1",
"variant": "emphasis"
},
{
"id": "nginx-guards",
"from": "nginx",
"to": "guards",
"label": "proxy_pass",
"variant": "emphasis"
},
{
"id": "guards-api",
"from": "guards",
"to": "api",
"variant": "security"
},
{
"id": "api-db",
"from": "api",
"to": "db",
"label": "SQL"
},
{
"id": "api-mp",
"from": "api",
"to": "mp",
"label": "cobros"
},
{
"id": "api-stripe",
"from": "api",
"to": "stripe",
"label": "Pro"
},
{
"id": "api-whatsapp",
"from": "api",
"to": "whatsapp",
"label": "mensajes"
},
{
"id": "api-smtp",
"from": "api",
"to": "smtp",
"label": "mails"
},
{
"id": "api-storage",
"from": "api",
"to": "storage",
"label": "URLs firmadas"
}
],
"cards": [
{
"dot": "cyan",
"title": "Entrada",
"items": [
"Un solo dominio público en el contenedor web: nginx sirve la PWA y hace proxy de /api a api:4000, así la cookie de sesión es first-party.",
"Los alumnos entran por un link de invitación de un solo uso; no tienen contraseña."
]
},
{
"dot": "rose",
"title": "Seguridad",
"items": [
"sessionAuthMiddleware exige sesión de Better Auth salvo la whitelist pública (isPublicApiRequest).",
"/student-portal usa cookie y middleware propios (studentSession); una sesión de alumno no llega a rutas del profe.",
"Los webhooks de MP, Stripe y WhatsApp son públicos y se autentican por firma."
]
},
{
"dot": "emerald",
"title": "Jobs en el mismo proceso",
"items": [
"server.ts arranca los crons de MP, pagos, WhatsApp, billing y app de alumnos junto a Bun.serve.",
"La conciliación de pagos es por polling a Mercado Pago, sin webhook."
]
}
]
}

View File

@@ -0,0 +1,515 @@
{
"schema_version": 1,
"diagram_type": "erd",
"meta": {
"title": "Personas y membresías",
"locale": "es",
"output": ".archify/erd-personas-membresias-20261103-120000/personas-membresias.html",
"quality_profile": "standard",
"repository": {
"url": "https://git.2pidev.com/jselesan/gruperly.git",
"link_mode": "local-only",
"revision": "d21e1c37302d8d3f2ff8b0af05f4df21284bffe3"
},
"views": [
{
"id": "membership",
"label": "Persona y membresía",
"focus": [
"people",
"attendees",
"groups"
],
"note": "Una persona del profe, una fila de attendees por cada grupo en el que está."
},
{
"id": "owner",
"label": "Todo cuelga del profe",
"focus": [
"users",
"groups",
"people",
"student_accounts"
],
"note": "Grupos, personas y cuentas de alumno tienen created_by_id al profe."
},
{
"id": "student_app",
"label": "Una cuenta por persona",
"focus": [
"student_accounts",
"student_account_people",
"people"
],
"note": "La cuenta se vincula a la persona, así ve todos sus grupos."
}
]
},
"layout": {
"mode": "grid",
"gapX": 72,
"gapY": 40
},
"entities": [
{
"id": "groups",
"label": "groups",
"tag": "grupos",
"row": 0,
"col": 0,
"width": 256,
"sources": [
{
"path": "apps/backend/prisma/models/domain.prisma",
"line": 3,
"end_line": 32
}
],
"attributes": [
{
"name": "id",
"type": "text",
"key": "pk"
},
{
"name": "name",
"type": "text"
},
{
"name": "description",
"type": "text?"
},
{
"name": "days",
"type": "WeekDay[]"
},
{
"name": "time",
"type": "text?"
},
{
"name": "capacity",
"type": "int?"
},
{
"name": "price",
"type": "numeric(10,2)?"
},
{
"name": "billing_type",
"type": "BillingType?"
},
{
"name": "due_day",
"type": "int?"
},
{
"name": "auto_payment_reminders",
"type": "boolean"
},
{
"name": "auto_reengagement",
"type": "boolean"
},
{
"name": "invite_token",
"type": "text?",
"key": "uk"
},
{
"name": "created_by_id",
"type": "text",
"key": "fk",
"references": "users.id"
},
{
"name": "created_at",
"type": "timestamp"
},
{
"name": "updated_at",
"type": "timestamp"
}
]
},
{
"id": "attendees",
"label": "attendees",
"sublabel": "membresía",
"tag": "membresías",
"row": 0,
"col": 1,
"width": 250,
"sources": [
{
"path": "apps/backend/prisma/models/domain.prisma",
"line": 100,
"end_line": 125
}
],
"attributes": [
{
"name": "id",
"type": "text",
"key": "pk"
},
{
"name": "group_id",
"type": "text",
"key": [
"fk",
"uk"
],
"references": "groups.id"
},
{
"name": "person_id",
"type": "text",
"key": [
"fk",
"uk"
],
"references": "people.id"
},
{
"name": "notify_token",
"type": "text?",
"key": "uk"
},
{
"name": "status",
"type": "AttendeeStatus"
},
{
"name": "created_at",
"type": "timestamp"
},
{
"name": "updated_at",
"type": "timestamp"
}
]
},
{
"id": "people",
"label": "people",
"sublabel": "persona del profe",
"tag": "personas",
"row": 0,
"col": 2,
"width": 250,
"sources": [
{
"path": "apps/backend/prisma/models/domain.prisma",
"line": 75,
"end_line": 98
},
{
"path": "apps/backend/prisma/migrations/20261102180000_add_people/migration.sql",
"line": 155,
"label": "índice parcial"
}
],
"attributes": [
{
"name": "id",
"type": "text",
"key": "pk"
},
{
"name": "created_by_id",
"type": "text",
"key": [
"fk",
"uk"
],
"references": "users.id"
},
{
"name": "full_name",
"type": "text"
},
{
"name": "email",
"type": "text?"
},
{
"name": "phone",
"type": "text?",
"key": "uk"
},
{
"name": "guardian_name",
"type": "text?"
},
{
"name": "guardian_phone",
"type": "text?"
},
{
"name": "notes",
"type": "text?"
},
{
"name": "created_at",
"type": "timestamp"
},
{
"name": "updated_at",
"type": "timestamp"
}
]
},
{
"id": "users",
"label": "users",
"sublabel": "profesor",
"tag": "profesor",
"row": 1,
"col": 2,
"width": 250,
"sources": [
{
"path": "apps/backend/prisma/models/auth.prisma",
"line": 3,
"end_line": 34
}
],
"attributes": [
{
"name": "id",
"type": "text",
"key": "pk"
},
{
"name": "name",
"type": "text"
},
{
"name": "email",
"type": "text",
"key": "uk"
},
{
"name": "email_verified",
"type": "boolean"
},
{
"name": "image",
"type": "text?"
},
{
"name": "onboarding_completed",
"type": "boolean"
},
{
"name": "country_code",
"type": "text?"
},
{
"name": "plan_selected_at",
"type": "timestamp?"
},
{
"name": "transfer_alias",
"type": "text?"
},
{
"name": "transfer_holder",
"type": "text?"
},
{
"name": "created_at",
"type": "timestamp"
},
{
"name": "updated_at",
"type": "timestamp"
}
]
},
{
"id": "student_account_people",
"label": "student_account_people",
"tag": "app de alumnos",
"row": 0,
"col": 3,
"width": 300,
"sources": [
{
"path": "apps/backend/prisma/models/student-access.prisma",
"line": 40,
"end_line": 54
}
],
"attributes": [
{
"name": "account_id",
"type": "text",
"key": [
"pk",
"fk"
],
"references": "student_accounts.id"
},
{
"name": "person_id",
"type": "text",
"key": [
"pk",
"fk"
],
"references": "people.id"
},
{
"name": "created_at",
"type": "timestamp"
}
]
},
{
"id": "student_accounts",
"label": "student_accounts",
"tag": "app de alumnos",
"row": 1,
"col": 3,
"width": 300,
"sources": [
{
"path": "apps/backend/prisma/models/student-access.prisma",
"line": 10,
"end_line": 38
}
],
"attributes": [
{
"name": "id",
"type": "text",
"key": "pk"
},
{
"name": "name",
"type": "text"
},
{
"name": "recovery_email",
"type": "text?"
},
{
"name": "recovery_email_verified_at",
"type": "timestamp?"
},
{
"name": "pending_recovery_email",
"type": "text?"
},
{
"name": "welcomed_at",
"type": "timestamp?"
},
{
"name": "created_by_id",
"type": "text",
"key": "fk",
"references": "users.id"
},
{
"name": "created_at",
"type": "timestamp"
},
{
"name": "updated_at",
"type": "timestamp"
}
]
}
],
"relationships": [
{
"id": "attendee_group",
"from": "attendees",
"to": "groups",
"label": "en el grupo",
"fromCardinality": "many",
"fromOptional": true,
"toCardinality": "one"
},
{
"id": "attendee_person",
"from": "attendees",
"to": "people",
"label": "membresía de",
"fromCardinality": "many",
"toCardinality": "one"
},
{
"id": "person_owner",
"from": "people",
"to": "users",
"label": "del profe",
"fromCardinality": "many",
"fromOptional": true,
"toCardinality": "one"
},
{
"id": "group_owner",
"from": "groups",
"to": "users",
"label": "dueño",
"fromCardinality": "many",
"fromOptional": true,
"toCardinality": "one"
},
{
"id": "link_person",
"from": "student_account_people",
"to": "people",
"fromCardinality": "many",
"fromOptional": true,
"toCardinality": "one"
},
{
"id": "link_account",
"from": "student_account_people",
"to": "student_accounts",
"fromCardinality": "many",
"toCardinality": "one"
},
{
"id": "account_owner",
"from": "student_accounts",
"to": "users",
"label": "creada por",
"fromCardinality": "many",
"fromOptional": true,
"toCardinality": "one"
}
],
"cards": [
{
"dot": "cyan",
"title": "Unicidad",
"items": [
"attendees: @@unique(group_id, person_id), una persona está una sola vez en cada grupo.",
"people_owner_phone_key: (created_by_id, phone) WHERE phone IS NOT NULL, índice parcial escrito a mano (Prisma no lo modela; el choque llega como P2002)."
]
},
{
"dot": "amber",
"title": "Qué es de quién",
"items": [
"people: contacto y notas; editarlos cambia en todos los grupos.",
"attendees: status y notify_token por grupo; asistencia, cuotas, alertas y mensajes cuelgan de esta fila (no dibujados).",
"El límite del plan cuenta personas con al menos una membresía ACTIVE."
]
},
{
"dot": "emerald",
"title": "Borrados",
"items": [
"Todas las FK son ON DELETE CASCADE.",
"Quitar la última membresía borra también la persona, y con ella el vínculo a la cuenta de alumno."
]
}
]
}

File diff suppressed because one or more lines are too long