How lorenzopalaia/blocktracr works
Based on an analysis of the file tree and README, Blocktracr is a full-stack web application that displays cryptocurrency market data and provides wallet reports, built with Next.js/React. The system architecture is divided between a client-facing frontend (UI, pages, and components) and server-side backend logic (API endpoints, authentication, and data fetching), plus integration with an external service (Supabase) for the database and authentication.
Core Components
• Frontend UI: Represented by the Next.js “app” directory that mostly mirrors the new “app” directory structure in Next.js 13. This includes pages (e.g., dashboard, coins, docs, error pages, account, cookie, etc.) and components (in “app/components” and “components”) for building the user interface.
• API Endpoints: Under “app/api”, separate folders are dedicated to authentication (signin, signup, forgot/reset password, signout, confirm) and cryptocurrency specific endpoints (coins, crypto-list, market-chart, global-market-data, trending). These endpoints are responsible for processing HTTP requests, interacting with data, and responding with JSON.
• State Management & Data Fetching: Custom hooks (in “hooks”) and stores (in “stores”) facilitate asynchronous data retrieval and manage UI state. They are key connectors between the UI components and the API.
• External Services: Supabase is used as the backend service and data store. SQL script files in the “supabase” folder (e.g., exchanges.sql, profiles.sql) highlight the database schema. Also include integration utilities in “utils/supabase”.
• Utility & Config Layers: The “utils”, “types”, “config” files and middleware (Next.js’s middleware.ts) handle cross-cutting concerns like encryption, price conversion, and client/server-side integration.
Establish Relationships and Interactions
• Client (Browser) → Frontend: Users interact with the UI built with React, with pages such as dashboard, coins details and account pages.
• UI Components & Hooks ↔ State Stores: Components use custom hooks to fetch data from the API, which are then stored in client-side state stores for reactivity.
• API Endpoints ↔ Supabase: The API endpoints interact with Supabase for running SQL operations, authentication verification, and data retrieval. Clearly mark these dependencies.
• Middleware & Routing: Highlight the role of Next.js middleware and configuration (e.g., next.config.ts) that routes requests and possibly applies site-wide logic (like theming via “ThemeProvider” found in the components).
Architectural Patterns & Design Principles
• Separation of Concerns: The project clearly separates the UI (presentational components), data fetching logic (hooks and stores), and backend processes (API endpoints).
• Modular Design: Different directories (account, dashboard, coins, docs) encapsulate features into distinct modules.
• Component Reusability: Extensive use of shared UI components (appearing in both “app/components” and “components/ui”) that promote reusability and consistency.
• Integration with External Services: Supabase integration for database operations and user authentication, along with state management libraries in hooks and stores.