How ezegatica/que-me-pongo works
Project Type and Purpose
• The project is a full-stack web application built with Next.js (using the new “app” directory structure). The purpose is to assist users by recommending clothing choices based on real-time temperature data from the OpenWeatherMap API and historical user responses.
• It integrates user onboarding, personalized recording of responses, and several forms of user interaction (e.g., login, settings, form submissions).
Analyzing the File Structure
• Top-Level Directories and Files:
• The “app” folder holds the React components, pages, layouts, and API routes.
• “app/api” contains API endpoints including routes for authentication (using NextAuth, as suggested by the [...nextauth] route), health checks (e.g., DB health), open graph metadata (OG), and secure revalidation endpoints.
• “app/app” and its nested directories (e.g., forms, onboarding, pronostico, respuestas, etc.) show that the application is segmented into various functional modules.
• The “prisma” folder holds the database schema and migrations, revealing that Prisma is used for ORM/database management.
• Configuration files such as next.config.js, tsconfig.json, tailwind.config.ts, and various linting/prettier configuration files indicate standard project setup and stylistic enforcement.
Key System Components
a. Frontend Components:
• Next.js Pages & Layouts: Represented under “app/landing”, “app/app”, “app/auth”, etc.
• Shared and reusable components under “app/(components)” (e.g., banners, buttons, toast notifications, headers, etc.).
• Onboarding UI flows and settings pages that customize the user experience.
b. Backend/API Components:
• API Routes: Under “app/api”, grouped by functionality (authentication, health, OG metadata, secure revalidation), these endpoints provide RESTful interfaces or Next.js server-side endpoints.
• Authentication System: Clearly indicated by the “auth” folder and NextAuth route handling.
c. Database and ORM:
• Prisma ORM: With migrations in the “prisma/migrations” folder and schema defined in “prisma/schema.prisma”; stores user responses, preferences, and related data.
• Database: The physical persistence layer that Prisma communicates with (likely PostgreSQL, MySQL, or another relational database) though that isn’t directly mentioned but can be inferred.
d. External Services and Integration:
• Weather API Integration: Utilizing OpenWeatherMap API as described in the README; this data drives the recommendation logic.
• Possibly additional integrations for authentication or other services, as hinted by security-related API endpoints.
e. Middleware & Global Configurations:
• Middleware found in “middleware.ts” that may handle authentication, logging, or routing pre-processing.
• Global styles and configurations (e.g., “app/globals.css”, tailwind.config.ts) consolidating the app’s visual and style management.
Relationships and Data Flow
• The Frontend (React components/pages) makes calls to the API endpoints which handle data logic and communicate with the database.
• The API layer authenticates users (via NextAuth) and also processes incoming weather information and user input (e.g., form actions for onboarding, settings, and “¿Qué me pongo?” queries).
• Prisma serves as a bridge between the API and the underlying database, handling migrations and queries.
• External API integration (OpenWeatherMap) feeds current and forecast weather data into the recommendation logic, influencing the UI responses and records.
Architectural Patterns and Design Principles
• Separation of Concerns: Clear division between UI (components and pages), API logic (serverless API routes), and data persistence (Prisma with migrations).
• Integration Pattern: Use of external REST APIs (OpenWeatherMap) within the backend to enhance data-driven decisions.