A React application built with Next.js and TypeScript that displays randomly generated user profiles by fetching data from external APIs with fallback support.
- 50 Fake User Profiles: Fetched from fakerapi.it with fallback to @faker-js/faker
- User Grid Display: Responsive grid layout showing user cards with avatar, name, job title, company, and location
- Sort by Name: Toggle between A-Z and Z-A sorting
- Filter by Location: Dropdown filter to show users from specific locations
- Individual Profile Pages: Click on any user card to view their detailed profile
- Scrollable Interface: Smooth scrolling through the user list
- Responsive Design: Works on all screen sizes
- Resilient Fallback: Automatically uses local data generation if API is unavailable
- User Notifications: Clear notification when using fallback data source
This application integrates with the following external APIs:
- fakerapi.it - Fetches person data from
/api/v1/personsendpoint- Retrieves 50 random person profiles
- Provides: name, email, phone, address, and location data
- No authentication required
- DiceBear API - Generates user avatars
- Creates unique avatar images based on user ID
- Style: Avataaars
- URL format:
https://api.dicebear.com/7.x/avataaars/svg?seed={id}
If the fakerapi.it API is unavailable or returns an error:
- Application automatically falls back to local @faker-js/faker library
- Generates 50 user profiles locally using the same data structure
- Displays a dismissable notification banner informing users about the fallback
- No interruption to user experience - all features remain functional
- Next.js 16 - React framework with App Router
- TypeScript - Type-safe development
- Tailwind CSS - Utility-first CSS framework
- fakerapi.it API - Primary data source for fake user profiles
- DiceBear API - Avatar generation service
- Faker.js - Fallback library for local data generation
- React Context API - Global state management
- Node.js 18+ installed
- npm package manager
- Clone the repository:
git clone https://github.com/Pyrem/ReactProject.git
cd ReactProject- Install dependencies:
npm install- Run the development server:
npm run dev- Open http://localhost:3000 in your browser
npm run build
npm startReactProject/
├── app/
│ ├── layout.tsx # Root layout with providers
│ ├── page.tsx # Main page with user grid
│ ├── globals.css # Global styles
│ └── users/
│ └── [id]/
│ └── page.tsx # Individual user profile page
├── components/
│ ├── Providers.tsx # Context providers wrapper
│ └── UserCard.tsx # User card component
├── contexts/
│ └── UserContext.tsx # User data context
├── types/
│ └── user.ts # User TypeScript interface
├── utils/
│ └── generateUsers.ts # Faker.js user generation
└── package.json
The application uses a well-defined User interface with the following properties:
id: Unique identifieravatar: Profile picture URLfirstName,lastName,fullName: Name informationemail,phone: Contact detailsjobTitle,company: Professional informationcity,state,country,location: Location databio,address,zipCode: Additional details