How isuu1/gifinity works
Project Type and Purpose
• Gifinity is a full-stack Next.js web application built with the App Router. Its primary functionality is to let users search and browse GIFs and stickers from the Giphy API. The app supports guest usage (storing favorites locally) and registered accounts (transferring and saving favorites to a database via Supabase). Additional features include smooth UI animations with Framer Motion.
File Structure
• Top-level directories and key parts include:
• The “app” folder, which contains pages segmented by user flows (authentication, main app pages, modals) following Next.js concepts.
• The “api” folder under “app” that provides backend endpoints for authentication, categories, search (including autocomplete, gifs, stickers), trending searches, and trending data.
• Feature-specific folders (“features/auth”, “features/categories”, “features/collections”, “features/favourites”, “features/media”, “features/search”, “features/user”) that separate the core application logic such as actions, components, schemas, types, and utilities.
• Shared components under “components” and layout definitions under “layouts” that reinforce separation of UI elements.
• Integration with Supabase (see “utils/supabase” folder), which handles authentication and database interactions.
• The file tree reflects a modular and organized approach, dividing presentation, business logic, and API interactions.
Key Components
a. Frontend:
• Next.js App: Represented by the “app” directory with segmented routes for:
• Auth Module: login, signup pages, and modals.
• Main Content: categories, trending, search, error pages, and user profiles.
• Special UI components for modals, headers, footers, etc.
• Shared Components and Layouts: All the UI elements imported from “components” and “layouts” provide the visual part of the application.
• Client-Side State & Local Storage: Illustrate how favorites are stored locally for non-authenticated users.
• Animations: Note that Framer Motion is used to enhance the smooth UI transitions.
b. API & Backend:
• Next.js API Routes: Under “app/api” handling business logic for authentication and content retrieval from the Giphy API.
• External API Integration: Clearly indicate the interaction with the Giphy API to fetch GIFs and stickers.
• Supabase Integration: Represent the Supabase service that manages authentication and is linked to database actions (like syncing favorites) as encapsulated in the “utils/supabase” module.
c. Data Storage:
• Local Storage: For persisting guest user favorites.
• Database (Supabase): For storing authenticated user data and favorites, which is synchronized during login.
Component Relationships & Data Flow
• The Browser/User Interface sends user inputs (search queries, actions like adding/removing favorites) to Next.js page components.
• Data returned from external services (Giphy API) flows into the API routes, then transformed and passed to the UI.
• Authentication modules interact with Supabase to handle user sessions and data storage, with local storage used for guest sessions.
Architectural Patterns & Design Principles
• Modularization: The separation into multiple “features” folders (auth, search, etc.) indicates a modular design that isolates functionality.
• Separation of concerns: Clean division between UI (presentation), business logic (features/actions), and backend (API endpoints).
• API Gateway/Back-end for Frontend: Next.js API routes serve as the middle layer connecting the frontend to external APIs and the database.
• Client-side vs. Server-side rendering: Next.js under the App Router suggests a mix of both patterns, with server-side endpoints fetching data and UI composed by dynamic React components.
Putting It All Together
• Out behavioral flows:
• From user interactions on the search page to the API fetch from Giphy API.
• From actions (like favorite selection) that initially update local storage and then are migrated to Supabase upon authentication.