Skip to content

Chanu6173/Collage_assgn_React-Native

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FoodOrder - Full-Stack Food Ordering App

A complete Zomato-like food ordering application built with React + Vite for web and React Native for mobile, demonstrating modern React concepts and best practices. Home Page output

πŸ“ Project Structure

otamoz/
β”œβ”€β”€ web/              # React + Vite web application
β”œβ”€β”€ mobile/           # React Native mobile application
└── api/              # Mock JSON server API
add to card Page OrderTrack  successfull

πŸš€ Features

Web Application (React + Vite)

  • βœ… Login Page - Form validation, controlled inputs, error handling
  • βœ… Home Page - Food item listing with search and filters
  • βœ… Item Details - Product details with add-to-cart functionality
  • βœ… Cart Page - Shopping cart with quantity management
  • βœ… Order Tracking - Real-time order status updates
  • βœ… Profile Page - User information and preferences

Mobile Application (React Native)

  • βœ… Login Screen - Native mobile login experience
  • βœ… Home Screen - Food item browsing
  • βœ… Cart Screen - Shopping cart management
  • βœ… Profile Screen - User profile and settings
  • Profile page

πŸ› οΈ Tech Stack

Web

  • React 18.2.0
  • Vite 5.0.8
  • React Router DOM 6.20.0
  • React Hooks (useState, useEffect, useMemo, useCallback)

Mobile

  • React Native 0.72.6
  • Expo ~49.0.0
  • React Navigation 6.x
  • AsyncStorage for persistence

API

  • JSON Server for mock API
  • CORS enabled
Server

πŸ“¦ Installation & Setup

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • For mobile: Expo CLI (npm install -g expo-cli)

1. Install Web Dependencies

cd web
npm install

2. Install API Dependencies

cd api
npm install

3. Install Mobile Dependencies

cd mobile
npm install

🎯 Running the Application

Start the Mock API Server

cd api
npm start

The API server will run on http://localhost:3001

Start the Web Application

cd web
npm run dev

The web app will be available at http://localhost:3000

Start the Mobile Application

cd mobile
npm start

Then:

  • Press i for iOS simulator
  • Press a for Android emulator
  • Scan QR code with Expo Go app on your phone

🎨 Key React Concepts Demonstrated

1. Component Architecture

  • Reusable components (ItemCard, InfoCard, etc.)
  • Separation of concerns
  • Props passing and composition

2. State Management

  • Context API for global state (Auth, Cart)
  • Local state with useState
  • Derived state with useMemo

3. Side Effects

  • useEffect for data fetching
  • Cleanup functions for intervals/timeouts
  • Dependency arrays for optimization

4. Performance Optimization

  • Lazy loading with React.lazy()
  • Code splitting with dynamic imports
  • useMemo for expensive calculations
  • useCallback for function memoization
  • Suspense for loading states

5. Routing

  • React Router for web navigation
  • React Navigation for mobile
  • Protected routes
  • Lazy-loaded routes

6. Form Handling

  • Controlled components
  • Form validation
  • Error state management
  • Event handling (onChange, onSubmit)

7. Conditional Rendering

  • Dynamic UI based on state
  • Error messages
  • Loading states
  • Empty states

πŸ“± Mobile App Features

  • Bottom tab navigation
  • Native mobile UI components
  • AsyncStorage for data persistence
  • Shared business logic with web app

πŸ”§ Advanced Features

Lazy Loading

Pages are lazy-loaded using React.lazy() and Suspense:

  • Login
  • Home
  • ItemDetails
  • Cart
  • OrderTracking
  • Profile

State Batching

React 18 automatically batches state updates for better performance.

Side Effect Cleanup

Order tracking page properly cleans up intervals when unmounting.

Performance Optimizations

  • Memoized calculations (total, itemCount)
  • Memoized callbacks (addToCart, updateQuantity)
  • Filtered items memoization
add to card Page

πŸ“ API Endpoints

The mock API provides:

  • GET /api/items - Get all food items
  • GET /api/items/:id - Get single item details

πŸŽ“ Learning Points

  1. When to use lazy loading: Top-level routes that are code-split
  2. When NOT to lazy load: Small components, frequently used components
  3. State management: Context API for global state, useState for local
  4. Performance: useMemo for expensive calculations, useCallback for functions passed as props
  5. Cleanup: Always cleanup side effects in useEffect return function

🚧 Future Enhancements

  • Real backend API integration
  • Payment gateway integration
  • Push notifications
  • Real-time order tracking
  • Restaurant selection
  • User reviews and ratings
  • Order history

πŸ“„ License

This project is for educational purposes.

πŸ‘¨β€πŸ’» Development Notes

  • All components are well-commented
  • Code follows React best practices
  • Responsive design for web
  • Native mobile UI patterns
  • Clean folder structure
  • Reusable component architecture

Happy Coding! πŸ”πŸ•πŸŸ

Chanu

About

Food Delivery App

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors