feat: завершить проект — добавить недостающие файлы, тесты и CI/CD

- backend/app/schemas/auth.py, ai_match.py, escrow.py (схемы)
- frontend/components/ui/button.tsx (UI компонент)
- email-validator в requirements.txt
- frontend/tsconfig.json, tailwind.config.js, postcss.config.js
- frontend: login page, projects/[id] page, ai-match page
- Dockerfile для backend и frontend
- docker-compose.yml с app-контейнерами и healthcheck
- .env.example с полными переменными окружения
- backend/tests/ — pytest тесты (conftest + test_health)
- .drone.yml — CI/CD пайплайн для Drone CI
- README.md — полный гайд по деплою
This commit is contained in:
2026-07-03 13:28:19 +00:00
parent ec2e9bf508
commit 4ccf4b7184
20 changed files with 693 additions and 46 deletions
+86
View File
@@ -0,0 +1,86 @@
"use client";
import { useState } from "react";
import Link from "next/link";
import { Button } from "@/components/ui/button";
export default function AIMatchPage() {
const [projectId, setProjectId] = useState("");
const [loading, setLoading] = useState(false);
const [matches, setMatches] = useState<any[]>([]);
const [error, setError] = useState("");
async function handleMatch() {
if (!projectId) return;
setLoading(true);
try {
const res = await fetch("/api/ai/match-project", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ project_id: projectId, limit: 10 }),
});
if (!res.ok) throw new Error("Ошибка при поиске совпадений");
const data = await res.json();
setMatches(data);
} catch (err) {
setError(err.message);
} finally {
setLoading(false);
}
}
return (
<div className="min-h-screen bg-gray-50">
<header className="bg-white border-b px-6 py-4 flex items-center justify-between">
<Link href="/dashboard" className="text-blue-600 hover:text-blue-800"> Назад</Link>
<h1 className="text-xl font-bold">AI-матчинг</h1>
</header>
<main className="container mx-auto px-4 py-8 max-w-3xl">
<div className="bg-white rounded-xl shadow-sm p-6 mb-6">
<h2 className="text-2xl font-bold mb-4">Подобрать фрилансеров</h2>
<input
value={projectId}
onChange={(e) => setProjectId(e.target.value)}
placeholder="ID проекта"
className="w-full px-4 py-3 border rounded-lg mb-4"
/>
{error && (
<div className="mb-4 p-3 bg-red-50 text-red-700 rounded">{error}</div>
)}
<Button onClick={handleMatch} disabled={loading}>
{loading ? "Поиск..." : "Найти совпадения"}
</Button>
</div>
{matches.length > 0 && (
<div className="space-y-4">
{matches.map((m, i) => (
<div key={i} className="bg-white rounded-xl shadow-sm p-6">
<div className="flex items-center justify-between mb-2">
<h3 className="font-semibold">{m.name}</h3>
<span className="text-green-600 font-bold">{(m.match_score * 100).toFixed(0)}%</span>
</div>
{m.skills_matched.length > 0 && (
<p className="text-sm text-gray-500 mb-2">Совпадение навыков: {m.skills_matched.join(", ")}</p>
)}
<ul className="space-y-1">
{m.reasons.map((r, j) => (
<li key={j} className="text-sm text-gray-600"> {r}</li>
))}
</ul>
</div>
))}
</div>
)}
</main>
</div>
);
}
+73
View File
@@ -0,0 +1,73 @@
"use client";
import { useState } from "react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import * as z from "zod";
const loginSchema = z.object({
email: z.string().email(),
password: z.string().min(1),
});
type FormData = z.infer<typeof loginSchema>;
export default function LoginPage() {
const router = useRouter();
const [loading, setLoading] = useState(false);
const [error, setError] = useState("");
const form = useForm<FormData>({ resolver: zodResolver(loginSchema) });
async function onSubmit(data: FormData) {
setLoading(true);
try {
const res = await fetch("/api/auth/login", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
});
if (!res.ok) throw new Error("Неверный email или пароль");
router.push("/dashboard");
} catch (err) {
setError(err.message);
} finally {
setLoading(false);
}
}
return (
<div className="min-h-screen flex items-center justify-center bg-gray-50">
<form onSubmit={form.handleSubmit(onSubmit)} className="w-full max-w-md p-8 rounded-xl shadow-sm bg-white">
<h1 className="text-2xl font-bold mb-6">Вход</h1>
{error && (
<div className="mb-4 p-3 bg-red-50 text-red-700 rounded">{error}</div>
)}
<input {...form.register("email")} placeholder="Email" className="w-full mb-3 px-4 py-2 border rounded" />
{form.formState.errors.email && (
<p className="text-sm text-red-500 mb-2">{form.formState.errors.email.message}</p>
)}
<input {...form.register("password")} type="password" placeholder="Пароль" className="w-full mb-4 px-4 py-2 border rounded" />
{form.formState.errors.password && (
<p className="text-sm text-red-500 mb-2">{form.formState.errors.password.message}</p>
)}
<button type="submit" disabled={loading} className="w-full bg-blue-600 text-white py-3 rounded font-medium">
{loading ? "Вход..." : "Войти"}
</button>
<p className="text-center mt-4 text-sm">
Нет аккаунта?{" "}
<Link href="/auth/register" className="text-blue-600">Зарегистрироваться</Link>
</p>
</form>
</div>
);
}
+66
View File
@@ -0,0 +1,66 @@
"use client";
import { useQuery } from "@tanstack/react-query";
import Link from "next/link";
import { useParams, useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
async function fetchProject(id: string) {
const res = await fetch(`/api/projects/${id}`);
if (!res.ok) throw new Error("Проект не найден");
return res.json();
}
export default function ProjectPage() {
const params = useParams<{ id: string }>();
const router = useRouter();
const { data: project, isLoading } = useQuery({
queryKey: ["project", params.id],
queryFn: () => fetchProject(params.id),
});
if (isLoading) return <div className="min-h-screen flex items-center justify-center">Загрузка...</div>;
if (!project) return <div>Проект не найден</div>;
return (
<div className="min-h-screen bg-gray-50">
<header className="bg-white border-b px-6 py-4 flex items-center justify-between">
<Link href="/dashboard" className="text-blue-600 hover:text-blue-800"> Назад</Link>
<h1 className="text-xl font-bold">Freelancer Match</h1>
</header>
<main className="container mx-auto px-4 py-8 max-w-3xl">
<div className="bg-white rounded-xl shadow-sm p-6 mb-6">
<h2 className="text-2xl font-bold mb-4">{project.title}</h2>
<p className="text-gray-700 whitespace-pre-wrap mb-4">{project.description}</p>
{project.category && (
<span className="inline-block px-3 py-1 bg-blue-100 text-blue-800 rounded-full text-sm">
{project.category}
</span>
)}
<div className="mt-4 flex gap-2 flex-wrap">
{project.required_skills.map((skill: string) => (
<span key={skill} className="px-2 py-1 bg-gray-100 rounded text-sm">{skill}</span>
))}
</div>
{(project.budget_min || project.budget_max) && (
<div className="mt-4 p-3 bg-green-50 rounded">
{project.budget_min ? `${project.budget_min.toLocaleString()}` : "—"} {" "}
{project.budget_max ? `${project.budget_max.toLocaleString()}` : "до бесконечности"}
</div>
)}
{project.deadline && (
<p className="mt-2 text-sm text-gray-500">Дедлайн: {new Date(project.deadline).toLocaleDateString("ru-RU")}</p>
)}
</div>
<Button onClick={() => router.push("/auth/login")}>Оставить заявку</Button>
</main>
</div>
);
}