Skip to content

Elchamos64/BYUI_Pantry

Repository files navigation

BYUI Pantry

A community sharing platform where BYU-Idaho students can post items they no longer need and help fellow students by allowing them to claim items for free.

Features

  • User Authentication: Sign up, sign in, and manage your profile
  • Item Listings: Post, edit, and delete item listings
  • Search & Filter: Browse items by category and search keywords
  • Comments: Comment on listings and coordinate pickup
  • Pickup Scheduling: Propose and confirm pickup times
  • Status Management: Track items as available, pending, or claimed

Tech Stack

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • Database: MongoDB with Mongoose
  • Authentication: NextAuth.js
  • Validation: Zod
  • Notifications: React Hot Toast

Getting Started

Prerequisites

  • Node.js 18+ installed
  • MongoDB installed and running locally, or a MongoDB Atlas account

Installation

  1. Clone the repository:
git clone <repository-url>
cd BYUI_Pantry
  1. Install dependencies:
npm install
  1. Create a .env.local file in the root directory:
cp .env.local.example .env.local
  1. Update the .env.local file with your configuration:
MONGODB_URI=mongodb://localhost:27017/byui-pantry
NEXTAUTH_SECRET=your-secret-key-here
NEXTAUTH_URL=http://localhost:3000

To generate a secure NEXTAUTH_SECRET, run:

openssl rand -base64 32

Running the Application

Development mode:

npm run dev

Open http://localhost:3000 in your browser.

Building for Production

npm run build
npm start

Project Structure

BYUI_Pantry/
├── src/
│   ├── app/                    # Next.js app directory
│   │   ├── api/               # API routes
│   │   ├── auth/              # Authentication pages
│   │   ├── items/             # Item pages
│   │   ├── profile/           # Profile page
│   │   ├── layout.tsx         # Root layout
│   │   └── page.tsx           # Home page
│   ├── components/            # React components
│   ├── lib/                   # Utility functions
│   ├── models/                # Mongoose models
│   └── types/                 # TypeScript types
├── public/                    # Static files
└── package.json

API Routes

Authentication

  • POST /api/auth/signup - Create new user account
  • POST /api/auth/[...nextauth] - NextAuth endpoints

Items

  • GET /api/items - Get all items (with filters)
  • POST /api/items - Create new item
  • GET /api/items/[id] - Get single item
  • PUT /api/items/[id] - Update item
  • DELETE /api/items/[id] - Delete item
  • PATCH /api/items/[id]/status - Update item status

Comments

  • GET /api/comments?itemId=[id] - Get comments for item
  • POST /api/comments - Create comment
  • PUT /api/comments/[id] - Update comment
  • DELETE /api/comments/[id] - Delete comment

Users

  • GET /api/users/[id] - Get user profile
  • PUT /api/users/[id] - Update user profile

Usage

Posting an Item

  1. Sign in to your account
  2. Click "Post Item" in the navigation
  3. Fill out the item details (title, description, category, location)
  4. Submit the form

Claiming an Item

  1. Browse available items
  2. Click on an item to view details
  3. Leave a comment with a proposed pickup time
  4. Wait for the owner to confirm

Managing Your Items

  1. Go to your Profile page
  2. View all your posted items
  3. Update status or delete items as needed

Environment Variables

  • MONGODB_URI: MongoDB connection string
  • NEXTAUTH_SECRET: Secret key for NextAuth.js
  • NEXTAUTH_URL: Application URL

Contributing

This is a student project for BYU-Idaho. Feel free to fork and modify for your own use.

License

MIT License - feel free to use this project as a template for your own community sharing platform.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages