Skip to content

safaahammoud/classified-ads

Repository files navigation

Ads Platform

A modern, feature-rich ads platform built with React 19 and TypeScript. This application allows users to browse and post advertisements for various categories including mobile phones, cars, and apartments.

Note: This project currently uses mock data and API responses for development. A real backend will be integrated in a future release.

πŸš€ Features

  • Browse Ads: View categorized listings for mobile phones, cars, and apartments
  • Post Ads: Dynamic form system that adapts based on selected category
    • Dynamic field generation from API/mock data
    • Support for text inputs, select dropdowns, and checkbox groups
    • Real-time validation with Zod schemas
  • Multi-language Support: Full internationalization with English and Arabic (RTL support)
  • Responsive Design: Mobile-first approach with modern UI components
  • Category Management: Dynamic category selection with nested subcategories
  • Form Validation: Comprehensive validation system with Zod schemas and custom rules
  • Top Navigation: Fixed horizontal navigation bar with logo, language toggle, and post ad button
  • Mock Data: Development mode uses mock data for categories and form fields

πŸ› οΈ Tech Stack

  • Framework: React 19 with TypeScript
  • Build Tool: Vite 7
  • UI Components:
    • Radix UI (Checkbox, Dialog, Label, Select)
    • react-select for dropdowns
    • Custom components built with Tailwind CSS
  • State Management:
    • TanStack Query (React Query) for server state
    • React Context for client state
  • Routing: React Router v7 with lazy loading
  • Internationalization: react-i18next (en/ar) with RTL support
  • Forms:
    • React Hook Form for form management
    • Zod 4 for schema validation
    • @hookform/resolvers for integration
  • Styling: Tailwind CSS 4
  • HTTP Client: Axios
  • Testing:
    • Vitest for unit tests
    • React Testing Library for component tests
  • Code Quality: ESLint + Prettier + TypeScript strict mode
  • Git Hooks: Husky + lint-staged

πŸ“ Project Structure

src/
β”œβ”€β”€ components/              # Shared components
β”‚   β”œβ”€β”€ core/               # Core app components
β”‚   β”‚   β”œβ”€β”€ CartLogo.tsx
β”‚   β”‚   β”œβ”€β”€ ErrorBoundary.tsx
β”‚   β”‚   └── PageLoader.tsx
β”‚   β”œβ”€β”€ navigation/         # Navigation components
β”‚   β”‚   β”œβ”€β”€ NavigationMenu.tsx
β”‚   β”‚   └── index.ts
β”‚   └── shared/             # Shared UI components
β”‚       β”œβ”€β”€ icons/          # Icon components (BackIcon, CheckIcon, etc.)
β”‚       β”œβ”€β”€ dynamic-form/   # Dynamic form system
β”‚       β”‚   β”œβ”€β”€ DynamicForm.tsx
β”‚       β”‚   └── utils/      # Form transformation utilities
β”‚       β”œβ”€β”€ AdCardSkeleton.tsx
β”‚       β”œβ”€β”€ Alert.tsx
β”‚       β”œβ”€β”€ Button.tsx
β”‚       β”œβ”€β”€ Checkbox.tsx
β”‚       β”œβ”€β”€ CheckboxGroup.tsx
β”‚       β”œβ”€β”€ DynamicField.tsx
β”‚       β”œβ”€β”€ Form.tsx
β”‚       β”œβ”€β”€ Input.tsx
β”‚       β”œβ”€β”€ Select.tsx
β”‚       └── index.ts        # Public exports
β”œβ”€β”€ features/               # Feature-based modules
β”‚   β”œβ”€β”€ home/              # Home feature
β”‚   β”‚   β”œβ”€β”€ pages/         # HomePage
β”‚   β”‚   β”œβ”€β”€ navigation.ts
β”‚   β”‚   └── index.ts
β”‚   └── ad-management/     # Ad management feature
β”‚       β”œβ”€β”€ components/    # Feature-specific components
β”‚       β”‚   β”œβ”€β”€ AdCategoryGrid.tsx
β”‚       β”‚   β”œβ”€β”€ AdCategoryColumns.tsx
β”‚       β”‚   β”œβ”€β”€ BaseAdCard.tsx
β”‚       β”‚   β”œβ”€β”€ CarAdCard.tsx
β”‚       β”‚   β”œβ”€β”€ ApartmentAdCard.tsx
β”‚       β”‚   └── MobileAdCard.tsx
β”‚       β”œβ”€β”€ hooks/         # Feature-specific hooks
β”‚       β”‚   β”œβ”€β”€ useAds.ts
β”‚       β”‚   β”œβ”€β”€ useCategoryAdFields.ts
β”‚       β”‚   └── useAdCardData.ts
β”‚       β”œβ”€β”€ pages/         # Feature pages
β”‚       β”‚   β”œβ”€β”€ AdCategoriesPage.tsx
β”‚       β”‚   └── SellAdFormPage.tsx
β”‚       β”œβ”€β”€ services/      # Feature API services
β”‚       β”‚   └── adsService.ts
β”‚       β”œβ”€β”€ types/         # Feature-specific types
β”‚       β”‚   β”œβ”€β”€ ads.ts
β”‚       β”‚   β”œβ”€β”€ carAds.ts
β”‚       β”‚   β”œβ”€β”€ apartmentAds.ts
β”‚       β”‚   └── mobileAds.ts
β”‚       β”œβ”€β”€ utils/         # Feature utilities
β”‚       β”‚   β”œβ”€β”€ fieldGrouping.ts
β”‚       β”‚   └── carAdFieldExtractors.ts
β”‚       β”œβ”€β”€ navigation.ts
β”‚       └── index.ts
β”œβ”€β”€ contexts/              # React contexts
β”‚   └── LanguageContext.tsx
β”œβ”€β”€ hooks/                 # Shared custom hooks
β”‚   β”œβ”€β”€ useCategories.ts
β”‚   β”œβ”€β”€ useSelectedCategory.ts
β”‚   └── queryUtils.ts
β”œβ”€β”€ services/              # API services
β”‚   β”œβ”€β”€ apiService.ts      # Axios instance & request handler
β”‚   β”œβ”€β”€ categoriesService.ts
β”‚   └── mocks/             # Mock data for development
β”‚       β”œβ”€β”€ mockCategories.json
β”‚       β”œβ”€β”€ mockMobileFieldsResponse.json
β”‚       β”œβ”€β”€ mockVehicleFieldsResponse.json
β”‚       └── mockApartmentsFieldsResponse.json
β”œβ”€β”€ routes/                # Routing configuration
β”‚   β”œβ”€β”€ AppRouter.tsx
β”‚   β”œβ”€β”€ RootLayout.tsx
β”‚   └── navigation.ts
β”œβ”€β”€ types/                 # TypeScript type definitions
β”‚   β”œβ”€β”€ adsCategory.ts
β”‚   β”œβ”€β”€ components.ts
β”‚   β”œβ”€β”€ form.ts
β”‚   β”œβ”€β”€ navigation.ts
β”‚   └── index.ts
β”œβ”€β”€ constants/             # Application constants
β”‚   β”œβ”€β”€ routes.ts
β”‚   β”œβ”€β”€ language.ts
β”‚   β”œβ”€β”€ svgIcons.json
β”‚   └── home.ts
β”œβ”€β”€ utils/                 # Utility functions
β”‚   β”œβ”€β”€ cn.ts              # className utility
β”‚   β”œβ”€β”€ ads.ts
β”‚   β”œβ”€β”€ date.ts
β”‚   └── locationUtils.ts
β”œβ”€β”€ styles/                # Global styles
β”‚   β”œβ”€β”€ global.css
β”‚   └── navigation-menu.css
β”œβ”€β”€ i18n/                  # Internationalization
β”‚   β”œβ”€β”€ index.ts
β”‚   └── locales/
β”‚       β”œβ”€β”€ en.json
β”‚       └── ar.json
β”œβ”€β”€ test/                  # Test setup
β”‚   └── setup.ts
β”œβ”€β”€ App.tsx                # Root app component
└── main.tsx               # Application entry point

πŸ—οΈ Architecture

  • Feature-based Organization: Each feature is self-contained with its own components, hooks, pages, services, types, and navigation
  • Atomic Design: Components organized by complexity (atoms, molecules, organisms)
  • SOLID Principles: Separation of concerns and single responsibility
  • Path Aliases: Uses &/ prefix for src/ imports (e.g., &/components, &/features)
  • Dynamic Forms: Form fields are generated dynamically from API/mock data with automatic schema validation
  • Type Safety: Strict TypeScript mode with comprehensive type definitions

🚦 Getting Started

Prerequisites

  • Node.js (v22.12.0 or higher recommended)
  • Yarn 4.0.2 (npm is not supported)

Installation

# Install dependencies
yarn install

# Start development server
yarn dev

# Build for production
yarn build

# Preview production build
yarn preview

πŸ“œ Available Scripts

  • yarn dev - Start development server with HMR
  • yarn build - Build for production (TypeScript check + Vite build)
  • yarn preview - Preview production build locally
  • yarn test - Run unit tests with Vitest
  • yarn test:ui - Run tests with Vitest UI
  • yarn test:coverage - Run tests with coverage report
  • yarn lint - Run ESLint
  • yarn lint:fix - Fix ESLint issues automatically
  • yarn format - Format code with Prettier
  • yarn format:check - Check code formatting without fixing

🌐 Internationalization

The application supports two languages:

  • English (en) - Default
  • Arabic (ar) - With RTL support

Translation files are located in src/i18n/locales/. All user-facing text should use translation keys - no hardcoded strings.

🎨 Design System

  • Primary Color: Cyan (#5dcbf4)
  • Navigation: Fixed top horizontal navigation bar with white background
  • Components:
    • Built with Radix UI primitives
    • Styled with Tailwind CSS 4
    • Custom icon components using SVG paths from constants/svgIcons.json
  • Responsive: Mobile-first design approach
  • Form System: Dynamic form generation based on category with Zod validation

πŸ§ͺ Testing

# Run unit tests
yarn test

# Run tests with UI
yarn test:ui

# Run tests with coverage
yarn test:coverage

πŸ“ Code Quality

The project uses:

  • ESLint for linting
  • Prettier for code formatting
  • TypeScript in strict mode
  • Husky for git hooks
  • lint-staged for pre-commit checks

Code is automatically formatted and linted on commit.

πŸ”§ Development Guidelines

  • Follow SOLID principles
  • Use feature-based organization
  • Implement atomic design patterns
  • All text must be internationalized
  • Mobile-first responsive design
  • Use TypeScript strict mode
  • Write tests for critical functionality
  • Follow conventional commit format

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing

Feel free to fork this repository and create a pull request with improvements or additional features. Feedback is always welcome!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors