How hayashi13597/flexibble-web3 works
Project Type & Purpose
• The project is a hybrid web application that combines a creative portfolio platform (resembling Dribbble, here called “Flexibble”) with a crowdfunding component that integrates Web3 functionality.
• The Flexibble side allows users to sign in with Gmail (authentication), share, edit, and delete work; the Crowdfunding side allows users to connect a wallet (e.g., via MetaMask), create campaigns, fund them, and view profiles with campaign lists.
• It leverages Next.js with API routes for serverless backend functions, and it appears to be extended with a GraphQL backend through a “grafbase” integration. There’s also notable Web3-specific modules for blockchain interactions.
Analyzing the File Structure
• The top-level directories include:
• app: Contains all Next.js pages and API routes. Here you have separate subdirectories for API routes (such as /api/auth, /api/upload, etc.) and top-level pages for different sections (main page, projects, profiles).
• app/web3: Dedicated folder for Web3-specific pages, including campaign details, creation, and profile views for the campaigning aspect.
• components: Reusable React components that support both the Flexibble and Web3 sides. Note separate Web3 components are also organized under components/Web3Component.
• context, lib, utils: Helper modules handling shared logic like session management, actions, and utilities.
• grafbase and graphql: These indicate a GraphQL service configuration likely used for data handling and possibly managing interactions between the front-end and a database.
• The presence of route.ts files hints at serverless functions used to handle dynamic API endpoints (e.g., for authentication with NextAuth, image uploads, and token management).
Key Components
a. Frontend (Client – Next.js):
• Two major sections: Flexibble (general pages such as home, create/edit project, profiles) and Crowdfunding/Web3 (pages under app/web3 including campaign details, wallet connection, campaign creation, etc.).
• Shared components (Navbar, Footer, Modals, Form components) that are rendered in these pages.
• Layout components (layout.tsx files) organizing the overall structure.
b. Backend/API Routes:
• API Endpoints:
• Auth endpoints for NextAuth (app/api/auth).
• Token and image handling endpoints.
• Upload and delete-image endpoints.
• These serverless routes manage communication with data services.
c. GraphQL Backend (Grafbase):
• The grafbase directory holds configuration and an environment file for the GraphQL backend.
• This is connected to the “graphql” folder where client-side graphql queries/mutations are defined, suggesting that the frontend interacts with this layer to manage persistent data.
d. Web3 Integration:
• Dedicated components and pages that allow wallet connection, interaction with blockchain/campaign smart contracts.
• Components under components/Web3Component (e.g., DisplayCampaigns, FundCard, CustomButton) indicate how the UI is built for blockchain interactions.
e. Supporting Services & Libraries:
• Authentication using NextAuth (indicated by the [...nextauth] folder).
• Third-party integrations with MetaMask for wallet connection.
• Utility libraries and context management to manage global states like sessions and modals.
Architectural Patterns & Design Principles
• Separation of Concerns: Notice the clear separation between UI (pages/components), API routes (serverless functions), GraphQL backend configuration, and utility functions.
• Modularization: Components are grouped by domain (regular vs. Web3) and API functionality, making it easier to identify dependencies and extend functionality.
• Integration Layer: The app serves as an integration point between conventional RESTful API calls and modern GraphQL interactions, along with blockchain (Web3) operations.