EventHub: Unveiling Core System Workflows & Interactions
Welcome to a deep dive into EventHub, our cutting-edge Event Management System! Built with a modern tech stack comprising React, Vite, and Supabase, EventHub is designed to offer a seamless and efficient experience for event organizers, attendees, and administrators alike. This article aims to provide a comprehensive, human-readable walkthrough of the system's core interaction flows, leveraging detailed sequence diagrams that are meticulously aligned with our current codebase. For both seasoned developers and curious users, understanding these system workflows is paramount to appreciating the robust architecture and the thoughtful design behind every user action. We'll explore everything from secure user authentication powered by Supabase Auth to intricate ticket purchasing processes involving real-time stock validation and unique QR code generation. Our persistence layer relies on the public schema of Supabase, while frontend logic is expertly managed using services and the efficient Zustand state management library. This allows us to handle complex features like event-specific payment methods, critical email verification guards, and comprehensive analytics calculations based on actual user interactions and database records. Get ready to embark on a journey that illuminates the inner workings of EventHub, revealing the magic behind its smooth operation and paving the way for future enhancements and a truly unique event experience.
š Autenticación y Gestión de Usuarios: La Puerta de Entrada a EventHub
In any modern application, especially a bustling platform like EventHub, robust and secure user authentication isn't just a featureāit's the absolute bedrock of trust and functionality. This section delves into how EventHub meticulously handles the crucial process of user authentication and management, ensuring that every interaction, from the moment a user decides to register to the final logout, is secure, intuitive, and seamlessly integrated. We leverage Supabase Auth, a powerful and developer-friendly authentication solution, which provides a solid foundation for managing user identities, email verifications, and secure sessions. The user journey begins with registration, where a mandatory email verification step acts as a crucial guard, preventing unverified access and bolstering security. Once verified, users gain access tailored to their specific rolesābe it an attendee eager to discover new experiences, an organizer planning their next big event, or an administrator overseeing the entire platform. On the frontend, the powerful Zustand state management library plays a pivotal role, ensuring that user authentication status and profile information are consistently and efficiently managed across the application, delivering a smooth and responsive user experience. This meticulous approach to user lifecycle management underscores our commitment to providing a safe, reliable, and user-centric platform where every participant feels confident and empowered. Understanding these flows is fundamental to appreciating how EventHub safeguards user data and maintains an orderly digital environment.
UC-001: Registrar Usuario (email + verificación obligatoria)
When a user decides to register for EventHub, they initiate this crucial flow by submitting their details through the frontend application. The React app first performs a quick check against the Supabase Database (BD) to ensure the email isn't already in use, preventing duplicate accounts and enhancing the user registration experience. If the email is available, the app then communicates with Supabase Auth to perform the signUp action, which is configured to redirect to a specific callback URL (/auth/callback) after successful authentication and to include user metadata. A critical step here is that Supabase Auth automatically dispatches a verification email to the provided address. Simultaneously, the app upserts a pending profile into the BD, marking the user's email as unverified. The user is then prompted to verify their email. Upon clicking the verification link in their email, they are redirected to the callback URL with an access_token. This token is then used by the callback to set the session via Supabase Auth, update the user's email_verified status in the BD, map their role, and store the authenticated user's data within the Zustand store. Finally, the user is redirected to the appropriate section of the application (e.g., events, organizer dashboard) based on their assigned role, ensuring a personalized and secure onboarding experience.
UC-002: Autenticar Usuario (login con password)
For existing users, the login process is designed to be straightforward yet secure. When a user provides their email and password, the EventHub frontend first performs a signOut action to clear any lingering previous sessions, ensuring a clean authentication state. Subsequently, it calls the signInWithPassword() method on Supabase Auth. Upon receiving a response from Supabase Auth, the system checks if the user's email has been verified. This is a critical security guard: if the email is unconfirmed, the user is prompted with an error message, and another signOut is performed to prevent unverified access. If the email is verified, the application then queries the Supabase Database (BD) through a dedicated ServicioUsuarios to fetch the user's complete profile, including their rol (e.g., administrador, organizador, asistente). This role is then mapped to its corresponding frontend identifier (admin, organizer, attendee) and stored in the Zustand state, allowing for dynamic UI rendering and access control. Finally, the user is redirected to the appropriate dashboard or section of the app, ensuring a tailored and secure user session.
UC-003: Cerrar Sesión
The logout process in EventHub is designed for simplicity and security, ensuring that users can easily and safely end their session. When a user chooses to