A small full-stack recipes app used as starter code for the AI implementation lesson. You can list recipes, view a recipe's details, and create new recipes by filling in a form.
- Client: React, React Router, Axios, Vite, TypeScript
- Server: Node.js, Express, Mongoose (MongoDB), TypeScript
.
├── client/ # React app (Vite)
│ ├── index.html
│ ├── vite.config.ts
│ └── src/
│ ├── main.tsx # Entry point, sets up BrowserRouter
│ ├── App.tsx # Routes
│ ├── components/ # Navbar
│ ├── pages/ # RecipeListPage, RecipeDetailsPage, RecipeCreatePage
│ ├── services/ # Axios instance (config.services.ts)
│ └── types/ # Shared TypeScript types (Recipe)
│
└── server/ # Express API
└── src/
├── server.ts # Starts the server
├── app.ts # Creates the Express app
├── config/ # Global middleware (CORS, logger, body parsers)
├── db/ # MongoDB connection
├── errors/ # 404 and error handlers
├── models/ # Recipe model
└── routes/ # API routes, mounted under /api
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/recipes |
List all recipes (title only) |
| GET | /api/recipes/:recipeId |
Get one recipe with all its details |
| POST | /api/recipes |
Create a recipe |
You need Node.js 24 or later and a running MongoDB instance.
cd server
npm installCreate a server/.env file based on server/.env.example:
PORT=5005
ORIGIN=http://localhost:5173
MONGODB_URI=mongodb://127.0.0.1:27017/recipes-db
Start the server in development mode:
npm run devIn a second terminal:
cd client
npm installCreate a client/.env file based on client/.env.example:
VITE_SERVER_URL=http://localhost:5005
Start the client:
npm run devOpen http://localhost:5173 in your browser.
| Folder | Command | What it does |
|---|---|---|
| server | npm run build |
Compiles TypeScript into dist/ |
| server | npm start |
Runs the compiled server from dist/ |
| client | npm run build |
Type-checks and builds the app into dist/ |
| client | npm run lint |
Runs ESLint |