daisy-client / README.md
Jessedbrown's picture
feat/init-daisy-client
6d643ca
|
Raw History Blame Contribute Delete
4.8 kB

Daisy - Digital Closet Frontend

A modern React-based frontend application for managing your digital wardrobe and discovering new fashion items through web scraping.

πŸ“‹ Features

  • Digital Closet Management: Add, view, and organize your wardrobe items
  • Product Discovery: Search and browse scraped fashion products from major retailers
  • Image Upload: Upload and manage photos of your clothing items

πŸ›  Tech Stack

  • Framework: React 18 with TypeScript
  • Build Tool: Vite
  • Styling: Tailwind CSS + Radix UI Components
  • State Management: TanStack Query (React Query)
  • Routing: React Router DOM v7
  • Form Handling: React Hook Form with Zod validation
  • HTTP Client: Axios
  • Testing: Vitest + React Testing Library
  • Deployment: Vercel

πŸ— Architecture Overview

The frontend follows a modern React architecture with clear separation of concerns:

Component Structure: The application uses a component-based architecture with reusable UI components built on Radix UI primitives. Components are organized into logical groups (ui, forms, layout) with consistent naming conventions.

State Management: TanStack Query handles server state management, providing caching, background updates, and optimistic updates. Local component state is managed with React hooks, while form state uses React Hook Form for optimal performance and validation.

πŸ“¦ Installation & Setup

Prerequisites

  • Node.js 18+
  • npm or yarn

Quick Start

  1. Clone the repository

    git clone https://github.com/JesseBrown1980/daisy-client.git
    cd daisy-client
    
  2. Install dependencies

    npm install
    
  3. Environment Configuration

    Create a .env.local file in the root directory:

    VITE_API_BASE_URL=http://localhost:3000/api/v1
    VITE_APP_NAME=Daisy
    
  4. Start the development server

    npm run dev
    

    The application will be available at http://localhost:5173

Build for Production

npm run build

The built files will be in the dist/ directory.

πŸ“ Project Structure

src/
β”œβ”€β”€ api/                 # API client and endpoint definitions
β”œβ”€β”€ components/          # React components
β”‚   β”œβ”€β”€ ui/             # Reusable UI components
β”‚   β”œβ”€β”€ router/         # Routing components
β”‚   └── __tests__/      # Component tests
β”œβ”€β”€ hooks/              # Custom React hooks
β”œβ”€β”€ lib/                # Utility libraries and configurations
β”œβ”€β”€ pages/              # Page components
β”œβ”€β”€ styles/             # Global styles
β”œβ”€β”€ types/              # TypeScript type definitions
└── utils/              # Helper functions and utilities

πŸ”§ Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run build:test - Build for testing environment
  • npm run build:prod - Build for production environment
  • npm run preview - Preview production build
  • npm run test - Run tests
  • npm run test:watch - Run tests in watch mode
  • npm run test:coverage - Run tests with coverage report
  • npm run lint - Lint code
  • npm run format - Format code with Prettier

🌐 Environment Variables

Variable Description Default
VITE_API_BASE_URL Backend API base URL http://localhost:3000/api/v1
VITE_APP_NAME Application name Daisy

πŸš€ Deployment

Vercel (Recommended)

  1. Connect your repository to Vercel
  2. Configure environment variables in Vercel dashboard
  3. Deploy - Vercel will automatically build and deploy

Manual Deployment

  1. Build the project

    npm run build
    
  2. Deploy the dist/ folder to your hosting provider

πŸ”— API Integration

The frontend communicates with the backend API through a centralized API client. All endpoints are typed with TypeScript for better development experience.

Key API Endpoints Used:

  • GET /closet - Fetch closet items
  • POST /closet - Add new closet item
  • DELETE /closet/:id - Remove closet item
  • GET /products - Search products
  • POST /products/:id/add-to-closet - Add product to closet
  • GET /scrape/brands - Get available brands
  • POST /scrape/brand/:brand - Start scraping

πŸ›‘ Error Handling

  • Error Boundaries: Catch and handle React component errors
  • API Error Handling: Centralized error handling with user-friendly messages
  • Form Validation: Real-time validation with clear error messages
  • Network Error Recovery: Automatic retries and offline support