This project was created for the Snappfood code challenge, where I implemented a restaurant list for Snappfood. Users can explore restaurants and their details through this web application.
You can check out the Live Demo, powered by Hamravesh, by visiting this link.
- React: The foundation of the project, allowing for dynamic and interactive user interfaces.
- TypeScript: Enhancing code quality and providing static type checking.
- Redux and Redux Toolkit: Managing global state and actions efficiently.
- SASS: Styling the components using the BEM methodology.
- Vite: A fast build tool for bundling and serving the application.
-
Virtual List: I've implemented
TanStack Virtual
to ensure efficient rendering of long lists. This results in a smooth user experience, especially when dealing with a large number of restaurants. -
Infinite Fetching: For fetching restaurant data, I've used
RTK Query
. The infinite fetching feature is powered byIntersection Observer
, which loads more data as the user scrolls down. -
Global Store:
Redux
manages the application's state, making it easy to share data across components. -
Lazy Loading for Images: To optimize performance, I've implemented lazy loading for images. Images load only when they become visible on the screen, enhancing the overall user experience. Additionally, I've added a skeleton animation for restaurant cards during loading.
-
BEM Methodology for SASS: Following the
Block Element Modifier (BEM)
methodology ensures consistent and maintainable styling. It prevents class name conflicts and keeps the codebase organized. -
Error Handling and 404 Page: Proper error handling is crucial. I've set up
middleware
in Redux Toolkit to handle errors gracefully. Additionally, I've created a custom 404 page for incorrect routes. -
Deployment with Docker: The project is deployed on Hamravesh using a
Dockerfile
and docker-compose. This ensures consistency across environments. -
Geolocation API: I've integrated the
geolocation API
to retrieve the user's latitude and longitude. This feature could be useful for location-based services. -
Code Quality Tools:
ESLint
helps identify and fix code issues, whilePrettier
ensures consistent formatting and sorted imports.
To run this project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/ghmasood/snappfood-code-challenge.git
-
Install dependencies:
yarn install
-
Start the development server:
yarn dev
-
Open your browser and visit: http://localhost:3000
.
├── public # Public Assets
├── src # Source files
│ ├── assets # Styles and other assets that needs to be transpiled at the build time
│ ├── types # Global types
│ ├── pages(app) # Next.js File routings/App Directory
│ └── components # All Major and Minor Components will place here
├── config files # .env files, docker files, bundler configs, .eslintrc, package.json, tsconfig.json, etc.
└── README.md
.
│ ├── ...
│ └── components
| ├── ExampleComponent # ExampleComponent Folder
| | ├── components # Sub Components of Example Component
| | ├── componentName.module.scss # Modular Styles
| | └── index.tsx # Main File (only contains imports, hook calls and jsx codes)
│ ├── ...
Home Page | Restaurants Page | Restaurants Skeleton |
Not found Page | Fallback page |