chefbible/README.md
2025-12-03 14:14:32 -05:00

158 lines
4.3 KiB
Markdown

# Chef Bible
A self-hosted, mobile-friendly recipe and menu management tool designed for real-world kitchen use. Built with SvelteKit, TailwindCSS, and Prisma.
## Features
- **Recipe Management**: Store recipes with ingredients, instructions, and photos
- **Ingredient Tracking**: Manage ingredients with allergen information
- **Menu Planning**: Create menus from recipes with seasonal organization
- **Kitchen-Friendly UI**: Optimized for tablets and phones in kitchen environments
- **Authentication**: Simple magic link authentication for chefs
## Tech Stack
- **Frontend**: SvelteKit 2.0 with Svelte 5
- **Styling**: TailwindCSS 4.0 + DaisyUI
- **Database**: SQLite with Prisma ORM
- **Authentication**: Magic link system
- **Build Tool**: Vite
## Prerequisites
- Node.js 18+
- npm or yarn
## Quick Start
1. **Clone the repository**
```bash
git clone <repository-url>
cd chefbible
```
2. **Install dependencies**
```bash
npm install
```
3. **Set up environment variables**
Create a `.env` file in the root directory:
```env
# Database
DATABASE_URL="file:./prisma/database.db"
# Authentication (generate a secure random token for production)
MAGIC_LINK_TOKEN="your-secure-token-here"
# Environment
NODE_ENV="development"
```
4. **Set up the database**
```bash
# Generate Prisma client
npx prisma generate
# Run database migrations
npx prisma migrate dev
# Seed the database with sample data (optional)
npm run prisma:seed
```
5. **Start the development server**
```bash
npm run dev
```
6. **Access the application**
- Open [http://localhost:5173](http://localhost:5173)
- Use the magic link: `/chef-access?token=your-secure-token-here`
## Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
| `DATABASE_URL` | Database connection string | `file:./prisma/database.db` |
| `MAGIC_LINK_TOKEN` | Secret token for chef authentication | Required |
| `NODE_ENV` | Environment mode | `development` |
## Database Schema
The application uses the following main models:
- **Recipe**: Core recipe information with instructions and metadata
- **Ingredient**: Ingredients with allergen tracking
- **RecipeIngredient**: Junction table linking recipes to ingredients with quantities
- **Allergen**: Allergen information linked to ingredients
- **Menu**: Menu collections with seasonal organization
- **MenuRecipe**: Junction table for menu-recipe relationships
## Development
### Available Scripts
- `npm run dev` - Start development server
- `npm run build` - Build for production
- `npm run preview` - Preview production build
- `npm run check` - Type check and lint
- `npm run format` - Format code with Prettier
### Database Operations
- `npx prisma studio` - Open Prisma Studio for database management
- `npx prisma migrate dev` - Create and apply new migrations
- `npx prisma generate` - Generate Prisma client
- `npx prisma db seed` - Seed database with sample data
### Authentication
The app uses a simple magic link authentication system:
- Generate a secure token and set it in `MAGIC_LINK_TOKEN`
- Share the magic link: `/chef-access?token=your-token`
- Authentication lasts for 30 days via HTTP-only cookies
## Deployment
### Production Build
1. Build the application:
```bash
npm run build
```
2. The built application will be in the `build/` directory
3. Deploy using your preferred hosting platform (Vercel, Netlify, etc.)
### Environment Considerations
- Set `NODE_ENV=production` in production
- Use a strong, randomly generated `MAGIC_LINK_TOKEN`
- Consider using a production database (PostgreSQL, MySQL) instead of SQLite
- Update the Prisma schema datasource provider if switching databases
## Project Structure
```
src/
├── lib/
│ ├── components/ # Reusable UI components
│ ├── server/ # Server-side utilities
│ └── types/ # TypeScript type definitions
├── routes/ # SvelteKit route handlers
│ ├── chef-access/ # Authentication endpoint
│ ├── recipe/ # Recipe management routes
│ └── logout/ # Logout functionality
└── app.html # HTML template
```
## Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Run tests and linting: `npm run check`
5. Submit a pull request