Erster commit wie von Claude erstellt (unverändert)
This commit is contained in:
151
README.md
Normal file
151
README.md
Normal file
@@ -0,0 +1,151 @@
|
||||
# Rezepte WebApp - Node.js/MongoDB Migration
|
||||
|
||||
Vollständige Migration der PHP/MySQL Rezepte-App zu Node.js/Express mit MongoDB.
|
||||
|
||||
## Stack
|
||||
|
||||
- **Backend**: Node.js 22 + Express.js
|
||||
- **Datenbank**: MongoDB 8
|
||||
- **Frontend**: Vanilla JavaScript, HTML, CSS
|
||||
- **Container**: Docker + Docker Compose
|
||||
|
||||
## Projektstruktur
|
||||
|
||||
```
|
||||
recipe-app/
|
||||
├── server/ # Backend
|
||||
│ ├── index.js # Express Server
|
||||
│ ├── db.js # MongoDB Connection
|
||||
│ ├── routes/ # API Routes
|
||||
│ └── middleware/ # Upload Middleware
|
||||
├── public/ # Frontend
|
||||
│ ├── *.html
|
||||
│ ├── css/
|
||||
│ └── js/
|
||||
├── uploads/ # Bilder (Volume)
|
||||
└── docker-compose.yml
|
||||
```
|
||||
|
||||
## Installation & Start
|
||||
|
||||
### Mit Docker (empfohlen)
|
||||
|
||||
```bash
|
||||
# Container bauen und starten
|
||||
docker-compose up -d
|
||||
|
||||
# Logs anzeigen
|
||||
docker-compose logs -f app
|
||||
|
||||
# Stoppen
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
App läuft auf: **http://localhost:3000**
|
||||
|
||||
### Lokal (ohne Docker)
|
||||
|
||||
```bash
|
||||
# MongoDB lokal installieren und starten
|
||||
|
||||
# Dependencies installieren
|
||||
cd server
|
||||
npm install
|
||||
|
||||
# Server starten
|
||||
npm start
|
||||
|
||||
# Entwicklungsmodus (mit Auto-Reload)
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## Daten migrieren
|
||||
|
||||
Wenn du deine bestehenden MySQL-Daten migrieren möchtest, erstelle ein Migrations-Script oder importiere die Daten manuell in MongoDB.
|
||||
|
||||
## MongoDB Schema
|
||||
|
||||
### Collection: `recipes`
|
||||
```javascript
|
||||
{
|
||||
_id: ObjectId,
|
||||
rezeptnummer: Number (unique),
|
||||
bezeichnung: String,
|
||||
beschreibung: String,
|
||||
kategorie: String,
|
||||
vorbereitung: String,
|
||||
anzahl: Number,
|
||||
zutaten: String,
|
||||
zubereitung: [
|
||||
{ schritt: Number, text: String }
|
||||
],
|
||||
kommentar: String,
|
||||
erstelltAm: Date,
|
||||
aktualisiertAm: Date
|
||||
}
|
||||
```
|
||||
|
||||
### Collection: `images`
|
||||
```javascript
|
||||
{
|
||||
_id: ObjectId,
|
||||
rezeptId: ObjectId (ref recipes),
|
||||
dateiPfad: String,
|
||||
dateiName: String,
|
||||
hochgeladenAm: Date
|
||||
}
|
||||
```
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### Rezepte
|
||||
- `GET /api/recipes` - Alle Rezepte (mit Suche & Sortierung)
|
||||
- `GET /api/recipes/:id` - Einzelnes Rezept
|
||||
- `POST /api/recipes` - Neues Rezept erstellen
|
||||
- `PUT /api/recipes/:id` - Rezept aktualisieren
|
||||
- `DELETE /api/recipes/:id` - Rezept löschen
|
||||
|
||||
### Bilder
|
||||
- `POST /api/images/:rezeptId` - Bild hochladen
|
||||
- `GET /api/images/recipe/:rezeptId` - Bilder eines Rezepts
|
||||
- `DELETE /api/images/:bildId` - Bild löschen
|
||||
|
||||
## Features
|
||||
|
||||
✅ Rezepte anzeigen, erstellen, bearbeiten, löschen
|
||||
✅ Volltextsuche
|
||||
✅ Sortierung nach Nummer, Name, Kategorie
|
||||
✅ Bilder hochladen (JPG, PNG)
|
||||
✅ Lightbox für Bildvergrößerung
|
||||
✅ Responsive Design
|
||||
✅ Docker-Ready
|
||||
|
||||
## Umgebungsvariablen
|
||||
|
||||
Erstelle eine `.env` Datei:
|
||||
|
||||
```
|
||||
PORT=3000
|
||||
NODE_ENV=production
|
||||
MONGODB_URI=mongodb://mongo:27017/recipes
|
||||
```
|
||||
|
||||
## Entwicklung
|
||||
|
||||
VSCode Extensions empfohlen:
|
||||
- ESLint
|
||||
- Prettier
|
||||
- MongoDB for VS Code
|
||||
|
||||
## Unterschiede zur PHP-Version
|
||||
|
||||
- **Datenbank**: MySQL → MongoDB (denormalisiert)
|
||||
- **Backend**: PHP → Node.js/Express
|
||||
- **Frontend**: Gleiche UI, aber mit Fetch API statt Forms
|
||||
- **Upload**: Multer statt move_uploaded_file
|
||||
- **Sessions**: Nicht mehr benötigt (Stateless API)
|
||||
|
||||
## Lizenz
|
||||
|
||||
Privat
|
||||
|
||||
Reference in New Issue
Block a user