Skip to content

A platform for pet adoption and temporary pet custody with blockchain-backed trust guarantees.

Notifications You must be signed in to change notification settings

amina69/PetAd-Frontend

Repository files navigation

License: MIT TypeScript React Vite

PetAd Frontend 🐾

A modern, responsive web application for pet adoption and temporary custody management, powered by blockchain-backed trust guarantees (Stellar trust layer integration).


Overview

PetAd Frontend is the client-side application for the PetAd platform, enabling users to browse pets, initiate adoption processes, and manage temporary custody arrangements. The application communicates exclusively with the PetAd backend API and does not directly interact with blockchain infrastructure.


✨ Features

  • πŸ” Pet Browsing & Search - Discover available pets with advanced filtering
  • ❀️ Adoption Workflows - Streamlined adoption process from inquiry to completion
  • ⏰ Temporary Custody - Request and manage short-term pet care arrangements
  • πŸ‘€ User Profiles - Personalized dashboards for pet seekers and caretakers
  • πŸ“„ Document Management - Secure upload and verification of required documents
  • πŸ”” Real-time Updates - Live status notifications for adoption and custody requests

πŸ› οΈ Tech Stack

Technology Purpose
React 18+ UI library
TypeScript Type-safe development
Vite Build tool and dev server
Tailwind CSS Utility-first styling
TanStack Query Server state management
React Router Client-side routing
Zod Schema validation

πŸ“¦ Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js >= 20.0.0
  • npm >= 10.0.0 or pnpm >= 8.0.0

Check your versions:

node --version
npm --version

πŸš€ Getting Started

Installation

  1. Clone the repository
git clone https://github.com/amina69/PetAd-Frontend.git
cd petad-frontend
  1. Install dependencies
npm install

Or using pnpm:

pnpm install

Environment Setup

Create a .env file in the project root:

VITE_API_URL=http://localhost:3000

Note: VITE_API_URL should point to your PetAd backend API instance.

Optional environment variables:

VITE_APP_NAME=PetAd
VITE_ENABLE_ANALYTICS=false

Running the App

Start the development server:

npm run dev

The application will be available at:

http://localhost:5173

πŸ“ Project Structure

src/
β”œβ”€β”€ api/              # API client and service layer
β”‚   β”œβ”€β”€ petService.ts
β”‚   β”œβ”€β”€ adoptionService.ts
β”‚   └── custodyService.ts
β”œβ”€β”€ components/       # Reusable UI components
β”‚   β”œβ”€β”€ common/
β”‚   β”œβ”€β”€ layout/
β”‚   └── forms/
β”œβ”€β”€ features/         # Domain-specific features
β”‚   β”œβ”€β”€ pets/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   └── types/
β”‚   β”œβ”€β”€ adoption/
β”‚   └── custody/
β”œβ”€β”€ hooks/            # Shared custom hooks
β”œβ”€β”€ pages/            # Route-level components
β”œβ”€β”€ utils/            # Helper functions and utilities
β”œβ”€β”€ types/            # Global TypeScript types
β”œβ”€β”€ main.tsx          # Application entry point
└── App.tsx           # Root component

Key Directories:

  • api/ - Centralized API communication layer
  • features/ - Feature-based architecture (pets, adoption, custody)
  • components/ - Reusable, presentational components
  • hooks/ - Custom React hooks for shared logic
  • pages/ - Top-level route components

πŸ§‘β€πŸ’» Development Guidelines

Code Style

  • Use feature-based architecture for scalability
  • Keep components small and focused (single responsibility)
  • Validate all forms with Zod schemas
  • Handle loading and error states explicitly
  • Use TypeScript strict mode (no implicit any)

Component Example

// features/pets/components/PetCard.tsx
import { Pet } from '@/types/pet';

interface PetCardProps {
  pet: Pet;
  onAdopt: (petId: string) => void;
}

export function PetCard({ pet, onAdopt }: PetCardProps) {
  return (
    <div className="rounded-lg border p-4">
      <h3 className="font-semibold">{pet.name}</h3>
      <p className="text-sm text-gray-600">{pet.breed}</p>
      <button 
        onClick={() => onAdopt(pet.id)}
        className="mt-2 rounded bg-blue-500 px-4 py-2 text-white"
      >
        Adopt Me
      </button>
    </div>
  );
}

Validation Example

import { z } from 'zod';

const adoptionFormSchema = z.object({
  fullName: z.string().min(2, 'Name must be at least 2 characters'),
  email: z.string().email('Invalid email address'),
  phone: z.string().regex(/^\+?[1-9]\d{1,14}$/, 'Invalid phone number'),
  reason: z.string().min(50, 'Please provide more details'),
});

type AdoptionFormData = z.infer<typeof adoptionFormSchema>;

πŸ“œ Scripts

Command Description
npm run dev Start development server (hot reload enabled)
npm run build Build optimized production bundle
npm run preview Preview production build locally
npm run type-check Run TypeScript compiler checks
npm run format Format code with Prettier

Important: Ensure environment variables are configured in your deployment platform:

  • VITE_API_URL - Backend API endpoint

πŸ”— API Communication

The frontend communicates with the PetAd backend API for all operations, including:

  • User authentication
  • Pet listings and details
  • Adoption applications
  • Custody requests
  • Document uploads

Security:

  • The frontend never holds private keys
  • All blockchain transactions are processed server-side
  • Authentication tokens are stored securely (HttpOnly cookies)

Example API Call:

import { useQuery } from '@tanstack/react-query';
import { petService } from '@/api/petService';

export function usePets() {
  return useQuery({
    queryKey: ['pets'],
    queryFn: () => petService.getAll(),
    staleTime: 5 * 60 * 1000, // 5 minutes
  });
}

🎨 Design Reference

This project follows a comprehensive design system documented in Figma. Please refer to the design files when implementing new features or components to ensure consistency.

πŸ“ Figma Design File: PetAd Design System

The design includes:

  • 🎨 Complete UI component library
  • πŸ“± Responsive layouts for mobile, tablet, and desktop
  • 🌈 Color palette and typography specifications
  • πŸ”„ User flow diagrams for adoption and custody workflows
  • β™Ώ Accessibility guidelines

Note for Developers: Always check the Figma design before building new components. Maintain pixel-perfect implementations where possible, and consult with the design team for any deviations.


🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Before submitting:

  • fix any issues
  • Ensure npm run type-check passes
  • Add tests for new features
  • Update documentation if needed

πŸ“„ License

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


πŸ™ Acknowledgments

  • Built with ❀️ for pet lovers everywhere
  • Powered by blockchain technology for transparent, trustworthy pet adoption

Made with 🐾 by the PetAd Team

About

A platform for pet adoption and temporary pet custody with blockchain-backed trust guarantees.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages