A Next.js application for tracking restaurant cooking oils and assessing peanut allergy risk. The app lets users submit restaurants with their oil type, then search with real-time filtering and risk badges to help make safer dining decisions.
- Features
- Tech Stack
- Project Structure
- Getting Started
- API Reference
- Scripts
- Deployment
- Roadmap
- Contributing
- License
- Add restaurants with the cooking oil type used.
- Real-time search with debounce and clear control.
- Risk assessment based on oil type (high/medium/low/unknown) with color-coded badges.
- MongoDB-backed persistence via Mongoose.
- Framework: Next.js (App Router)
- UI: React + Tailwind CSS
- Database: MongoDB + Mongoose
- Language: TypeScript (frontend) + JavaScript (API/routes)
app/
api/
restaurants/ # Create restaurant entries
restaurants/search/ # Search + risk assessment
page.tsx # UI: form + search experience
lib/
mongodb.js # MongoDB connection
riskAssessment.js # Risk scoring helpers
models/
Restaurant.js # Mongoose schema
- Node.js 18+ (recommended)
- MongoDB instance (local or cloud)
npm installCreate a .env.local file in the project root:
MONGODB_URI="mongodb+srv://<user>:<password>@<cluster>/<db>?retryWrites=true&w=majority"The application expects a MongoDB database named
restaurant-trackerby default. You can adjust this inlib/mongodb.js.
npm run devThen open http://localhost:3000 in your browser.
POST /api/restaurants
Request body:
{
"name": "Joe's Diner",
"oilType": "Canola"
}GET /api/restaurants/search?name=<query>
Returns restaurants sorted by most recent submission and includes a risk object for each entry.
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLintThe application can be deployed on any platform that supports Next.js (e.g., Vercel, Render, or a custom Node.js server). Ensure that MONGODB_URI is configured in your deployment environment.
- UI component library setup (shadcn/ui).
npx shadcn@latest initDocumentation: https://ui.shadcn.com/docs/installation/next
- Restaurant field validation
- Fork the repository.
- Create a feature branch:
git checkout -b feature/my-feature. - Commit your changes:
git commit -m "Add my feature". - Push to the branch:
git push origin feature/my-feature. - Open a pull request.
This project is licensed under the MIT License.