Compare commits

...

17 Commits

24 changed files with 3663 additions and 22876 deletions

View File

@@ -16,12 +16,22 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
tag_name: ${{ steps.set_tag.outputs.tag_name }} tag_name: ${{ steps.set_tag.outputs.tag_name }}
is_main_branch: ${{ steps.branch_check.outputs.is_main }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 # Fetch all history for tags fetch-depth: 0 # Fetch all history for tags
- name: Check if main branch
id: branch_check
run: |
if [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == "refs/heads/master" ]]; then
echo "is_main_branch=true" >> $GITHUB_OUTPUT
else
echo "is_main_branch=false" >> $GITHUB_OUTPUT
fi
- name: Determine next semantic version tag - name: Determine next semantic version tag
id: set_tag id: set_tag
run: | run: |
@@ -65,14 +75,10 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: '20' node-version: '20'
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install backend dependencies - name: Install backend dependencies
working-directory: ./backend working-directory: ./backend
run: | run: npm install
# Try npm ci first, if it fails use npm install
npm ci || (echo "package-lock.json out of sync, using npm install..." && npm install)
- name: Run TypeScript check - name: Run TypeScript check
working-directory: ./backend working-directory: ./backend
@@ -139,6 +145,8 @@ jobs:
type=sha type=sha
# Add the dynamically generated semantic version # Add the dynamically generated semantic version
${{ needs.set-tag.outputs.tag_name }} ${{ needs.set-tag.outputs.tag_name }}
# Add latest tag for main branch
${{ needs.set-tag.outputs.is_main_branch == 'true' && 'latest' }}
- name: Build and push Docker image - name: Build and push Docker image
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
@@ -168,3 +176,4 @@ jobs:
echo "- Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" echo "- Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
echo "- Tags: ${{ steps.meta.outputs.tags }}" echo "- Tags: ${{ steps.meta.outputs.tags }}"
echo "- New version: ${{ needs.set-tag.outputs.tag_name }}" echo "- New version: ${{ needs.set-tag.outputs.tag_name }}"
echo "- Is main branch: ${{ needs.set-tag.outputs.is_main_branch }}"

21
.gitignore vendored
View File

@@ -115,3 +115,24 @@ Thumbs.db
premium/* premium/*
!premium/README-PREMIUM.md !premium/README-PREMIUM.md
!premium/.gitkeep !premium/.gitkeep
.git
.gitignore
node_modules
npm-debug.log
README.md
.env
.nyc_output
coverage
.cache
dist
build
logs
*.tsbuildinfo
# Frontend specific
frontend/dist
frontend/.vite
# Backend specific
backend/dist

View File

@@ -1,5 +1,5 @@
# Multi-stage build for combined frontend + backend # Single stage build for workspaces
FROM node:20-bullseye AS backend-builder FROM node:20-bullseye AS builder
WORKDIR /app WORKDIR /app
@@ -10,80 +10,55 @@ RUN apt-get update && apt-get install -y python3 python3-pip build-essential \
# Create symlink so python3 is callable as python # Create symlink so python3 is callable as python
RUN ln -sf /usr/bin/python3 /usr/bin/python RUN ln -sf /usr/bin/python3 /usr/bin/python
# Copy ALL package files (root + backend) # Copy root package files first
COPY package*.json ./ COPY package*.json ./
COPY backend/package.json ./backend/ COPY tsconfig.base.json ./
COPY ecosystem.config.cjs ./
# Install dependencies using workspaces # Install root dependencies
RUN npm ci --workspace=backend RUN npm install
# Copy backend source # Copy workspace files
COPY backend/src/ ./backend/src/ COPY backend/ ./backend/
COPY backend/tsconfig.json ./backend/ COPY frontend/ ./frontend/
# Build backend # Install workspace dependencies individually
RUN npm install --workspace=backend
RUN npm install --workspace=frontend
# Build backend first
RUN npm run build --workspace=backend RUN npm run build --workspace=backend
# Copy database files manually
RUN cp -r backend/src/database/ backend/dist/database/
# Verify Python and OR-Tools installation
RUN python -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
# Frontend build stage
FROM node:20-bullseye AS frontend-builder
WORKDIR /app
# Copy ALL package files (root + frontend)
COPY package*.json ./
COPY frontend/package.json ./frontend/
# Install dependencies using workspaces
RUN npm ci --workspace=frontend
# Copy frontend source
COPY frontend/src/ ./frontend/src/
COPY frontend/public/ ./frontend/public/
COPY frontend/tsconfig.json ./frontend/
# Build frontend # Build frontend
RUN npm run build --workspace=frontend RUN npm run build --workspace=frontend
# Production stage # Verify Python and OR-Tools installation
RUN python -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
# Production stage (same as above)
FROM node:20-bookworm FROM node:20-bookworm
WORKDIR /app WORKDIR /app
# Install PM2 for process management
RUN npm install -g pm2 RUN npm install -g pm2
# Create data directory for SQLite database with proper permissions
RUN mkdir -p /app/data RUN mkdir -p /app/data
COPY --from=builder /app/backend/dist/ ./dist/
COPY --from=builder /app/backend/package*.json ./
# Copy backend built files COPY --from=builder /app/node_modules/ ./node_modules/
COPY --from=backend-builder /app/backend/dist/ ./dist/ COPY --from=builder /app/frontend/dist/ ./frontend-build/
COPY --from=backend-builder /app/backend/node_modules/ ./node_modules/
COPY --from=backend-builder /app/backend/package.json ./
# Copy frontend built files COPY --from=builder /app/ecosystem.config.cjs ./
COPY --from=frontend-builder /app/frontend/build/ ./frontend-build/
# Copy PM2 configuration COPY --from=builder /app/backend/src/database/ ./dist/database/
COPY ecosystem.config.cjs ./ COPY --from=builder /app/backend/src/database/ ./database/
# Create a non-root user and group - DEBIAN STYLE
RUN groupadd -g 1001 nodejs && \ RUN groupadd -g 1001 nodejs && \
useradd -m -u 1001 -s /bin/bash -g nodejs schichtplan && \ useradd -m -u 1001 -s /bin/bash -g nodejs schichtplan && \
chown -R schichtplan:nodejs /app && \ chown -R schichtplan:nodejs /app && \
chmod 755 /app && \ chmod 755 /app && \
chmod 775 /app/data chmod 775 /app/data
# Set PM2 to use app directory instead of home directory
ENV PM2_HOME=/app/.pm2 ENV PM2_HOME=/app/.pm2
USER schichtplan USER schichtplan
EXPOSE 3002 EXPOSE 3002
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \

3893
backend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -40,7 +40,7 @@ app.get('/api/health', (req: any, res: any) => {
}); });
// 🆕 STATIC FILE SERVING FÜR FRONTEND // 🆕 STATIC FILE SERVING FÜR FRONTEND
const frontendBuildPath = path.join(__dirname, '../frontend-build'); const frontendBuildPath = process.env.FRONTEND_BUILD_PATH || '../frontend-build';
console.log('📁 Frontend build path:', frontendBuildPath); console.log('📁 Frontend build path:', frontendBuildPath);
// Überprüfe ob das Verzeichnis existiert // Überprüfe ob das Verzeichnis existiert

View File

@@ -1,18 +1,17 @@
// ecosystem.config.cjs // ecosystem.config.cjs
module.exports = { module.exports = {
apps: [ apps: [{
{ name: 'schichtplan-app',
name: 'schichtplaner', script: './dist/server.js',
script: './dist/server.js', instances: 1,
instances: 1, env: {
exec_mode: 'fork', NODE_ENV: 'production',
env: { PORT: 3002,
NODE_ENV: 'production', FRONTEND_BUILD_PATH: './frontend-build'
PORT: 3002 },
}, error_file: './logs/err.log',
error_file: './logs/app-err.log', out_file: './logs/out.log',
out_file: './logs/app-out.log', log_file: './logs/combined.log',
time: true time: true
} }]
]
}; };

13
frontend/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Shift Planning App</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

View File

@@ -4,44 +4,22 @@
"private": true, "private": true,
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@testing-library/dom": "^10.4.1", "react": "^19.0.0",
"@testing-library/jest-dom": "^6.9.1", "react-dom": "^19.0.0",
"@testing-library/react": "^16.3.0", "react-router-dom": "^6.28.0"
"@testing-library/user-event": "^13.5.0", },
"@types/jest": "^27.5.2", "devDependencies": {
"@types/node": "^16.18.126", "@types/node": "20.19.23",
"@types/react": "^19.2.2", "@types/react": "^19.0.0",
"@types/react-dom": "^19.2.1", "@types/react-dom": "^19.0.0",
"@types/react-router-dom": "^5.3.3", "@types/react-router-dom": "^5.3.3",
"react": "^19.2.0", "@vitejs/plugin-react": "^4.3.3",
"react-dom": "^19.2.0", "typescript": "^5.7.3",
"react-router-dom": "^7.9.3", "vite": "^6.0.7"
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "dev": "vite",
"build": "react-scripts build", "build": "tsc && vite build",
"test": "react-scripts test", "preview": "vite preview"
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
} }
} }

View File

@@ -1,9 +0,0 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

View File

@@ -1,4 +1,4 @@
// frontend/src/App.tsx - ONE-REPO SAFE WITHOUT DYNAMIC IMPORTS // src/App.tsx - UPDATED FOR VITE
import React from 'react'; import React from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import { AuthProvider, useAuth } from './contexts/AuthContext'; import { AuthProvider, useAuth } from './contexts/AuthContext';
@@ -22,8 +22,8 @@ import About from './components/Layout/FooterLinks/About/About';
import Features from './components/Layout/FooterLinks/Features/Features'; import Features from './components/Layout/FooterLinks/Features/Features';
import { CommunityContact, CommunityLegalPage } from './components/Layout/FooterLinks/CommunityLinks/communityLinks'; import { CommunityContact, CommunityLegalPage } from './components/Layout/FooterLinks/CommunityLinks/communityLinks';
// Feature flag from environment // Vite environment variables (use import.meta.env instead of process.env)
const ENABLE_PRO = process.env.ENABLE_PRO === 'true'; const ENABLE_PRO = import.meta.env.ENABLE_PRO === 'true';
// Conditional Premium Components // Conditional Premium Components
let PremiumContact: React.FC = CommunityContact; let PremiumContact: React.FC = CommunityContact;

View File

@@ -1,3 +1,14 @@
/* Reset and base styles */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
#root {
min-height: 100vh;
}
body { body {
margin: 0; margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',

View File

@@ -1,19 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

10
frontend/src/main.tsx Normal file
View File

@@ -0,0 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)

View File

@@ -129,7 +129,7 @@ const Login: React.FC = () => {
onChange={(e) => setEmail(e.target.value)} onChange={(e) => setEmail(e.target.value)}
required required
style={{ style={{
width: '94.5%', width: '100%',
padding: '10px', padding: '10px',
border: '1px solid #ddd', border: '1px solid #ddd',
borderRadius: '4px', borderRadius: '4px',
@@ -151,7 +151,7 @@ const Login: React.FC = () => {
onChange={(e) => setPassword(e.target.value)} onChange={(e) => setPassword(e.target.value)}
required required
style={{ style={{
width: '94.5%', width: '100%',
padding: '10px', padding: '10px',
paddingRight: '10px', paddingRight: '10px',
border: '1px solid #ddd', border: '1px solid #ddd',

View File

@@ -1 +0,0 @@
/// <reference types="react-scripts" />

View File

@@ -1,15 +0,0 @@
import { ReportHandler } from 'web-vitals';
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;

View File

@@ -1,5 +0,0 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';

12
frontend/src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
/// <reference types="vite/client" />
// Define types for environment variables
interface ImportMetaEnv {
readonly VITE_APP_TITLE: string
readonly ENABLE_PRO: string
// more env variables...
}
interface ImportMeta {
readonly env: ImportMetaEnv
}

View File

@@ -1,28 +1,38 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "ES2020",
"lib": [ "useDefineForClassFields": true,
"dom", "lib": ["ES2020", "DOM", "DOM.Iterable"],
"dom.iterable", "module": "ESNext",
"esnext"
],
"allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"esModuleInterop": true, //"ignoreDeprecations": "6.0",
"allowSyntheticDefaultImports": true,
"strict": true, /* Bundler mode */
"forceConsistentCasingInFileNames": true, "moduleResolution": "bundler",
"noFallthroughCasesInSwitch": true, "allowImportingTsExtensions": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"noEmit": true, "noEmit": true,
"ignoreDeprecations": "6.0",
"jsx": "react-jsx", "jsx": "react-jsx",
"downlevelIteration": true
/* Linting */
"strict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noFallthroughCasesInSwitch": true,
/* Path mapping (modern approach) */
"paths": {
"@/*": ["./src/*"],
"@/components/*": ["./src/components/*"],
"@/pages/*": ["./src/pages/*"],
"@/contexts/*": ["./src/contexts/*"],
"@/utils/*": ["./src/utils/*"],
"@/services/*": ["./src/services/*"],
"@/models/*": ["./src/models/*"],
"@/design/*": ["./src/design/*"]
}
}, },
"include": [ "include": ["src"],
"src" "references": [{ "path": "./tsconfig.node.json" }]
]
} }

View File

@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

45
frontend/vite.config.ts Normal file
View File

@@ -0,0 +1,45 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { resolve } from 'path'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
port: 3003,
host: true,
open: true,
proxy: {
'/api': {
target: 'http://localhost:3002',
changeOrigin: true,
secure: false,
}
}
},
build: {
outDir: 'dist',
sourcemap: true,
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html')
}
}
},
resolve: {
alias: {
'@': resolve(__dirname, './src'),
'@/components': resolve(__dirname, './src/components'),
'@/pages': resolve(__dirname, './src/pages'),
'@/contexts': resolve(__dirname, './src/contexts'),
'@/models': resolve(__dirname, './src/models'),
'@/utils': resolve(__dirname, './src/utils'),
'@/services': resolve(__dirname, './src/services'),
'@/design': resolve(__dirname, './src/design')
}
},
// Define environment variables
define: {
'process.env': process.env
}
})

22218
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -7,15 +7,9 @@
"premium" "premium"
], ],
"scripts": { "scripts": {
"dev:frontend": "cd frontend && npm run dev", "docker:build": "docker build -t schichtplan-app .",
"dev:backend": "cd backend && npm run dev", "docker:run": "docker run -p 3002:3002 schichtplan-app",
"build:all": "npm run build:premium && npm run build:backend && npm run build:frontend", "build:all": "npm run build --workspace=backend && npm run build --workspace=frontend"
"build:premium": "cd premium && npm run build",
"build:backend": "cd backend && npm run build",
"build:frontend": "cd frontend && npm run build",
"type-check": "npm run type-check:all",
"type-check:all": "cd premium && npx tsc --noEmit && cd ../backend && npx tsc --noEmit && cd ../frontend && npx tsc --noEmit",
"clean": "rm -rf premium/dist backend/dist frontend/dist"
}, },
"devDependencies": { "devDependencies": {
"typescript": "^5.3.3" "typescript": "^5.3.3"

Submodule premium updated: ce4b3fd6e0...c65016aaab