feat: Initiale Furt API-Gateway Projektstruktur
- Go-Projektstruktur nach Low-Tech-Prinzipien - Issue-Templates für Service-Requests und Bug-Reports - Konfiguration für sichere Entwicklung (.env.example) - Scripts-Verzeichnis für Build und Deployment - Dokumentationsstruktur für Dev und User Docs - Apache 2.0 Lizenz für Open-Source-Entwicklung Furt (Durchgang) vereint Services unter einheitlicher API für vollständige digitale Souveränität.
This commit is contained in:
parent
80e27a773b
commit
f4e8a40cdf
9 changed files with 796 additions and 1 deletions
516
furt_setup_repo.sh
Executable file
516
furt_setup_repo.sh
Executable file
|
|
@ -0,0 +1,516 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Load environment variables
|
||||
if [ -f .env ]; then
|
||||
export $(cat .env | grep -v '^#' | xargs)
|
||||
else
|
||||
echo "❌ .env file not found!"
|
||||
echo "📋 Copy .env.example to .env and configure it first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate required variables
|
||||
if [ -z "$GITEA_URL" ] || [ -z "$REPO_OWNER" ] || [ -z "$REPO_NAME" ] || [ -z "$GITEA_TOKEN" ]; then
|
||||
echo "❌ Missing required environment variables in .env"
|
||||
echo "📋 Check .env.example for required variables"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
|
||||
log_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
# Check repo
|
||||
check_repo() {
|
||||
if [ ! -d ".git" ]; then
|
||||
log_error "Not in a Git repository!"
|
||||
exit 1
|
||||
fi
|
||||
log_success "Repository check passed"
|
||||
}
|
||||
|
||||
# Create directory structure for API Gateway project
|
||||
create_directory_structure() {
|
||||
log_info "Creating Furt API Gateway directory structure..."
|
||||
|
||||
# Core Go project structure
|
||||
mkdir -p cmd/{furt-gateway,services/{formular2mail,sagjan}}
|
||||
mkdir -p internal/{gateway,services/{formular2mail,sagjan},shared/{auth,config,logging}}
|
||||
mkdir -p pkg/client
|
||||
|
||||
# Configuration and deployment
|
||||
mkdir -p configs/{services,examples}
|
||||
mkdir -p scripts/{build,deploy,development}
|
||||
mkdir -p tools/service-generator
|
||||
|
||||
# Documentation
|
||||
mkdir -p docs/{api,installation,services}
|
||||
mkdir -p devdocs
|
||||
mkdir -p examples/{hugo,nginx,apache,docker}
|
||||
|
||||
# Testing
|
||||
mkdir -p tests/{unit,integration,e2e}
|
||||
|
||||
# Gitea specific
|
||||
mkdir -p .gitea/{issue_template,workflows}
|
||||
|
||||
log_success "Furt directory structure created"
|
||||
}
|
||||
|
||||
# Create issue templates for API project
|
||||
create_issue_templates() {
|
||||
log_info "Creating Furt-specific issue templates..."
|
||||
|
||||
# Service Request Template
|
||||
cat > .gitea/issue_template/service_request.yml << 'TEMPLATE_EOF'
|
||||
name: 🔧 Neuer Service für API-Gateway
|
||||
description: Anfrage für einen neuen Service im Furt-Gateway
|
||||
title: "[SERVICE] "
|
||||
labels: ["service-request", "enhancement"]
|
||||
body:
|
||||
- type: input
|
||||
id: service_name
|
||||
attributes:
|
||||
label: "🏷️ Service-Name"
|
||||
description: "Wie soll der neue Service heißen?"
|
||||
placeholder: "z.B. newsletter, shop, calendar"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: service_description
|
||||
attributes:
|
||||
label: "📝 Service-Beschreibung"
|
||||
description: "Was soll der Service tun?"
|
||||
placeholder: "Detaillierte Beschreibung der gewünschten Funktionalität"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: service_port
|
||||
attributes:
|
||||
label: "🔌 Gewünschter Port"
|
||||
description: "Auf welchem Port soll der Service laufen?"
|
||||
placeholder: "z.B. 8083, 8084"
|
||||
|
||||
- type: dropdown
|
||||
id: priority
|
||||
attributes:
|
||||
label: "⚡ Priorität"
|
||||
description: "Wie dringend wird der Service benötigt?"
|
||||
options:
|
||||
- "🔥 Hoch - wird sofort benötigt"
|
||||
- "📊 Mittel - geplante Entwicklung"
|
||||
- "📝 Niedrig - nice to have"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: checkboxes
|
||||
id: integration_needs
|
||||
attributes:
|
||||
label: "🔗 Integration-Anforderungen"
|
||||
description: "Welche Integrationen werden benötigt?"
|
||||
options:
|
||||
- label: "Hugo-Shortcode"
|
||||
- label: "OpenAPI-Dokumentation"
|
||||
- label: "Admin-Interface"
|
||||
- label: "E-Mail-Benachrichtigungen"
|
||||
- label: "Datenbank-Speicherung"
|
||||
TEMPLATE_EOF
|
||||
|
||||
# Bug Report Template
|
||||
cat > .gitea/issue_template/bug_report.yml << 'TEMPLATE_EOF'
|
||||
name: 🐛 Bug Report
|
||||
description: Problem mit Gateway oder Service melden
|
||||
title: "[BUG] "
|
||||
labels: ["bug"]
|
||||
body:
|
||||
- type: dropdown
|
||||
id: component
|
||||
attributes:
|
||||
label: "🎯 Betroffene Komponente"
|
||||
description: "Welcher Teil des Systems ist betroffen?"
|
||||
options:
|
||||
- "Gateway (Routing, Auth, etc.)"
|
||||
- "Service: formular2mail"
|
||||
- "Service: sagjan"
|
||||
- "Konfiguration"
|
||||
- "Deployment/Scripts"
|
||||
- "Dokumentation"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: bug_description
|
||||
attributes:
|
||||
label: "📝 Bug-Beschreibung"
|
||||
description: "Was ist das Problem?"
|
||||
placeholder: "Detaillierte Beschreibung des Bugs"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: steps_to_reproduce
|
||||
attributes:
|
||||
label: "🔄 Schritte zur Reproduktion"
|
||||
description: "Wie kann der Bug reproduziert werden?"
|
||||
placeholder: |
|
||||
1. Gehe zu ...
|
||||
2. Klicke auf ...
|
||||
3. Führe aus ...
|
||||
4. Fehler tritt auf
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: expected_behavior
|
||||
attributes:
|
||||
label: "✅ Erwartetes Verhalten"
|
||||
description: "Was sollte stattdessen passieren?"
|
||||
validations:
|
||||
required: true
|
||||
TEMPLATE_EOF
|
||||
|
||||
# Architecture Discussion Template
|
||||
cat > .gitea/issue_template/architecture.yml << 'TEMPLATE_EOF'
|
||||
name: 🏗️ Architektur-Diskussion
|
||||
description: Diskussion über technische Entscheidungen und Architektur
|
||||
title: "[ARCH] "
|
||||
labels: ["architecture", "discussion"]
|
||||
body:
|
||||
- type: input
|
||||
id: topic
|
||||
attributes:
|
||||
label: "🎯 Thema"
|
||||
description: "Welcher Architektur-Aspekt soll diskutiert werden?"
|
||||
placeholder: "z.B. Service-Discovery, Auth-Strategy, Database-Choice"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: current_situation
|
||||
attributes:
|
||||
label: "📊 Aktuelle Situation"
|
||||
description: "Wie ist es momentan gelöst?"
|
||||
|
||||
- type: textarea
|
||||
id: proposed_change
|
||||
attributes:
|
||||
label: "💡 Vorgeschlagene Änderung"
|
||||
description: "Was soll geändert/diskutiert werden?"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: "🔄 Alternativen"
|
||||
description: "Welche anderen Ansätze gibt es?"
|
||||
|
||||
- type: checkboxes
|
||||
id: impact_areas
|
||||
attributes:
|
||||
label: "📈 Betroffene Bereiche"
|
||||
description: "Welche Teile des Systems sind betroffen?"
|
||||
options:
|
||||
- label: "Gateway-Performance"
|
||||
- label: "Service-Integration"
|
||||
- label: "Sicherheit"
|
||||
- label: "Skalierbarkeit"
|
||||
- label: "Wartbarkeit"
|
||||
- label: "Deployment"
|
||||
TEMPLATE_EOF
|
||||
|
||||
log_success "Furt issue templates created"
|
||||
}
|
||||
|
||||
# Create labels for API Gateway project
|
||||
create_labels() {
|
||||
log_info "Creating Furt-specific labels via Gitea API..."
|
||||
|
||||
declare -a labels=(
|
||||
"gateway,0052CC,API-Gateway Kern-Funktionalität"
|
||||
"service-formular2mail,2188FF,Formular-zu-E-Mail Service"
|
||||
"service-sagjan,34D058,Sagjan Kommentarsystem Integration"
|
||||
"service-request,0E8A16,Anfrage für neuen Service"
|
||||
"architecture,6F42C1,Architektur und Design-Entscheidungen"
|
||||
"security,D73A49,Sicherheit und Authentifizierung"
|
||||
"performance,F66A0A,Performance und Optimierung"
|
||||
"documentation,D1D5DA,Dokumentation schreiben/verbessern"
|
||||
"testing,28A745,Tests und Qualitätssicherung"
|
||||
"deployment,FBCA04,Build, Deploy und DevOps"
|
||||
"configuration,008672,Konfiguration und Setup"
|
||||
"bug,DC143C,Fehler und Probleme"
|
||||
"enhancement,32CD32,Verbesserung oder neue Funktion"
|
||||
"question,87CEEB,Frage oder Hilfe benötigt"
|
||||
"help-wanted,FF69B4,Community-Input erwünscht"
|
||||
"good-first-issue,98FB98,Gut für neue Mitwirkende"
|
||||
"breaking-change,FF4500,Breaking Change - Version Bump nötig"
|
||||
"low-tech,8B4513,Im Einklang mit Low-Tech-Prinzipien"
|
||||
"digital-sovereignty,4B0082,Fördert digitale Souveränität"
|
||||
)
|
||||
|
||||
for label_data in "${labels[@]}"; do
|
||||
IFS=',' read -r name color description <<< "$label_data"
|
||||
|
||||
response=$(curl -s -w "\n%{http_code}" -X POST \
|
||||
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/labels" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"name\": \"$name\",
|
||||
\"color\": \"$color\",
|
||||
\"description\": \"$description\"
|
||||
}")
|
||||
|
||||
http_code=$(echo "$response" | tail -n1)
|
||||
if [ "$http_code" = "201" ]; then
|
||||
log_success "Label '$name' created"
|
||||
elif [ "$http_code" = "409" ]; then
|
||||
log_warning "Label '$name' already exists"
|
||||
else
|
||||
log_error "Failed to create label '$name' (HTTP: $http_code)"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Create .env.example for API project
|
||||
create_env_example() {
|
||||
log_info "Creating .env.example for Furt..."
|
||||
|
||||
cat > .env.example << 'ENV_EOF'
|
||||
# Gitea-Konfiguration für Issue-Management
|
||||
GITEA_URL=https://your-gitea-instance.com
|
||||
REPO_OWNER=your-username
|
||||
REPO_NAME=furt
|
||||
GITEA_TOKEN=your-gitea-token-here
|
||||
|
||||
# Optional: Default-Assignee für Issues
|
||||
DEFAULT_ASSIGNEE=your-username
|
||||
|
||||
# Gateway-Konfiguration (für Entwicklung)
|
||||
GATEWAY_PORT=8080
|
||||
GATEWAY_LOG_LEVEL=info
|
||||
|
||||
# Service-Ports (für lokale Entwicklung)
|
||||
FORMULAR2MAIL_PORT=8081
|
||||
SAGJAN_PORT=8082
|
||||
|
||||
# SMTP-Konfiguration (für formular2mail)
|
||||
SMTP_HOST=localhost
|
||||
SMTP_PORT=25
|
||||
SMTP_FROM=no-reply@dragons-at-work.de
|
||||
SMTP_TO=admin@dragons-at-work.de
|
||||
|
||||
# API-Schlüssel (generiere sichere Schlüssel für Produktion!)
|
||||
HUGO_API_KEY=change-me-in-production
|
||||
ADMIN_API_KEY=change-me-in-production
|
||||
ENV_EOF
|
||||
|
||||
log_success ".env.example created"
|
||||
}
|
||||
|
||||
# Update .gitignore for Go project
|
||||
update_gitignore() {
|
||||
log_info "Creating Go-specific .gitignore..."
|
||||
|
||||
cat > .gitignore << 'GITIGNORE_EOF'
|
||||
# Environment variables (NEVER commit!)
|
||||
.env
|
||||
|
||||
# Go build artifacts
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
furt-gateway
|
||||
formular2mail-service
|
||||
sagjan-service
|
||||
/build/
|
||||
/dist/
|
||||
|
||||
# Go test files
|
||||
*.test
|
||||
*.out
|
||||
coverage.txt
|
||||
coverage.html
|
||||
|
||||
# Go modules
|
||||
/vendor/
|
||||
|
||||
# OS generated files
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
# Editor files
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
*.temp
|
||||
*.log
|
||||
|
||||
# Development files
|
||||
_personal/
|
||||
_drafts/
|
||||
_notes/
|
||||
debug.log
|
||||
|
||||
# Database files (for testing)
|
||||
*.db
|
||||
*.sqlite
|
||||
*.sqlite3
|
||||
|
||||
# Configuration files with secrets
|
||||
config.local.yaml
|
||||
config.production.yaml
|
||||
GITIGNORE_EOF
|
||||
|
||||
log_success ".gitignore updated for Go project"
|
||||
}
|
||||
|
||||
# Create initial Go module
|
||||
create_go_module() {
|
||||
log_info "Initializing Go module..."
|
||||
|
||||
if [ ! -f "go.mod" ]; then
|
||||
go mod init furt
|
||||
log_success "Go module initialized"
|
||||
else
|
||||
log_warning "go.mod already exists"
|
||||
fi
|
||||
}
|
||||
|
||||
# Create basic project files
|
||||
create_basic_files() {
|
||||
log_info "Creating basic project files..."
|
||||
|
||||
# README.md
|
||||
cat > README.md << 'README_EOF'
|
||||
# Furt API Gateway
|
||||
|
||||
Ein Low-Tech API-Gateway für selbst-gehostete Services im Einklang mit digitaler Souveränität.
|
||||
|
||||
## Überblick
|
||||
|
||||
Furt ist ein minimalistischer API-Gateway, der verschiedene Services unter einer einheitlichen API vereint. Der Name "Furt" (germanisch für "Durchgang durch Wasser") symbolisiert die Gateway-Funktion: Alle Requests durchqueren die API-Furt um zu den dahinterliegenden Services zu gelangen.
|
||||
|
||||
## Philosophie
|
||||
|
||||
- **Low-Tech-Ansatz**: Einfachheit vor Komplexität
|
||||
- **Digitale Souveränität**: Vollständige Kontrolle über die eigene Infrastruktur
|
||||
- **Native Deployment**: Go-Binaries ohne externe Abhängigkeiten
|
||||
- **Ressourcenschonend**: Minimaler Speicher- und CPU-Verbrauch
|
||||
- **Open Source**: Transparent und gemeinschaftlich entwickelt
|
||||
|
||||
## Status
|
||||
|
||||
🚧 **In Entwicklung** - Grundgerüst wird implementiert
|
||||
|
||||
## Geplante Services
|
||||
|
||||
- **formular2mail**: Kontaktformulare zu E-Mail weiterleiten
|
||||
- **sagjan**: Selbst-gehostetes Kommentarsystem
|
||||
- **Weitere**: Shop, Newsletter, Terminbuchung, etc.
|
||||
|
||||
## Installation
|
||||
|
||||
*Dokumentation folgt mit erstem Release*
|
||||
|
||||
## Entwicklung
|
||||
|
||||
Siehe `devdocs/` für Entwicklungsrichtlinien und Architektur-Dokumentation.
|
||||
|
||||
## Lizenz
|
||||
|
||||
Apache License 2.0 - Siehe [LICENSE](LICENSE) für Details.
|
||||
README_EOF
|
||||
|
||||
# LICENSE
|
||||
cat > LICENSE << 'LICENSE_EOF'
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
[Complete Apache 2.0 license text would go here]
|
||||
LICENSE_EOF
|
||||
|
||||
log_success "Basic project files created"
|
||||
}
|
||||
|
||||
# Git commit and push
|
||||
commit_and_push() {
|
||||
log_info "Committing initial Furt structure..."
|
||||
|
||||
git add .
|
||||
git commit -m "feat: Initiale Furt API-Gateway Projektstruktur
|
||||
|
||||
- Go-Projektstruktur nach Low-Tech-Prinzipien
|
||||
- Issue-Templates für Service-Requests und Bug-Reports
|
||||
- Konfiguration für sichere Entwicklung (.env.example)
|
||||
- Scripts-Verzeichnis für Build und Deployment
|
||||
- Dokumentationsstruktur für Dev und User Docs
|
||||
- Apache 2.0 Lizenz für Open-Source-Entwicklung
|
||||
|
||||
Furt (Durchgang) vereint Services unter einheitlicher API
|
||||
für vollständige digitale Souveränität."
|
||||
|
||||
if git remote get-url origin > /dev/null 2>&1; then
|
||||
git push origin main
|
||||
log_success "Changes committed and pushed"
|
||||
else
|
||||
log_warning "No remote 'origin' configured - changes committed locally"
|
||||
fi
|
||||
}
|
||||
|
||||
# Main function
|
||||
main() {
|
||||
log_info "🚀 Starting Furt API Gateway repository setup"
|
||||
echo
|
||||
|
||||
check_repo
|
||||
create_directory_structure
|
||||
create_issue_templates
|
||||
create_env_example
|
||||
update_gitignore
|
||||
create_basic_files
|
||||
create_go_module
|
||||
commit_and_push
|
||||
create_labels
|
||||
|
||||
echo
|
||||
log_success "🎯 Furt repository setup complete!"
|
||||
echo
|
||||
echo "Next steps:"
|
||||
echo "1. Copy .env.example to .env and configure it"
|
||||
echo "2. Create devdocs/KONZEPT.md with project philosophy"
|
||||
echo "3. Implement Gateway basic structure in cmd/furt-gateway/"
|
||||
echo "4. Create first service: formular2mail"
|
||||
echo "5. Test with Hugo integration"
|
||||
echo
|
||||
log_info "Ready to build the Furt! 🌊"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue