A modern React TypeScript application that allows users to search for GitHub users and explore their public repositories. Built with React Context API, Material-UI, Framer Motion, and powered by the GitHub API.
- User Search: Search for GitHub users by username
- Repository Explorer: View user's public repositories with detailed information
- Responsive Design: Fully responsive interface built with Material-UI
- Smooth Animations: Enhanced user experience with Framer Motion animations
- Loading States: Skeleton loaders for better UX during data fetching
- Expandable Interface: Click on users to expand and view their repositories
- Pagination: Load more repositories with pagination support
- React 19.1.0 - Modern React with latest features
- TypeScript - Type-safe development
- Vite - Fast build tool and development server
- Material-UI (MUI) 7.1.1 - React component library
- Emotion - CSS-in-JS styling solution
- Framer Motion 12.18.1 - Animation library
- Plus Jakarta Sans - Modern typography
- React Context API - Global state management
- Custom Hooks - Reusable stateful logic
- Octokit/REST 22.0.0 - Official GitHub API client
- Vitest - Fast unit testing framework
- Testing Library - React component testing utilities
- ESLint - Code linting and formatting
- Prettier - Code formatting
- TypeScript ESLint - TypeScript-specific linting rules
- Lodash - Utility functions (debouncing, etc.)
Before running this project, make sure you have the following installed:
- Node.js (version 18.0 or higher)
- npm or yarn package manager
- GitHub Personal Access Token (for API access)
git clone https://github.com/your-username/github-repositories-explorer.git
cd github-repositories-explorerUsing npm:
npm installUsing yarn:
yarn installCreate a .env file in the root directory and add your GitHub Personal Access Token:
VITE_GITHUB_TOKEN=your_github_personal_access_token_hereHow to get a GitHub Personal Access Token:
- Go to GitHub Settings β Developer settings β Personal access tokens
- Click "Generate new token (classic)"
- Select scopes:
public_repoandread:user - Copy the generated token and paste it in your
.envfile
npm run dev
# or
yarn devThe application will be available at http://localhost:5173
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run lint- Run ESLintnpm run format- Format code with Prettiernpm run test- Run testsnpm run test:watch- Run tests in watch mode
github-repositories-explorer/
βββ public/ # Static assets
β βββ vite.svg
βββ src/
β βββ assets/ # Images, icons, and static files
β β βββ icons/ # SVG icons
β βββ components/ # React components
β β βββ app-context-provider.tsx
β β βββ github-context-provider.tsx
β β βββ github-repositories-explorer.tsx
β β βββ github-repository-item.tsx
β β βββ github-user-item.tsx
β β βββ header.tsx
β β βββ searcbar.tsx
β β βββ *.test.tsx # Component tests
β βββ contexts/ # React Context definitions
β β βββ app.context.tsx
β β βββ github.context.tsx
β β βββ index.ts
β βββ hooks/ # Custom React hooks
β β βββ useApp.hook.ts
β β βββ useGithub.hook.ts
β β βββ index.ts
β βββ plugins/ # Third-party integrations
β β βββ @mui/ # Material-UI theme configuration
β β βββ axios/ # Axios configuration
β β βββ octokit/ # GitHub API client setup
β βββ services/ # API services and data fetching
β β βββ github.api.ts
β βββ test/ # Test configuration
β β βββ setup.ts
β βββ types/ # TypeScript type definitions
β β βββ app.d.ts
β β βββ github.d.ts
β βββ App.tsx # Main App component
β βββ main.tsx # Application entry point
β βββ vite-env.d.ts # Vite environment types
βββ dist/ # Production build output
βββ node_modules/ # Dependencies
βββ .env # Environment variables (create this)
βββ eslint.config.js # ESLint configuration
βββ package.json # Project dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ vite.config.ts # Vite configuration
βββ README.md # Project documentation
The application uses React Context API for global state management with two main contexts:
-
AppContext (
src/contexts/app.context.tsx)- Manages application-wide settings (theme, etc.)
- Provides
isDarkstate for theme switching
-
GithubContext (
src/contexts/github.context.tsx)- Manages GitHub-related data and state
- Handles users list, repositories, loading states, and UI interactions
App
βββ AppContextProvider
β βββ GithubContextProvider
β β βββ MuiThemeProvider
β β β βββ Header
β β β βββ GithubRepositoriesExplorer
β β β βββ SearchBar
β β β βββ GithubUserItem[]
β β β βββ GithubRepositoryItem[]
- User types in the search bar (debounced input)
GitHubApi.fetchSearchUsers()is called- Results are stored in
GithubContext - User clicks on a user item
GitHubApi.fetchRepositories()fetches user's repositories- Repositories are displayed with expand/collapse animation
- GitHub REST API via Octokit client
- Search Users:
/search/usersendpoint - User Repositories:
/users/{username}/reposendpoint - User Data:
/user/{account_id}endpoint for repository count
- Search for Users: Type a GitHub username in the search bar
- View Results: Up to 5 matching users will be displayed
- Explore Repositories: Click on any user to expand and view their repositories
- Load More: Use "Load More" button to fetch additional repositories
- Visit GitHub: Click the arrow icon to open the user's GitHub profile
The project includes comprehensive unit tests using Vitest and Testing Library:
# Run all tests
npm run test
# Run tests in watch mode
npm run test:watch
# Run specific test file
npm run test src/components/github-user-item.test.tsx- Component rendering and interactions
- API service mocking
- Context provider functionality
- User event handling
- Debounced Search: Uses Lodash debounce to prevent excessive API calls
- Real-time Results: Updates results as you type
- Error Handling: Graceful handling of API errors and rate limits
- Expandable Cards: Smooth animations using Framer Motion
- Pagination: Load repositories in chunks of 10
- Repository Details: Shows name, description, language, stars, and forks
- Empty States: Handles users with no public repositories
- React.memo: Prevents unnecessary re-renders of user items
- useCallback: Optimizes event handlers and API calls
- useMemo: Caches computed values like pagination logic
- Skeleton Loading: Provides visual feedback during data fetching
- Mobile-First: Optimized for mobile devices
- Breakpoint System: Uses Material-UI's responsive breakpoints
- Flexible Layouts: Adapts to different screen sizes
npm run buildThe build artifacts will be stored in the dist/ directory.
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod# Build the project
npm run build
# Deploy the dist/ folder to Netlify- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript best practices
- Write tests for new components
- Use Material-UI components when possible
- Follow the existing code structure and naming conventions
- Run
npm run lintandnpm run formatbefore committing
| Variable | Description | Required |
|---|---|---|
VITE_GITHUB_TOKEN |
GitHub Personal Access Token | Yes |
- GitHub API rate limiting (60 requests per hour for unauthenticated requests)
- Some users might have private repositories that won't be displayed
- GitHub API for providing the data
- Material-UI for the beautiful components
- Framer Motion for smooth animations
- Vite for the fast development experience
Made with β€οΈ by Rizki Muhamad s.
