FE-0: Projektgrundgerüst (SvelteKit, Tailwind, Docker, Caddy)
This commit is contained in:
5
.dockerignore
Normal file
5
.dockerignore
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
node_modules
|
||||||
|
.git
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
*.md
|
||||||
8
.env.example
Normal file
8
.env.example
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# URL des NSCT Backend API
|
||||||
|
NSCT_API_BASE_URL=http://localhost:8080
|
||||||
|
|
||||||
|
# Optional: Caddy Domain für externen Zugriff
|
||||||
|
CADDY_DOMAIN=
|
||||||
|
|
||||||
|
# Default Theme
|
||||||
|
DEFAULT_THEME=dark
|
||||||
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
node_modules
|
||||||
|
.svelte-kit
|
||||||
|
build
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
*.log
|
||||||
|
.DS_Store
|
||||||
12
Caddyfile
Normal file
12
Caddyfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
:443 {
|
||||||
|
reverse_proxy web:3000
|
||||||
|
|
||||||
|
@notPrivateIP not remote_ip 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 127.0.0.0/8
|
||||||
|
|
||||||
|
encode gzip zstd
|
||||||
|
header {
|
||||||
|
X-Content-Type-Options nosniff
|
||||||
|
X-Frame-Options DENY
|
||||||
|
X-XSS-Protection "1; mode=block"
|
||||||
|
}
|
||||||
|
}
|
||||||
25
Dockerfile
Normal file
25
Dockerfile
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Build stage
|
||||||
|
FROM node:22-alpine AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json .
|
||||||
|
RUN npm ci
|
||||||
|
COPY . .
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Production stage
|
||||||
|
FROM node:22-alpine AS runtime
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=builder /app/build ./build
|
||||||
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
|
COPY package.json package.json
|
||||||
|
|
||||||
|
# Non-root user
|
||||||
|
RUN addgroup -S nsct && adduser -S nsct -G nsct
|
||||||
|
USER nsct
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
ENV PORT=3000
|
||||||
|
|
||||||
|
CMD ["node", "build"]
|
||||||
38
docker-compose.yml
Normal file
38
docker-compose.yml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
services:
|
||||||
|
web:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: nsct-web
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- NSCT_API_BASE_URL=http://nsct-api:8080
|
||||||
|
- DEFAULT_THEME=dark
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
networks:
|
||||||
|
- nsct-network
|
||||||
|
|
||||||
|
caddy:
|
||||||
|
image: caddy:2.8-alpine
|
||||||
|
container_name: nsct-caddy
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
|
volumes:
|
||||||
|
- ./Caddyfile:/etc/caddy/Caddyfile
|
||||||
|
- caddy_data:/data
|
||||||
|
- caddy_config:/config
|
||||||
|
networks:
|
||||||
|
- nsct-network
|
||||||
|
depends_on:
|
||||||
|
- web
|
||||||
|
|
||||||
|
networks:
|
||||||
|
nsct-network:
|
||||||
|
driver: bridge
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
caddy_data:
|
||||||
|
caddy_config:
|
||||||
27
package.json
Normal file
27
package.json
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"name": "nsct-web",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite dev",
|
||||||
|
"build": "vite build",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@sveltejs/adapter-static": "^3.0.0",
|
||||||
|
"@sveltejs/kit": "^2.0.0",
|
||||||
|
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
||||||
|
"autoprefixer": "^10.4.0",
|
||||||
|
"postcss": "^8.4.0",
|
||||||
|
"svelte": "^5.0.0",
|
||||||
|
"svelte-check": "^4.0.0",
|
||||||
|
"tailwindcss": "^4.0.0",
|
||||||
|
"typescript": "^5.0.0",
|
||||||
|
"vite": "^6.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"svelte-markdown": "^0.5.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
6
postcss.config.js
Normal file
6
postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export default {
|
||||||
|
plugins: {
|
||||||
|
tailwindcss: {},
|
||||||
|
autoprefixer: {}
|
||||||
|
}
|
||||||
|
};
|
||||||
1
src/app.css
Normal file
1
src/app.css
Normal file
@@ -0,0 +1 @@
|
|||||||
|
@import 'tailwindcss';
|
||||||
14
src/app.d.ts
vendored
Normal file
14
src/app.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
/// <reference types="@sveltejs/kit" />
|
||||||
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
namespace App {
|
||||||
|
// interface Error {}
|
||||||
|
// interface Locals {}
|
||||||
|
// interface PageData {}
|
||||||
|
// interface PageState {}
|
||||||
|
// interface Platform {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {};
|
||||||
11
src/app.html
Normal file
11
src/app.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de" class="dark">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
%sveltekit.head%
|
||||||
|
</head>
|
||||||
|
<body class="bg-gray-900 text-white dark">
|
||||||
|
<div>%sveltekit.body%</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
60
src/lib/api.ts
Normal file
60
src/lib/api.ts
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
const API_BASE_URL = import.meta.env.NSCT_API_BASE_URL || 'http://localhost:8080';
|
||||||
|
|
||||||
|
interface ApiConfig {
|
||||||
|
apiKey?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function headers(config?: ApiConfig): Record<string, string> {
|
||||||
|
const h: Record<string, string> = {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
};
|
||||||
|
if (config?.apiKey) {
|
||||||
|
h['X-API-Key'] = config.apiKey;
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiPost<T>(
|
||||||
|
path: string,
|
||||||
|
body?: unknown,
|
||||||
|
config?: ApiConfig
|
||||||
|
): Promise<T> {
|
||||||
|
const res = await fetch(`${API_BASE_URL}${path}`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: headers(config),
|
||||||
|
body: body ? JSON.stringify(body) : undefined
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`API Error ${res.status}: ${res.statusText}`);
|
||||||
|
}
|
||||||
|
return res.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiGet<T>(
|
||||||
|
path: string,
|
||||||
|
config?: ApiConfig
|
||||||
|
): Promise<T> {
|
||||||
|
const res = await fetch(`${API_BASE_URL}${path}`, {
|
||||||
|
headers: headers(config)
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`API Error ${res.status}: ${res.statusText}`);
|
||||||
|
}
|
||||||
|
return res.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDelete<T>(
|
||||||
|
path: string,
|
||||||
|
config?: ApiConfig
|
||||||
|
): Promise<T> {
|
||||||
|
const res = await fetch(`${API_BASE_URL}${path}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: headers(config)
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`API Error ${res.status}: ${res.statusText}`);
|
||||||
|
}
|
||||||
|
return res.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
export { API_BASE_URL };
|
||||||
13
src/lib/stores.ts
Normal file
13
src/lib/stores.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
|
// Theme: 'dark' | 'light'
|
||||||
|
export const theme = writable<'dark' | 'light'>('dark');
|
||||||
|
|
||||||
|
// User: null oder { apiKey, username? }
|
||||||
|
export const user = writable<{ apiKey: string; username?: string } | null>(null);
|
||||||
|
|
||||||
|
// Sidebar: ist offen oder geschlossen (mobile)
|
||||||
|
export const sidebarOpen = writable(false);
|
||||||
|
|
||||||
|
// Session IDs der letzten Researches
|
||||||
|
export const recentResearchIds = writable<string[]>([]);
|
||||||
20
src/lib/theme.ts
Normal file
20
src/lib/theme.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { theme } from '$lib/stores';
|
||||||
|
|
||||||
|
export function initTheme() {
|
||||||
|
const stored = localStorage.getItem('nsct-theme');
|
||||||
|
if (stored === 'dark' || stored === 'light') {
|
||||||
|
theme.set(stored);
|
||||||
|
} else {
|
||||||
|
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
|
theme.set(prefersDark ? 'dark' : 'light');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toggleTheme() {
|
||||||
|
theme.update(t => t === 'dark' ? 'light' : 'dark');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function applyTheme(t: 'dark' | 'light') {
|
||||||
|
document.documentElement.classList.toggle('dark', t === 'dark');
|
||||||
|
localStorage.setItem('nsct-theme', t);
|
||||||
|
}
|
||||||
41
src/lib/types.ts
Normal file
41
src/lib/types.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
export interface ResearchStatus {
|
||||||
|
id: string;
|
||||||
|
status: string;
|
||||||
|
progress?: number;
|
||||||
|
error?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResearchSummary {
|
||||||
|
id: string;
|
||||||
|
query: string;
|
||||||
|
status: string;
|
||||||
|
created_at: string;
|
||||||
|
completed_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SourceInfo {
|
||||||
|
id: string;
|
||||||
|
url: string;
|
||||||
|
title: string;
|
||||||
|
domain?: string;
|
||||||
|
source_type?: string;
|
||||||
|
independence_score?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ClaimInfo {
|
||||||
|
id: string;
|
||||||
|
claim: string;
|
||||||
|
claim_type: string;
|
||||||
|
confidence: number;
|
||||||
|
source_id?: string;
|
||||||
|
evidence_span?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EvidenceScore {
|
||||||
|
source_independence: number;
|
||||||
|
primary_source_proximity: number;
|
||||||
|
cross_source_support: number;
|
||||||
|
contradiction_level: number;
|
||||||
|
evidence_directness: number;
|
||||||
|
date_relevance: number;
|
||||||
|
}
|
||||||
17
src/routes/+layout.svelte
Normal file
17
src/routes/+layout.svelte
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<script>
|
||||||
|
import '../app.css';
|
||||||
|
import { initTheme, applyTheme } from '$lib/theme';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
|
initTheme();
|
||||||
|
onMount(() => {
|
||||||
|
applyTheme($theme);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<title>NSCT – Neutral Search Crawler</title>
|
||||||
|
<meta name="description" content="Neutraler Recherche- und Analyse-Report" />
|
||||||
|
</svelte:head>
|
||||||
|
|
||||||
|
<slot />
|
||||||
49
src/routes/+page.svelte
Normal file
49
src/routes/+page.svelte
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<script>
|
||||||
|
import { user } from '$lib/stores';
|
||||||
|
import { theme, toggleTheme } from '$lib/theme';
|
||||||
|
|
||||||
|
let apiKey = '';
|
||||||
|
let error = '';
|
||||||
|
|
||||||
|
function login() {
|
||||||
|
if (apiKey.trim()) {
|
||||||
|
user.set({ apiKey: apiKey.trim() });
|
||||||
|
error = '';
|
||||||
|
} else {
|
||||||
|
error = 'Bitte API-Key eingeben.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="min-h-screen flex items-center justify-center p-4">
|
||||||
|
<div class="w-full max-w-md">
|
||||||
|
<h1 class="text-3xl font-bold mb-2 text-center">NSCT</h1>
|
||||||
|
<p class="text-center text-gray-500 mb-8">Neutral Search Crawler Tool</p>
|
||||||
|
|
||||||
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6">
|
||||||
|
<h2 class="text-xl font-semibold mb-4">Anmelden</h2>
|
||||||
|
<input
|
||||||
|
bind:value={apiKey}
|
||||||
|
placeholder="API-Key eingeben"
|
||||||
|
class="w-full px-3 py-2 border rounded dark:bg-gray-700 dark:border-gray-600 mb-4"
|
||||||
|
on:keydown={(e) => e.key === 'Enter' && login()}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
on:click={login}
|
||||||
|
class="w-full bg-indigo-600 text-white py-2 rounded hover:bg-indigo-700"
|
||||||
|
>
|
||||||
|
Anmelden
|
||||||
|
</button>
|
||||||
|
{#if error}
|
||||||
|
<p class="text-red-500 mt-2 text-sm">{error}</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
on:click={toggleTheme}
|
||||||
|
class="mt-4 text-sm text-gray-500 hover:text-gray-300"
|
||||||
|
>
|
||||||
|
Theme umschalten ☀/☾
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
22
svelte.config.js
Normal file
22
svelte.config.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import adapter from '@sveltejs/adapter-static';
|
||||||
|
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
kit: {
|
||||||
|
adapter: adapter({
|
||||||
|
pages: 'build',
|
||||||
|
assets: 'build',
|
||||||
|
fallback: undefined,
|
||||||
|
precompress: false,
|
||||||
|
strict: true
|
||||||
|
}),
|
||||||
|
alias: {
|
||||||
|
$components: 'src/components',
|
||||||
|
$lib: 'src/lib',
|
||||||
|
$assets: 'src/assets'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
preprocess: vitePreprocess()
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
33
tailwind.config.js
Normal file
33
tailwind.config.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/** @type {import('tailwindcss').Config} */
|
||||||
|
export default {
|
||||||
|
content: ['./src/**/*.{svelte,js,ts,html}'],
|
||||||
|
darkMode: 'class', // Class-based theming (dark/light toggle)
|
||||||
|
theme: {
|
||||||
|
extend: {
|
||||||
|
colors: {
|
||||||
|
// Dark mode colors
|
||||||
|
'nsct-dark-bg': '#0f0f23',
|
||||||
|
'nsct-dark-surface': '#1a1a2e',
|
||||||
|
'nsct-dark-border': '#2d2d44',
|
||||||
|
'nsct-dark-text': '#e0e0e0',
|
||||||
|
'nsct-dark-text-secondary': '#a0a0b0',
|
||||||
|
'nsct-dark-hover': '#2a2a3e',
|
||||||
|
// Light mode colors
|
||||||
|
'nsct-light-bg': '#ffffff',
|
||||||
|
'nsct-light-surface': '#f8f9fa',
|
||||||
|
'nsct-light-border': '#e0e0e0',
|
||||||
|
'nsct-light-text': '#1a1a1a',
|
||||||
|
'nsct-light-text-secondary': '#666666',
|
||||||
|
'nsct-light-hover': '#f0f0f0',
|
||||||
|
// Accent
|
||||||
|
'nsct-accent': '#6366f1',
|
||||||
|
'nsct-accent-hover': '#4f46e5',
|
||||||
|
'nsct-success': '#22c55e',
|
||||||
|
'nsct-warning': '#f59e0b',
|
||||||
|
'nsct-error': '#ef4444',
|
||||||
|
'nsct-info': '#3b82f6'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: []
|
||||||
|
};
|
||||||
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"extends": "./.svelte-kit/tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowJs": true,
|
||||||
|
"checkJs": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"strict": true,
|
||||||
|
"moduleResolution": "bundler"
|
||||||
|
}
|
||||||
|
}
|
||||||
18
vite.config.ts
Normal file
18
vite.config.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { sveltekit } from '@sveltejs/kit/vite';
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [sveltekit()],
|
||||||
|
server: {
|
||||||
|
port: 3000,
|
||||||
|
strictPort: true,
|
||||||
|
host: '0.0.0.0',
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: 'http://nsct-api:8080',
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: (path) => path.replace(/^\/api/, '')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user