How diegovianagomes/architecture-survey works
Main Components
• Frontend (User Interface):
• Pages and Routes: Represented by the Next.js "app" directory, which holds various pages including home, survey page, researcher/admin login, survey confirmation, and even example submissions.
• UI Components: Use of folders such as "components" and "components/ui" indicates a rich, reusable component system for elements like forms, charts (bar, pie, vertical-bar charts), alerts, dialogs, and other interactive UI elements.
• Styling: Global styles from "app/globals.css" and Tailwind configuration (tailwind.config.ts) should be noted.
• API Layer:
• A variety of API endpoints under "app/api" that handle different functionalities: email check, registration, survey submission, and reset data. These endpoints define routes to interact with both client-side and server-side logic.
• Backend / Data Services:
• Supabase Integration: The "lib/supabase", "lib/supabase-admin.ts", and "lib/supabase-client.ts" files indicate how the project communicates with Supabase for authentication, database queries, and possibly real-time data updates.
• Utility Functions: Located in "lib/utils" and related files, these provide helper functions (like email encryption and other business logic) related to data processing and security.
• Administration and Data Analysis:
• Admin Pages: The "app/admin" directory encapsulates the administration panel, used for reviewing and exporting research results.
Relationships and Interactions
• User Interaction Flow:
• Users (students/respondents) access the survey page to enter their responses.
• The frontend sends these responses to API endpoints (e.g., "app/api/submit-survey" or "app/api/survey/submit"), where the data is validated and then processed.
• During the survey process, email verification is performed (via endpoints like "app/api/check-email" and "app/api/register-email") with encryption before saving.
• Administrative Flow:
• Researchers or administrators log in via designated pages such as "app/researcher-login" or "app/admin/page.tsx".
• Once authenticated (backed by Supabase’s authentication processes), they can view survey results and detailed analyses.
• Data visualization is achieved through multiple chart components that render statistics on user responses.
• Data and Security:
• The API endpoints interact with a database (Supabase) through the lib layer.
• A dedicated set of utilities (under "lib/utils/email-crypto.ts") is used for ensuring email uniqueness and encryption, highlighting the security measures built into the system.
Architectural Patterns and Technologies
• Modern Full-Stack Architecture:
• Frontend built with Next.js using both server- and client-side rendering.
• API routes following RESTful patterns that handle data submission, retrieval, and security functions.
• Component-Based UI:
• Extensive use of reusable React components from shadcn/ui for consistency and scalability.
• Backend as a Service:
• Supabase integration central to managing data, making authentication secure, and executing CRUD operations on survey responses.
• Utility-driven Logic:
• Lib folders providing encapsulated business logic and helper functions essential for maintaining separation of concerns and reusability.