How devanup/devtective works
Main Components
• Frontend (UI & Client-Side Rendering):
• The primary UI is implemented using Next.js (see the src/app directory and the multiple React components spread across src/components). This includes layout, pages, and specialized components such as Header, Footer, and various cards for user profiles and repository stats.
• Within the UI, there are grouped components for charts (e.g., CommitActivity, TopLanguages, MostStarredChart) that render visual analytics.
• A theming mechanism is provided (refer to src/components/theme-provider.tsx) and several custom UI components under src/components/ui (like buttons, cards, inputs) that help in building a unified interface.
• Data Fetching & Business Logic Layer:
• The data access layer is clearly separated within the src/lib directory, where individual modules handle GitHub API calls (fetchUser, fetchRepoStats, etc.) and parse analytics (getContributions, getTopContributingRepos, etc.).
• There are also custom hooks (in src/hooks) such as useLocalStorage that help manage state and enhance reusability.
• External Service Integration:
• The external GitHub API (including use of GitHub GraphQL API as mentioned in the README) is central to the data sourcing, where the libraries in src/lib act as a bridge between the external data source and the internal components.
Relationships and Interactions
• The client-side components request data indirectly by invoking the functions found in the src/lib directory.
• Data flows from external APIs (GitHub API) → library functions (data fetching/parsing, e.g., fetchUser, getLangData) → custom hooks (e.g., useLocalStorage to manage client state) → presentation components (charts, UI cards).
• Layout components (in src/app and layout.tsx) act as the orchestrators that include Header, Footer, and main content components (like ProfileOverview and RepoOverview) which in turn use the more granular UI and chart components.
Architectural Patterns and Design Principles
• Separation of concerns: The project clearly separates UI components, data fetching logic, and utility functions. This modular setup makes it easier to manage and extend functionality.
• Component-driven architecture: By structuring the project into reusable components (especially in folders like ui, charts, skeletons, repository, user), the design supports maintainability and scalability.
• Use of TypeScript for type safety ensures robustness throughout the project.