Hello!
In the last lesson, we established a crucial piece of our application's infrastructure by connecting our Flask backend to a MongoDB Atlas database. You now have a backend that is state-ready, waiting to manage and serve data for our recommendation engine.
This lesson shifts our focus to the user-facing part of the application: the frontend. Our learning outcome is to build a frontend dashboard skeleton using React, displaying placeholder product cards and a recommendation panel, and serve it locally. Since you have experience with React, we'll dive right into building a clean, component-based structure that can be easily expanded upon in future lessons. We will use Vite for a fast development environment and Tailwind CSS for rapid, utility-first styling.
Let's start building the visual interface for our H&M recommendation system.
1. Setting Up Your React Frontend
First, we'll initialize a new React project inside our main project directory and configure it with Tailwind CSS. This combination provides a powerful and efficient development experience.
In your project's root directory (the one containing your backend folder and .git), create a new directory named frontend. We will initialize our React app here.
The following video provides an excellent guide on setting up a React project using Vite and then integrating Tailwind CSS.
Responsive Dashboard with Sidebar & Dark Mode in React & Tailwind CSS
Watch this segment from the video 'Responsive Dashboard with Sidebar & Dark Mode in React & Tailwind CSS' by Mitter - Your Tech Mate. It clearly demonstrates how to initialize a new React project with Vite and configure Tailwind CSS.
Watch from 00:41 to 02:26. Follow the steps to create your React app inside the frontend directory and install/configure Tailwind. You can name the project something simple like 'hm-fashion-recs-fe'. Make sure to clean out the boilerplate CSS and JSX as shown in the video to start with a blank slate.
By the end of this step, you should have a frontend directory containing a basic React application that you can run locally using npm run dev.
2. Structuring the Dashboard
A well-structured application is built from reusable components. For our dashboard, we will create a simple layout with a header, a main content area for our products, and a sidebar that we can use for filters later.
The article "Build a Full-Stack E-Commerce React App from Scratch" provides a great overview of a standard project structure for an e-commerce application, which is very similar to what we are building.
Build a Full-Stack E-Commerce React App from Scratch - Dev.to
This article outlines a typical project structure for a React e-commerce app, which is a great reference for organizing our own components.
Briefly read the 'Project Structure and Key Features' section. Pay attention to the use of a components folder to hold reusable UI pieces and a pages folder. For now, we will put everything in src/components and assemble them in App.jsx.
3. Building the Core Components
Now, let's build the visual components: the main layout, the product cards, and the grid that will contain them.
The Overall Layout
The video "Responsive Dashboard with Sidebar & Dark Mode" that you referenced for setup also contains excellent guidance for building a responsive layout with a sidebar and main content area. We can adapt this for our dashboard.
Responsive Dashboard with Sidebar & Dark Mode in React & Tailwind CSS
This video provides a complete walkthrough of building a dashboard layout. We'll use it as a guide for creating our header, sidebar, and main content area.
You don't need to code along with this entire video, but use it as a primary reference for building the layout in App.jsx. Top Bar/Header (03:28 - 07:07): Watch this to see how a simple header is constructed. You can create a Header.jsx component for this. Sidebar (07:07 - 17:09): This section shows how to build a responsive sidebar. Create a Sidebar.jsx component. For now, it can just be a styled container with some placeholder text like 'Filters'. Main Content Grid (17:09 - 19:44): This part is key. It shows how to create a responsive grid layout using Tailwind CSS. This will be the container for our product cards.
The Product Card
The most important component for our app is the ProductCard. This will display an item's image, name, and price. For now, we'll use placeholder content.

The video below gives a fantastic, detailed walkthrough of creating stylish and responsive product cards with a hover effect. This is directly applicable to our needs.
React JS & Tailwind CSS Responsive Website - Beginner Friendly
This section of 'React JS & Tailwind CSS Responsive Website' by Code Commerce is perfect for building our ProductCard component.
Watch the segment from 53:26 to 01:03:10. Follow the instructions to create a ProductCard.jsx component. You can simplify it by removing the logic for the middle card being different. Focus on creating one reusable card with: A placeholder for an image. An h2 for the product title. A p tag for the price. A button (e.g., 'View Details'). The shadow and hover-scaling effects, which add a professional touch.
Your Task: Build the Frontend Skeleton
Now it's time to put all the pieces together. Follow these steps to build and run your frontend dashboard skeleton.
-
Initialize Project: If you haven't already, create the
frontenddirectory. Inside it, runnpm create vite@latest . -- --template react(the.will create it in the currentfrontenddirectory). Then, follow the video guide to install and configure Tailwind CSS. -
Create Component Files: Inside
frontend/src/, create a new directory namedcomponents. Insidesrc/components/, create the following files:Header.jsxSidebar.jsxProductCard.jsx
-
Implement
ProductCard.jsx:- Using the video guide, build your product card component. Use a placeholder image from a service like placeholder.com (e.g.,
https://via.placeholder.com/150). - The card should display a placeholder title, price, and a button.
Here's some starter JSX for
ProductCard.jsxto guide you:// src/components/ProductCard.jsx import React from 'react'; const ProductCard = ({ product }) => { return ( <div className="w-full max-w-sm mx-auto rounded-md shadow-md overflow-hidden transform hover:scale-105 duration-300"> <div className="flex items-end justify-end h-56 w-full bg-cover" style={{ backgroundImage: `url(${product.imageUrl})` }}> <button className="p-2 rounded-full bg-blue-600 text-white mx-5 -mb-4 hover:bg-blue-500 focus:outline-none focus:bg-blue-500"> {/* Icon placeholder */} <svg className="h-5 w-5" fill="none" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" viewBox="0 0 24 24" stroke="currentColor"><path d="M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"></path></svg> </button> </div> <div className="px-5 py-3"> <h3 className="text-gray-700 uppercase">{product.name}</h3> <span className="text-gray-500 mt-2">${product.price}</span> </div> </div> ); }; export default ProductCard; - Using the video guide, build your product card component. Use a placeholder image from a service like placeholder.com (e.g.,
-
Assemble the Layout in
App.jsx:- Clear the default content from
frontend/src/App.jsx. - Import your
Header,Sidebar, andProductCardcomponents. - Use Tailwind CSS classes (
flex,grid,grid-cols-*) to create the main layout: aHeaderat the top, aSidebaron the left, and a main content area on the right. - In the main content area, create a "Recommendations" panel. This can be as simple as a
divwith a heading (h2) that says "Our Top Picks for You". - Inside this panel, create a responsive grid and map over a small, hardcoded array of product data to render several
ProductCardcomponents.
- Clear the default content from
-
Run the Application:
- From your
frontenddirectory, runnpm run devin the terminal. - Open your browser to the local address provided (usually
http://localhost:5173). You should see your dashboard skeleton.
- From your
Verification
To confirm you've successfully built the skeleton, please provide the following:
- The final directory structure of your
frontend/srcfolder. - The complete code from
frontend/src/App.jsx. - The complete code from
frontend/src/components/ProductCard.jsx.
Great job! You've now scaffolded the frontend of our application. This component-based structure is scalable and ready to be integrated with our backend.
In the next lesson, we will make these two separate parts—frontend and backend—talk to each other for the first time by having our React app call the /health endpoint on our Flask server.