mirror of
https://github.com/CarGDev/debug-dojo.git
synced 2025-09-18 09:58:37 +00:00

- Add PokemonAutoComplete atom component using Ant Design - Implement API layer with axios for Pokémon data fetching - Create Zustand store for centralized state management - Add autocomplete suggestions with real-time filtering - Update SearchBar molecule to use autocomplete functionality - Load all Pokémon names on app initialization - Add path aliases for cleaner imports (@api, @stores) - Remove old service layer in favor of API layer - Maintain intentional bugs for debugging practice - Update project structure and documentation
3.7 KiB
3.7 KiB
Pokémon Explorer App
A Vite + React + TypeScript application that allows users to search for Pokémon and view their details using the PokeAPI.
Features
- Search for Pokémon by name with autocomplete suggestions
- Display Pokémon details including:
- Name and image
- Types
- Base stats with progress bars
- Height and weight
- Modern UI built with Ant Design
- Atomic Design architecture
- Centralized state management with Zustand
- API layer with axios for data fetching
Project Structure
src/
├── api/ # API layer with axios
│ ├── config.ts # Axios configuration
│ ├── get/ # GET requests
│ ├── post/ # POST requests
│ ├── put/ # PUT requests
│ ├── delete/ # DELETE requests
│ └── index.ts # API exports
├── components/
│ ├── atoms/ # Basic UI elements (Input, Button, AutoComplete)
│ ├── molecules/ # Combinations (SearchBar)
│ ├── organisms/ # Complex components (PokemonDetails)
│ ├── templates/ # Layout structure (MainLayout)
│ └── pages/ # Route-level views (Home)
├── stores/ # Zustand state management
│ ├── pokemonStore.ts # Pokémon state store
│ └── index.ts # Store exports
├── styles/ # SCSS modules
│ ├── global.module.scss # Global styles
│ ├── app.module.scss # App-specific styles
│ └── index.ts # Style exports
└── types/ # TypeScript type definitions
Path Aliases
The project uses path aliases for cleaner imports:
@/
- Points tosrc/
@components/
- Points tosrc/components/
@styles/
- Points tosrc/styles/
@pokemonTypes/
- Points tosrc/types/
@api/
- Points tosrc/api/
@stores/
- Points tosrc/stores/
Example usage:
// Instead of: import { PokemonInput } from '../../components/atoms/PokemonInput';
import { PokemonInput } from '@components/atoms/PokemonInput';
// Instead of: import styles from '../../styles/app.module.scss';
import styles from '@styles/app.module.scss';
// Instead of: import { getPokemon } from '../../api/get/pokemon';
import { getPokemon } from '@api/get/pokemon';
// Instead of: import { usePokemonStore } from '../../stores/pokemonStore';
import { usePokemonStore } from '@stores/pokemonStore';
Intentional Bugs (For Debugging Session)
⚠️ These bugs are intentionally left in the code for debugging practice:
- Silent Failure: When a Pokémon doesn't exist, no error message is shown - the app silently fails
- UI Flickering: When searching for a new Pokémon, the previous data briefly disappears causing a flicker effect
- Incorrect Stat Mapping: Speed and defense stats are swapped in the display
- TypeScript Error: The
height
field is assumed to always be present when it's actually optional in the API
Getting Started
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Open your browser and navigate to the URL shown in the terminal
Usage
- Enter a Pokémon name in the search bar (e.g., "pikachu", "charizard", "bulbasaur")
- Click "Search" or press Enter
- View the Pokémon's details including stats, types, and image
Technologies Used
- Vite - Build tool and dev server
- React - UI framework
- TypeScript - Type safety
- Ant Design - UI component library
- PokeAPI - Pokémon data source
Available Scripts
npm run dev
- Start development servernpm run build
- Build for productionnpm run preview
- Preview production build