diff --git a/README-DATABASE.md b/README-DATABASE.md deleted file mode 100644 index ecb8b43..0000000 --- a/README-DATABASE.md +++ /dev/null @@ -1,228 +0,0 @@ -# 🗄️ Portfolio Database Setup - -Dieses Portfolio verwendet **PostgreSQL mit Prisma ORM** für maximale Performance und Skalierbarkeit. - -## 🚀 Warum PostgreSQL + Prisma? - -- **🏃‍♂️ Hohe Performance**: Kann tausende User gleichzeitig bedienen -- **📈 Einfache Skalierung**: Von lokal zu Cloud ohne Code-Änderungen -- **🔧 TypeScript-First**: Vollständige Type-Sicherheit und Auto-completion -- **💾 Robuste Datenbank**: ACID, Transaktionen, Indizes für optimale Performance -- **🔄 Einfache Migration**: Einfache Updates und Schema-Änderungen - -## 📋 Voraussetzungen - -- Node.js 18+ -- npm oder yarn -- PostgreSQL (wird automatisch installiert) - -## 🛠️ Schnellstart (Automatisch) - -```bash -# 1. Repository klonen -git clone -cd my_portfolio - -# 2. Automatische Datenbank-Einrichtung -npm run db:setup -``` - -Das Skript installiert automatisch: -- ✅ PostgreSQL -- ✅ Datenbank und Benutzer -- ✅ Prisma Client -- ✅ Beispieldaten -- ✅ Umgebungsvariablen - -## 🔧 Manuelle Einrichtung - -### 1. PostgreSQL installieren - -**Ubuntu/Debian:** -```bash -sudo apt-get update -sudo apt-get install postgresql postgresql-contrib -``` - -**macOS:** -```bash -brew install postgresql -brew services start postgresql -``` - -**Windows:** -- [PostgreSQL Download](https://www.postgresql.org/download/windows/) - -### 2. Datenbank einrichten - -```bash -# PostgreSQL starten -sudo systemctl start postgresql # Linux -brew services start postgresql # macOS - -# Datenbank und Benutzer erstellen -sudo -u postgres psql -CREATE DATABASE portfolio_db; -CREATE USER portfolio_user WITH PASSWORD 'portfolio_pass'; -GRANT ALL PRIVILEGES ON DATABASE portfolio_db TO portfolio_user; -ALTER USER portfolio_user WITH SUPERUSER; -\q -``` - -### 3. Umgebungsvariablen - -Erstelle `.env.local`: -```env -DATABASE_URL="postgresql://portfolio_user:portfolio_pass@localhost:5432/portfolio_db?schema=public" -NEXTAUTH_SECRET="your-secret-key-here" -NEXTAUTH_URL="http://localhost:3000" -``` - -### 4. Dependencies installieren - -```bash -npm install -npx prisma generate -npx prisma db push -npx prisma db seed -``` - -## 🎯 Verfügbare Befehle - -```bash -# Datenbank verwalten -npm run db:setup # Vollständige Einrichtung -npm run db:generate # Prisma Client generieren -npm run db:push # Schema zur Datenbank pushen -npm run db:seed # Beispieldaten einfügen -npm run db:studio # Datenbank-Interface öffnen -npm run db:reset # Datenbank zurücksetzen - -# Entwicklung -npm run dev # Entwicklungsserver starten -npm run build # Produktions-Build -npm run start # Produktions-Server starten -``` - -## 🗄️ Datenbank-Schema - -### Projects -- **Basis**: Titel, Beschreibung, Inhalt, Tags -- **Metadaten**: Kategorie, Schwierigkeit, Datum -- **Performance**: Lighthouse Score, Bundle Size, Load Time -- **Analytics**: Views, Likes, Shares -- **Erweiterte Features**: Technologien, Herausforderungen, Lektionen - -### Analytics -- **PageViews**: Seitenaufrufe mit IP und User-Agent -- **UserInteractions**: Likes, Shares, Bookmarks, Kommentare - -## 📊 Performance-Features - -- **Indizes** auf allen wichtigen Feldern -- **Pagination** für große Datenmengen -- **Caching** für häufige Abfragen -- **Optimierte Queries** mit Prisma -- **Real-time Updates** möglich - -## 🔄 Migration & Updates - -```bash -# Schema ändern -npx prisma db push - -# Bei Breaking Changes -npx prisma migrate dev --name update_schema - -# Produktion -npx prisma migrate deploy -``` - -## 🌐 Deployment - -### Lokal zu Cloud Migration - -1. **Datenbank exportieren:** -```bash -pg_dump portfolio_db > backup.sql -``` - -2. **Cloud-Datenbank einrichten** (z.B. Supabase, PlanetScale, AWS RDS) - -3. **Umgebungsvariablen aktualisieren:** -```env -DATABASE_URL="postgresql://user:pass@host:5432/db?schema=public" -``` - -4. **Schema pushen:** -```bash -npx prisma db push -``` - -## 🚨 Troubleshooting - -### PostgreSQL startet nicht -```bash -# Linux -sudo systemctl status postgresql -sudo systemctl start postgresql - -# macOS -brew services list -brew services restart postgresql -``` - -### Verbindungsfehler -```bash -# PostgreSQL Status prüfen -sudo -u postgres psql -c "SELECT version();" - -# Verbindung testen -psql -h localhost -U portfolio_user -d portfolio_db -``` - -### Prisma Fehler -```bash -# Client neu generieren -npx prisma generate - -# Datenbank zurücksetzen -npx prisma db push --force-reset -``` - -## 📈 Monitoring & Wartung - -### Datenbank-Status -```bash -# Größe prüfen -psql -U portfolio_user -d portfolio_db -c "SELECT pg_size_pretty(pg_database_size('portfolio_db'));" - -# Performance-Statistiken -psql -U portfolio_user -d portfolio_db -c "SELECT * FROM pg_stat_database;" -``` - -### Backup & Restore -```bash -# Backup erstellen -pg_dump -U portfolio_user portfolio_db > backup_$(date +%Y%m%d).sql - -# Backup wiederherstellen -psql -U portfolio_user -d portfolio_db < backup_20241201.sql -``` - -## 🎉 Nächste Schritte - -1. **Datenbank starten**: `npm run db:setup` -2. **Entwicklungsserver starten**: `npm run dev` -3. **Admin-Bereich öffnen**: http://localhost:3000/admin -4. **Projekte verwalten** und dein Portfolio erweitern! - -## 📚 Weitere Ressourcen - -- [Prisma Dokumentation](https://www.prisma.io/docs) -- [PostgreSQL Dokumentation](https://www.postgresql.org/docs/) -- [Next.js API Routes](https://nextjs.org/docs/api-routes/introduction) - ---- - -**Fragen oder Probleme?** Erstelle ein Issue oder kontaktiere mich! 🚀