# Freedge Freedge is a web application that generates personalized recipes based on the ingredients available in the user's fridge. The application is built on a modern fullstack architecture with a lightweight and fast backend, an integrated database, and a smooth user interface. ## Tech Stack - **Frontend**: React.js + TailwindCSS + ShadCN - **Backend**: Fastify + Prisma + SQLite - **AI**: ChatGPT API for recipe generation - **Payments**: Stripe (subscriptions) ## Project Structure ``` freedge/ ├── frontend/ # React frontend application │ ├── public/ # Static assets │ └── src/ # Source code │ ├── components/ # Reusable UI components │ ├── pages/ # Application pages │ ├── services/ # API service integrations │ └── utils/ # Utility functions │ ├── backend/ # Fastify API server │ ├── prisma/ # Prisma schema and migrations │ └── src/ # Source code │ ├── routes/ # API route definitions │ ├── controllers/ # Request handlers │ ├── services/ # Business logic │ └── models/ # Data models │ └── README.md # Project documentation ``` ## Getting Started ### Prerequisites - Node.js (v16+) - npm or yarn - SQLite ### Installation 1. Clone the repository ``` git clone https://github.com/yourusername/freedge.git cd freedge ``` 2. Install backend dependencies ``` cd backend npm install ``` 3. Set up environment variables - Create a `.env` file in the backend directory (or modify the existing one) - Add your OpenAI API key and Stripe keys 4. Set up the database ``` npx prisma migrate dev --name init npx prisma generate ``` 5. Install frontend dependencies ``` cd ../frontend npm install ``` 6. Start the development servers In the backend directory: ``` npm run dev ``` In the frontend directory: ``` npm run dev ``` 7. Open your browser and navigate to `http://localhost:5173` ## Features - User authentication with JWT - Ingredient management - AI-powered recipe generation - Subscription management with Stripe - Recipe history ## API Routes All routes are prefixed with `/api`. ### Authentication - `POST /auth/register` - Create a new user account - `POST /auth/login` - Login and get JWT token ### Profile Management - `GET /profile` - Get user profile - `PUT /profile` - Update user profile ### Ingredients - `GET /ingredients` - Get user's ingredients - `POST /ingredients` - Add a new ingredient - `DELETE /ingredients/:id` - Delete an ingredient ### Recipes - `POST /recipes/generate` - Generate a recipe based on ingredients - `GET /recipes/history` - Get recipe history - `GET /recipes/:id` - Get a specific recipe ### Subscriptions - `POST /subscriptions/create-checkout-session` - Create a Stripe checkout session - `GET /subscriptions/status` - Get subscription status ## License MIT