React LogoRecipe Sharing Site

A Recipe Sharing Site is an online platform designed to allow users to share, discover, and manage culinary recipes. It acts as a community hub where food enthusiasts, home cooks, and professional chefs can upload their own recipes, browse creations from others, and organize their favorite dishes.

Core functionalities typically include:
1. User Authentication: Users can register, log in, and manage their profiles. This allows for personalized experiences, such as saving favorite recipes or viewing their own submissions.
2. Recipe Submission: A dedicated interface for users to submit new recipes. This usually involves fields for: Recipe Name, Description, Ingredients (often structured for quantity, unit, and item), Step-by-step Instructions, Preparation Time, Cooking Time, Cuisine Type, Categories (e.g., Vegetarian, Dessert, Main Course), Servings, and optional fields for photos/videos, nutritional information, and difficulty level.
3. Recipe Browsing and Search: Users can browse recipes by category, cuisine, or popularity. A robust search functionality allows searching by keywords (e.g., ingredient, recipe name), and advanced filters (e.g., dietary restrictions, cooking time).
4. Recipe Details View: A dedicated page for each recipe displaying all its information, including user-submitted photos, ingredients, instructions, and user reviews/comments.
5. User Interaction: Users can leave feedback, ratings, or tips on recipes, save recipes to their personal collection (favorites/bookmarks), and share recipes on social media or via email.
6. User Profiles: Each user typically has a profile page showcasing their submitted recipes, favorited recipes, and activity history.

Technical Considerations:
* Frontend: A modern, responsive user interface built with frameworks like React, Angular, or Vue.js is crucial for a smooth user experience. State management libraries (like Redux or Context API in React) often help manage complex application states.
* Backend: A robust API (e.g., built with Node.js/Express, Python/Django/Flask, Ruby on Rails) to handle user authentication, recipe data management (CRUD operations), search indexing, and potentially image/video upload processing.
* Database: A database (e.g., MongoDB for NoSQL, PostgreSQL/MySQL for SQL) to store user information, recipe details, comments, and other related data.
* Cloud Storage: For handling media files like recipe photos, cloud storage solutions (e.g., AWS S3, Google Cloud Storage, Cloudinary) are often used.

A recipe sharing site combines social networking features with practical utility, creating a valuable resource for cooking enthusiasts.

Example Code

import React, { useState } from 'react';

// This example assumes a basic 'App.css' file for styling.
// The content of a typical 'App.css' to make this example presentable is provided below:
/*
body {
  font-family: Arial, sans-serif;
  margin: 0;
  background-color: #f4f4f4;
  color: #333;
}

.app-container {
  max-width: 1200px;
  margin: 20px auto;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.app-header {
  background-color: #28a745;
  color: white;
  padding: 20px;
  text-align: center;
}

.app-main {
  display: flex;
  padding: 20px;
}

.sidebar {
  flex: 1;
  padding-right: 20px;
  border-right: 1px solid #eee;
}

.content {
  flex: 2;
  padding-left: 20px;
}

.recipe-form-container {
  margin-bottom: 20px;
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.recipe-form .form-group {
  margin-bottom: 15px;
}

.recipe-form label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}

.recipe-form input[type="text"],
.recipe-form textarea {
  width: calc(100% - 20px);
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

.recipe-form textarea {
  min-height: 80px;
  resize: vertical;
}

.recipe-form button {
  background-color: #007bff;
  color: white;
  padding: 10px 15px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}

.recipe-form button:hover {
  background-color: #0056b3;
}

.recipe-list h2 {
  margin-top: 0;
  color: #28a745;
}

.recipe-item {
  background-color: #fff;
  border: 1px solid #eee;
  border-radius: 5px;
  padding: 15px;
  margin-bottom: 15px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.recipe-item h3 {
  color: #333;
  margin-top: 0;
}

.recipe-item p {
  margin-bottom: 8px;
  line-height: 1.5;
}

.recipe-item small {
  color: #666;
}

.app-footer {
  background-color: #343a40;
  color: white;
  text-align: center;
  padding: 15px;
  font-size: 0.9rem;
}
*/

// --- RecipeItem Component ---
function RecipeItem({ recipe }) {
  return (
    <div className="recipe-item">
      <h3>{recipe.name}</h3>
      <p><strong>Ingredients:</strong> {recipe.ingredients}</p>
      <p><strong>Instructions:</strong> {recipe.instructions}</p>
      <p><small>Prep Time: {recipe.prepTime} | Cook Time: {recipe.cookTime}</small></p>
    </div>
  );
}

// --- RecipeList Component ---
function RecipeList({ recipes }) {
  return (
    <div className="recipe-list">
      <h2>All Recipes</h2>
      {recipes.length === 0 ? (
        <p>No recipes yet. Be the first to add one!</p>
      ) : (
        recipes.map((recipe, index) => (
          <RecipeItem key={index} recipe={recipe} />
        ))
      )}
    </div>
  );
}

// --- RecipeForm Component ---
function RecipeForm({ onAddRecipe }) {
  const [name, setName] = useState('');
  const [ingredients, setIngredients] = useState('');
  const [instructions, setInstructions] = useState('');
  const [prepTime, setPrepTime] = useState('');
  const [cookTime, setCookTime] = useState('');

  const handleSubmit = (e) => {
    e.preventDefault();
    if (!name || !ingredients || !instructions) {
      alert('Please fill in all required fields.');
      return;
    }
    onAddRecipe({ name, ingredients, instructions, prepTime, cookTime });
    // Clear form
    setName('');
    setIngredients('');
    setInstructions('');
    setPrepTime('');
    setCookTime('');
  };

  return (
    <div className="recipe-form-container">
      <h2>Add a New Recipe</h2>
      <form onSubmit={handleSubmit} className="recipe-form">
        <div className="form-group">
          <label htmlFor="name">Recipe Name:</label>
          <input
            type="text"
            id="name"
            value={name}
            onChange={(e) => setName(e.target.value)}
            required
          />
        </div>
        <div className="form-group">
          <label htmlFor="ingredients">Ingredients (comma-separated):</label>
          <textarea
            id="ingredients"
            value={ingredients}
            onChange={(e) => setIngredients(e.target.value)}
            required
          ></textarea>
        </div>
        <div className="form-group">
          <label htmlFor="instructions">Instructions:</label>
          <textarea
            id="instructions"
            value={instructions}
            onChange={(e) => setInstructions(e.target.value)}
            required
          ></textarea>
        </div>
        <div className="form-group">
          <label htmlFor="prepTime">Preparation Time:</label>
          <input
            type="text"
            id="prepTime"
            value={prepTime}
            onChange={(e) => setPrepTime(e.target.value)}
          />
        </div>
        <div className="form-group">
          <label htmlFor="cookTime">Cook Time:</label>
          <input
            type="text"
            id="cookTime"
            value={cookTime}
            onChange={(e) => setCookTime(e.target.value)}
          />
        </div>
        <button type="submit">Add Recipe</button>
      </form>
    </div>
  );
}

// --- Main App Component ---
function App() {
  const [recipes, setRecipes] = useState([
    {
      name: 'Classic Spaghetti Carbonara',
      ingredients: 'Spaghetti, Eggs, Pancetta/Guanciale, Pecorino Romano, Black Pepper',
      instructions: 'Cook pasta. Fry pancetta. Whisk eggs, cheese, pepper. Combine hot pasta with pancetta, then quickly add egg mixture, tossing to emulsify.',
      prepTime: '10 min',
      cookTime: '15 min'
    },
    {
      name: 'Simple Green Salad',
      ingredients: 'Mixed greens, Cherry tomatoes, Cucumber, Olive oil, Balsamic vinegar, Salt, Pepper',
      instructions: 'Wash and chop vegetables. Combine in a bowl. Drizzle with olive oil and balsamic vinegar. Season with salt and pepper. Toss gently.',
      prepTime: '5 min',
      cookTime: '0 min'
    }
  ]);

  const handleAddRecipe = (newRecipe) => {
    setRecipes([...recipes, newRecipe]);
  };

  return (
    <div className="app-container">
      <header className="app-header">
        <h1>My Recipe Sharing Hub</h1>
      </header>
      <main className="app-main">
        <div className="sidebar">
          <RecipeForm onAddRecipe={handleAddRecipe} />
        </div>
        <div className="content">
          <RecipeList recipes={recipes} />
        </div>
      </main>
      <footer className="app-footer">
        <p>© 2023 Recipe Sharing Hub</p>
      </footer>
    </div>
  );
}

export default App;