Directory Overview
GitScope follows a standard Vite + React project structure with clear separation between source code, configuration, and build artifacts.Root Directory
Configuration Files
vite.config.js
vite.config.js
Purpose: Vite build tool configurationLocation: Key Settings:
/vite.config.jsContents:plugins: [react()]→ Enables React Fast Refresh and JSX transformationbase: '/github-dashboard/'→ Sets base path for GitHub Pages deployment
package.json
package.json
Purpose: Project metadata, dependencies, and scriptsLocation:
/package.jsonKey Sections:name:github-dashboardtype:module(ES modules)homepage: Deployment URL for GitHub Pagesscripts: Build, dev, and deployment commandsdependencies: Production runtime dependenciesdevDependencies: Build-time development tools
index.html
index.html
Purpose: HTML entry point for the applicationLocation:
/index.htmlKey Features:- Single page application (SPA) entry point
- Contains root
<div id="root">mount point - Imports
/src/main.jsxas JavaScript module - Vite injects script tags during development and build
.gitignore
.gitignore
Purpose: Excludes files from Git version controlTypical Contents:
node_modules/→ Dependenciesdist/→ Build output.env→ Environment variables- Editor-specific files
/src Directory
The src/ folder contains all application source code.
Entry Points
main.jsx
Purpose: React application bootstrapResponsibilities:
- Imports React and ReactDOM
- Renders root
<App />component - Mounts to
#rootelement inindex.html
index.css
Purpose: Global styles and CSS variablesContents:
- CSS reset (box-sizing, margin, padding)
:rootCSS variables for light theme[data-theme="dark"]variables for dark theme- Global animations (fadeUp, spin, pulse, shimmer)
- Utility classes (.fade-up, .skeleton, .spinner)
- Custom scrollbar styles
Root Component
App.jsx & App.module.css
App.jsx & App.module.css
Purpose: Root component and application orchestratorLocation:
src/App.jsx + src/App.module.cssResponsibilities:- Manages all top-level application state
- Coordinates data fetching via
useGitHubhook - Renders child components with appropriate props
- Handles theme persistence and switching
- Implements search and pagination logic
theme,user,repos,selectedRepo,loading,error,page,hasMore,currentUsername,showToken
App.jsx acts as the single source of truth for application state. No global state management library is used.
/src/components Directory
All UI components live here, each with its own .module.css file for scoped styles.
Component Files
Header
Files:
Header.jsx, Header.module.cssPurpose: Top navigation barFeatures:- App logo and title
- Dark/light theme toggle button
- Rate limit indicator (color-coded)
- “Token API” button to open modal
SearchBar
Files:
SearchBar.jsx, SearchBar.module.cssPurpose: User search interfaceFeatures:- Text input with Enter key support
- “Analizar” submit button
- Suggestion chips (torvalds, gvanrossum, etc.)
- Loading spinner during search
UserCard
Files:
UserCard.jsx, UserCard.module.cssPurpose: User profile displayFeatures:- Avatar image
- Name and bio
- Company, location, social links
- Stats grid (repos, followers, following, gists)
LanguageChart
Files:
LanguageChart.jsx, LanguageChart.module.cssPurpose: Language distribution visualizationFeatures:- Recharts donut chart
- Fetches languages for top 12 repos
- In-memory caching with
useRef - Aggregates bytes by language
- Legend with color-coded bars
RepoList
Files:
RepoList.jsx, RepoList.module.cssPurpose: Repository grid with filtersFeatures:- Filter by minimum stars
- Sort by updated/stars/forks
- Responsive grid layout
- Pagination controls
- Click to select repo for commit view
CommitPanel
Files:
CommitPanel.jsx, CommitPanel.module.cssPurpose: Display recent commitsFeatures:- Shows last 10 commits for selected repo
- Commit message, author avatar, SHA
- Repository metadata sidebar
- “View on GitHub” link
- Close button to collapse panel
TokenModal
Files:
TokenModal.jsx, TokenModal.module.cssPurpose: GitHub token configurationFeatures:- Modal overlay with form
- Secure password-type input
- Save and remove token buttons
- Instructions for creating token
ErrorBanner
Files:
ErrorBanner.jsx, ErrorBanner.module.cssPurpose: Dismissible error messagesFeatures:- Red banner with error text
- Close button (X icon)
- Auto-dismiss option (if implemented)
/src/hooks Directory
Custom React hooks for reusable stateful logic.
useGitHub.js
useGitHub.js
Purpose: GitHub API abstraction layerLocation: Internal State:
src/hooks/useGitHub.jsExports:token: Loaded from localStorage on mountrateLimit: Extracted from API response headers
request(path, params): Generic API request handlerheaders(): Generates headers with optional tokensaveToken(t): Persists token to localStorage
CSS Modules Organization
Why CSS Modules?
GitScope uses CSS Modules for component styling, providing:Scoped Styles
Class names are automatically namespaced to prevent collisions
Colocation
Each component’s styles live next to its JSX file
Tree Shaking
Unused styles are removed during build
Type Safety
Class names can be autocompleted in modern editors
Naming Convention
Every component follows this pattern:Usage Pattern
The hash suffix (
__a7b3c) is generated by Vite to ensure uniqueness.Global vs. Scoped Styles
Global Styles (index.css)
Used for:
- CSS variables (colors, spacing, fonts)
- CSS resets
- Global utility classes (
.fade-up,.skeleton,.spinner) - Keyframe animations
- Theme definitions (
:root,[data-theme="dark"])
Scoped Styles (.module.css)
Used for:
- Component-specific layouts
- Element-specific styles
- Component state variations (
.selected,.active)
RepoList.module.css):
Note how
.module.css files reference global CSS variables defined in index.css.Build Output (/dist)
Generated by running npm run build. This folder is deployed to GitHub Pages.
Contents:
- All JavaScript is bundled and minified
- CSS Modules are compiled to plain CSS with hashed class names
- Assets include content hashes for cache busting
- Source maps generated for debugging (if configured)
GitHub Actions Workflow
Location:.github/workflows/deploy.yml
Purpose: Automated deployment to GitHub Pages on push to main branch
Typical Steps:
- Checkout code
- Install Node.js
- Install dependencies (
npm ci) - Build application (
npm run build) - Deploy
dist/folder togh-pagesbranch
File Naming Conventions
| File Type | Convention | Example |
|---|---|---|
| Components | PascalCase + .jsx | SearchBar.jsx |
| Component Styles | PascalCase + .module.css | SearchBar.module.css |
| Hooks | camelCase + .js | useGitHub.js |
| Global Styles | lowercase + .css | index.css |
| Config | lowercase + .js | vite.config.js |
Import Path Patterns
Relative Imports
All imports use relative paths (no path aliases configured). Examples:Import Order Convention
Adding New Components
To add a new component, follow these steps:Next Steps
Architecture
Learn about system architecture and design patterns
Tech Stack
Explore the technologies and dependencies