Competition/Round architecture: full platform rewrite (Phases 1-9)
All checks were successful
Build and Push Docker Image / build (push) Successful in 7m45s

Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 23:04:15 +01:00
parent 9ab4717f96
commit 6ca39c976b
349 changed files with 69938 additions and 28767 deletions

View File

@@ -8,13 +8,13 @@ import { ProjectFilesSection } from './project-files-section'
interface CollapsibleFilesSectionProps {
projectId: string
stageId: string
roundId: string
fileCount: number
}
export function CollapsibleFilesSection({
projectId,
stageId,
roundId,
fileCount,
}: CollapsibleFilesSectionProps) {
const [isExpanded, setIsExpanded] = useState(false)
@@ -63,7 +63,7 @@ export function CollapsibleFilesSection({
{isExpanded && (
<CardContent className="pt-0">
{showFiles ? (
<ProjectFilesSection projectId={projectId} stageId={stageId} />
<ProjectFilesSection projectId={projectId} roundId={roundId} />
) : (
<div className="py-4 text-center text-sm text-muted-foreground">
Loading documents...

View File

@@ -0,0 +1,181 @@
'use client';
import { useState } from 'react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Label } from '@/components/ui/label';
import { Input } from '@/components/ui/input';
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle
} from '@/components/ui/alert-dialog';
import { Badge } from '@/components/ui/badge';
interface Project {
id: string;
title: string;
category: string;
}
interface DeliberationRankingFormProps {
projects: Project[];
mode: 'SINGLE_WINNER_VOTE' | 'FULL_RANKING';
onSubmit: (votes: Array<{ projectId: string; rank?: number; isWinnerPick?: boolean }>) => void;
disabled?: boolean;
}
export function DeliberationRankingForm({
projects,
mode,
onSubmit,
disabled = false
}: DeliberationRankingFormProps) {
const [selectedWinner, setSelectedWinner] = useState<string>('');
const [rankings, setRankings] = useState<Record<string, number>>({});
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
const handleSubmit = () => {
if (mode === 'SINGLE_WINNER_VOTE') {
if (!selectedWinner) {
return;
}
} else {
// FULL_RANKING mode - check if all ranks are assigned
const assignedRanks = Object.values(rankings);
if (assignedRanks.length !== projects.length) {
return;
}
}
setConfirmDialogOpen(true);
};
const handleConfirm = () => {
if (mode === 'SINGLE_WINNER_VOTE') {
onSubmit([
{
projectId: selectedWinner,
isWinnerPick: true
}
]);
} else {
// FULL_RANKING mode
const votes = Object.entries(rankings).map(([projectId, rank]) => ({
projectId,
rank
}));
onSubmit(votes);
}
setConfirmDialogOpen(false);
};
const isValid = mode === 'SINGLE_WINNER_VOTE'
? !!selectedWinner
: Object.keys(rankings).length === projects.length;
return (
<>
<Card>
<CardHeader>
<CardTitle>
{mode === 'SINGLE_WINNER_VOTE' ? 'Select Winner' : 'Rank All Projects'}
</CardTitle>
<CardDescription>
{mode === 'SINGLE_WINNER_VOTE'
? 'Choose your top pick for this category'
: 'Assign a rank (1 = best) to each project'}
</CardDescription>
</CardHeader>
<CardContent className="space-y-6">
{mode === 'SINGLE_WINNER_VOTE' ? (
<RadioGroup value={selectedWinner} onValueChange={setSelectedWinner}>
<div className="space-y-3">
{projects.map((project) => (
<div
key={project.id}
className="flex items-center space-x-3 rounded-lg border p-4"
>
<RadioGroupItem value={project.id} id={project.id} />
<Label htmlFor={project.id} className="flex-1 cursor-pointer">
<div>
<p className="font-medium">{project.title}</p>
<Badge variant="outline" className="mt-1">
{project.category}
</Badge>
</div>
</Label>
</div>
))}
</div>
</RadioGroup>
) : (
<div className="space-y-3">
{projects.map((project) => (
<div
key={project.id}
className="flex items-center gap-3 rounded-lg border p-4"
>
<Input
type="number"
min="1"
max={projects.length}
placeholder="Rank"
value={rankings[project.id] || ''}
onChange={(e) => {
const rank = parseInt(e.target.value) || 0;
if (rank > 0 && rank <= projects.length) {
setRankings({
...rankings,
[project.id]: rank
});
} else if (e.target.value === '') {
const newRankings = { ...rankings };
delete newRankings[project.id];
setRankings(newRankings);
}
}}
className="w-20"
/>
<div className="flex-1">
<p className="font-medium">{project.title}</p>
<Badge variant="outline" className="mt-1">
{project.category}
</Badge>
</div>
</div>
))}
</div>
)}
<Button onClick={handleSubmit} disabled={!isValid || disabled} className="w-full" size="lg">
{disabled ? 'Submitting...' : 'Submit Vote'}
</Button>
</CardContent>
</Card>
{/* Confirmation Dialog */}
<AlertDialog open={confirmDialogOpen} onOpenChange={setConfirmDialogOpen}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Confirm Your Vote</AlertDialogTitle>
<AlertDialogDescription>
{mode === 'SINGLE_WINNER_VOTE'
? 'You have selected your winner. This vote cannot be changed once submitted.'
: 'You have ranked all projects. This ranking cannot be changed once submitted.'}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Review</AlertDialogCancel>
<AlertDialogAction onClick={handleConfirm}>Confirm Vote</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</>
);
}

View File

@@ -0,0 +1,124 @@
'use client';
import { useState } from 'react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Label } from '@/components/ui/label';
import { Input } from '@/components/ui/input';
import { Slider } from '@/components/ui/slider';
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle
} from '@/components/ui/alert-dialog';
import { CheckCircle2 } from 'lucide-react';
interface LiveVotingFormProps {
sessionId?: string;
projectId: string;
onVoteSubmit: (vote: { score: number }) => void;
disabled?: boolean;
}
export function LiveVotingForm({
sessionId,
projectId,
onVoteSubmit,
disabled = false
}: LiveVotingFormProps) {
const [score, setScore] = useState(50);
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
const [hasSubmitted, setHasSubmitted] = useState(false);
const handleSubmit = () => {
setConfirmDialogOpen(true);
};
const handleConfirm = () => {
onVoteSubmit({ score });
setHasSubmitted(true);
setConfirmDialogOpen(false);
};
if (hasSubmitted || disabled) {
return (
<Card>
<CardContent className="flex flex-col items-center justify-center py-12">
<CheckCircle2 className="mb-4 h-12 w-12 text-green-600" />
<p className="font-medium">Vote Submitted</p>
<p className="mt-1 text-sm text-muted-foreground">Score: {score}/100</p>
</CardContent>
</Card>
);
}
return (
<>
<Card>
<CardHeader>
<CardTitle>Live Voting</CardTitle>
<CardDescription>Rate this project on a scale of 0-100</CardDescription>
</CardHeader>
<CardContent className="space-y-6">
<div className="space-y-4">
<div className="flex items-center justify-between">
<Label>Score</Label>
<div className="flex items-center gap-3">
<Input
type="number"
min="0"
max="100"
value={score}
onChange={(e) => setScore(Math.min(100, Math.max(0, parseInt(e.target.value) || 0)))}
className="w-20 text-center"
/>
<span className="text-2xl font-bold text-primary">{score}</span>
</div>
</div>
<Slider
value={[score]}
onValueChange={(values) => setScore(values[0])}
min={0}
max={100}
step={1}
className="w-full"
/>
<div className="flex justify-between text-xs text-muted-foreground">
<span>Poor (0)</span>
<span>Average (50)</span>
<span>Excellent (100)</span>
</div>
</div>
<Button onClick={handleSubmit} className="w-full" size="lg">
Submit Vote
</Button>
</CardContent>
</Card>
{/* Confirmation Dialog */}
<AlertDialog open={confirmDialogOpen} onOpenChange={setConfirmDialogOpen}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Confirm Your Vote</AlertDialogTitle>
<AlertDialogDescription>
You are about to submit a score of <strong>{score}/100</strong>. This action cannot
be undone. Are you sure?
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction onClick={handleConfirm}>Confirm Vote</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</>
);
}

View File

@@ -0,0 +1,145 @@
'use client'
import { trpc } from '@/lib/trpc/client'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { Skeleton } from '@/components/ui/skeleton'
import { FileText, Download, ExternalLink } from 'lucide-react'
import { toast } from 'sonner'
interface MultiWindowDocViewerProps {
roundId: string
projectId: string
}
function formatFileSize(bytes: number): string {
if (bytes === 0) return '0 B'
const k = 1024
const sizes = ['B', 'KB', 'MB', 'GB']
const i = Math.floor(Math.log(bytes) / Math.log(k))
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
}
function getFileIcon(mimeType: string) {
if (mimeType.startsWith('image/')) return '🖼️'
if (mimeType.startsWith('video/')) return '🎥'
if (mimeType.includes('pdf')) return '📄'
if (mimeType.includes('word') || mimeType.includes('document')) return '📝'
if (mimeType.includes('sheet') || mimeType.includes('excel')) return '📊'
if (mimeType.includes('presentation') || mimeType.includes('powerpoint')) return '📊'
return '📎'
}
export function MultiWindowDocViewer({ roundId, projectId }: MultiWindowDocViewerProps) {
const { data: windows, isLoading } = trpc.round.getVisibleWindows.useQuery(
{ roundId },
{ enabled: !!roundId }
)
if (isLoading) {
return (
<Card>
<CardHeader>
<Skeleton className="h-6 w-48" />
</CardHeader>
<CardContent>
<Skeleton className="h-64" />
</CardContent>
</Card>
)
}
if (!windows || windows.length === 0) {
return (
<Card>
<CardHeader>
<CardTitle>Documents</CardTitle>
<CardDescription>Submission windows and uploaded files</CardDescription>
</CardHeader>
<CardContent className="text-center py-8">
<FileText className="h-12 w-12 text-muted-foreground/50 mx-auto mb-3" />
<p className="text-sm text-muted-foreground">No submission windows available</p>
</CardContent>
</Card>
)
}
return (
<Card>
<CardHeader>
<CardTitle>Documents</CardTitle>
<CardDescription>Files submitted across all windows</CardDescription>
</CardHeader>
<CardContent>
<Tabs defaultValue={windows[0]?.id || ''} className="w-full">
<TabsList className="w-full flex-wrap justify-start h-auto gap-1 bg-transparent p-0 mb-4">
{windows.map((window: any) => (
<TabsTrigger
key={window.id}
value={window.id}
className="data-[state=active]:bg-brand-blue data-[state=active]:text-white px-4 py-2 rounded-md text-sm"
>
{window.name}
{window.files && window.files.length > 0 && (
<Badge variant="secondary" className="ml-2 text-xs">
{window.files.length}
</Badge>
)}
</TabsTrigger>
))}
</TabsList>
{windows.map((window: any) => (
<TabsContent key={window.id} value={window.id} className="mt-0">
{!window.files || window.files.length === 0 ? (
<div className="text-center py-8 border border-dashed rounded-lg">
<FileText className="h-10 w-10 text-muted-foreground/50 mx-auto mb-2" />
<p className="text-sm text-muted-foreground">No files uploaded</p>
</div>
) : (
<div className="grid gap-3 sm:grid-cols-2">
{window.files.map((file: any) => (
<Card key={file.id} className="overflow-hidden">
<CardContent className="p-4">
<div className="flex items-start gap-3">
<div className="text-2xl">{getFileIcon(file.mimeType || '')}</div>
<div className="flex-1 min-w-0">
<p className="font-medium text-sm truncate" title={file.filename}>
{file.filename}
</p>
<div className="flex items-center gap-2 mt-1">
<Badge variant="outline" className="text-xs">
{file.mimeType?.split('/')[1]?.toUpperCase() || 'FILE'}
</Badge>
{file.size && (
<span className="text-xs text-muted-foreground">
{formatFileSize(file.size)}
</span>
)}
</div>
<div className="flex gap-2 mt-3">
<Button size="sm" variant="outline" className="h-7 text-xs">
<Download className="mr-1 h-3 w-3" />
Download
</Button>
<Button size="sm" variant="ghost" className="h-7 text-xs">
<ExternalLink className="mr-1 h-3 w-3" />
Preview
</Button>
</div>
</div>
</div>
</CardContent>
</Card>
))}
</div>
)}
</TabsContent>
))}
</Tabs>
</CardContent>
</Card>
)
}

View File

@@ -8,13 +8,13 @@ import { AlertCircle, FileX } from 'lucide-react'
interface ProjectFilesSectionProps {
projectId: string
stageId: string
roundId: string
}
export function ProjectFilesSection({ projectId, stageId }: ProjectFilesSectionProps) {
const { data: groupedFiles, isLoading, error } = trpc.file.listByProjectForStage.useQuery({
export function ProjectFilesSection({ projectId, roundId }: ProjectFilesSectionProps) {
const { data: files, isLoading, error } = trpc.file.listByProject.useQuery({
projectId,
stageId,
roundId,
})
if (isLoading) {
@@ -35,7 +35,7 @@ export function ProjectFilesSection({ projectId, stageId }: ProjectFilesSectionP
)
}
if (!groupedFiles || groupedFiles.length === 0) {
if (!files || files.length === 0) {
return (
<Card>
<CardContent className="flex flex-col items-center justify-center py-8 text-center">
@@ -49,22 +49,9 @@ export function ProjectFilesSection({ projectId, stageId }: ProjectFilesSectionP
)
}
// Flatten all files from all stage groups for FileViewer
const allFiles = groupedFiles.flatMap((group) => group.files)
return (
<div className="space-y-4">
{groupedFiles.map((group) => (
<div key={group.stageId || 'general'} className="space-y-2">
<div className="flex items-center gap-2">
<h3 className="font-semibold text-sm text-muted-foreground uppercase tracking-wide">
{group.stageName}
</h3>
<div className="flex-1 h-px bg-border" />
</div>
<FileViewer files={group.files} />
</div>
))}
<FileViewer files={files} />
</div>
)
}