Project Setup
Let’s get your development environment ready and run the ML Store project! This guide will walk you through every step from downloading the code to seeing it live in your browser.Quick Start
If you’re experienced with Node.js projects, here’s the TL;DR:Terminal
For detailed explanations of each step, continue reading below.
Step-by-Step Setup
Navigate to Project Directory
Open your terminal and navigate to where you have the tutorial source code:Verify you’re in the correct directory:
Install Dependencies
Install the required packages (Vite and TypeScript):
What's happening during installation?
What's happening during installation?
npm reads
package.json and downloads:- Vite 7.3.1 - Development server and build tool
- TypeScript 5.9.3 - TypeScript compiler and type definitions
- Their dependencies (a few dozen packages)
node_modules/ folder (which can be safely deleted and reinstalled anytime).This typically takes 30-60 seconds depending on your internet speed.The
node_modules folder can be large (50-100MB). This is normal for modern JavaScript projects.Start Development Server
Launch the Vite development server:You’ll see output similar to:
Success! Your development server is running.
Open in Browser
Open your web browser and navigate to:You should see the ML Store homepage with:
- Yellow header with search bar
- “Envío gratis desde $299” hero banner
- Benefits section with icons
- “Cargar Productos” button
Test the Application
Click the “Cargar Productos” button to fetch products from the API.
What should happen?
What should happen?
- Loading State: Spinner appears briefly
- Products Load: Grid of 20 product cards appears
- Interactive Features:
- Hover over product cards to see animation
- Click “Agregar al carrito” on any product
- Watch the cart counter in the header update
- See toast notification appear
Development Workflow
Hot Module Replacement (HMR)
Vite provides instant feedback as you code:NPM Scripts Explained
Yourpackage.json defines three scripts:
- npm run dev
- npm run build
- npm run preview
Starts the development server
- Runs Vite in development mode
- Enables Hot Module Replacement
- Serves files from
http://localhost:5173/ - TypeScript is compiled on-the-fly
- Source maps for easy debugging
Project Structure Deep Dive
Let’s explore what each file does:📄 index.html - Main HTML Structure
📄 index.html - Main HTML Structure
- 800+ lines of educational comments
- Semantic HTML5 elements
- BEM class naming convention
- Accessibility attributes (ARIA labels)
- Template element for product cards
📘 src/main.ts - TypeScript Application Logic
📘 src/main.ts - TypeScript Application Logic
The main TypeScript file handles:State Management:API Integration:Shopping Cart:1000+ lines of explanatory comments teach TypeScript concepts.
🎨 src/style.css - CSS Styling
🎨 src/style.css - CSS Styling
The stylesheet implements modern CSS:CSS Variables:BEM Methodology:Modern Layouts:
⚙️ tsconfig.json - TypeScript Configuration
⚙️ tsconfig.json - TypeScript Configuration
- Enables all strict type checking
- Targets modern browsers (ES2022)
- Includes DOM type definitions
- Works seamlessly with Vite
📦 package.json - Project Metadata
📦 package.json - Project Metadata
Browser Developer Tools Setup
Maximize your learning by using DevTools effectively:Common Setup Issues
Port Already in Use
Port Already in Use
Error:Solution:
- Stop other Vite instances
- Or specify a different port:
Module Not Found
Module Not Found
Error:Solution:
Run
npm install again:TypeScript Errors
TypeScript Errors
Error:Solution:
This means type assertions are needed. The tutorial code already handles this correctly. If you’re modifying code, use type assertions:
API Request Fails
API Request Fails
Error:Solutions:
- Check your internet connection
- Verify the API is accessible: https://api.escuelajs.co/api/v1/products
- Check browser console for CORS errors
- Try disabling browser extensions (especially ad blockers)
The Platzi Fake Store API is free and public, but occasionally may have downtime.
Blank Page
Blank Page
Problem:
Browser shows blank page or loading forever.Solutions:
- Check Console (F12 → Console) for JavaScript errors
- Hard Refresh:
Ctrl+Shift+R(Windows) orCmd+Shift+R(Mac) - Clear Cache: In DevTools → Network → Check “Disable cache”
- Restart Dev Server:
Ctrl+Cto stop, thennpm run devagain
Next Steps: Exploring the Code
Now that everything is running, here’s how to learn effectively:Start with HTML
Open
index.html and read through the comments. They explain:- Why we use semantic elements
- How BEM class naming works
- HTML accessibility best practices
- Form and input fundamentals
Study the CSS
Open
src/style.css and explore:- CSS variable system
- Flexbox and Grid layouts
- BEM class organization
- Responsive design patterns
- Animations and transitions
Dive into TypeScript
Open
src/main.ts and follow:- Interface and type definitions
- Async/await patterns
- State management approach
- DOM manipulation techniques
- Event handling strategies
Helpful Commands Reference
VS Code Tips
View Source Code
The complete source code is in
~/workspace/source/mi-tutorial/Start Learning
Read through the comments in each file to understand how everything works together.
You’re all set! Start exploring the code and building amazing web applications.