How therealadil/dreamcatcher works
Main Components
• Frontend (Next.js Application):
• Pages and Routes: Represent the various pages, for example, the landing page (found in src/app/LandingPAge), dashboard (src/app/dashboard/page.js), form, and sign-in pages.
• Layout & Global Styles: The global layout (src/app/layout.js), globals.css, and CSS modules used for styling.
• Reusable Components: Such as Header, Footer, and NiceButton in src/app/components which are used across pages.
• Backend/API Routes:
• API Endpoints: The project leverages Next.js API routes (e.g., src/app/api/explain-dream/route.js) to handle server-side logic for functionalities like explaining dreams.
• Authentication Routes: Special endpoints for handling auth callbacks (src/app/auth/callback/route.js).
• Backend Service (Supabase):
• Supabase Client: Located under src/lib/supabaseClient.js, this file sets up the connection to Supabase for managing user authentication and database interactions.
• External Services and Deployment:
• Authentication: Integration with Google Sign-In through Supabase.
• Deployment: The application is deployed on Vercel.
Relationships and Interactions
• Client Interactions:
• Browser users interact with the Next.js frontend which renders the various pages and components.
• The frontend communicates with the backend API routes for dynamic functionalities (e.g., dream explanations).
• Data Flow:
• User inputs from the frontend trigger API calls (e.g., capturing and interpreting dreams).
• API endpoints fetch or update data via the Supabase client.
• Authentication flows involve redirection to auth callback endpoints followed by Supabase verification with Google.
• Component Reusability:
• Common components (Header, Footer, NiceButton) are used across various pages, ensuring consistency in UI and reducing redundancy.
Architectural Patterns and Design Principles
• File-Based Routing: Implemented by Next.js, categorizing pages and API endpoints.
• Separation of Concerns: Clear division between UI (pages and components), server-side logic (API routes and auth callbacks), and data management (Supabase client).
• Modular Design: Well-organized directories for components, API, pages, and utility logic (lib), making the system extensible and maintainable.
• External Service Integration: The use of Supabase for both authentication and database operations centralizes backend services.
Technologies, Frameworks, and Libraries
• Next.js (React framework, App Router)
• React for building UI components
• Supabase for backend, authentication, and database management
• CSS Modules for component-specific styling
• Vercel for deployment
• ESLint and Jest for development and testing