fastapi-fullstack 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastapi_fullstack-0.1.2.dist-info/METADATA +545 -0
- fastapi_fullstack-0.1.2.dist-info/RECORD +221 -0
- fastapi_fullstack-0.1.2.dist-info/WHEEL +4 -0
- fastapi_fullstack-0.1.2.dist-info/entry_points.txt +2 -0
- fastapi_fullstack-0.1.2.dist-info/licenses/LICENSE +21 -0
- fastapi_gen/__init__.py +3 -0
- fastapi_gen/cli.py +256 -0
- fastapi_gen/config.py +255 -0
- fastapi_gen/generator.py +181 -0
- fastapi_gen/prompts.py +648 -0
- fastapi_gen/template/cookiecutter.json +76 -0
- fastapi_gen/template/hooks/post_gen_project.py +111 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/.env.example +136 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/.github/workflows/ci.yml +150 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/.gitignore +108 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/CLAUDE.md +357 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/Makefile +298 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/README.md +723 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/.dockerignore +60 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/.pre-commit-config.yaml +32 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/Dockerfile +56 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/env.py +76 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/script.py.mako +30 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic/versions/.gitkeep +0 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/alembic.ini +48 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/__init__.py +3 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/admin.py +115 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/__init__.py +13 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/assistant.py +202 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/tools/__init__.py +13 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/agents/tools/datetime_tool.py +17 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/__init__.py +1 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/deps.py +528 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/exception_handlers.py +85 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/router.py +10 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/__init__.py +9 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/__init__.py +87 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/agent.py +448 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/auth.py +395 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/conversations.py +490 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/health.py +227 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/items.py +275 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/oauth.py +205 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/sessions.py +168 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/users.py +333 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/webhooks.py +477 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/routes/v1/ws.py +46 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/api/versioning.py +221 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/clients/__init__.py +14 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/clients/redis.py +88 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/commands/__init__.py +117 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/commands/cleanup.py +75 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/commands/example.py +28 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/commands/seed.py +266 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/__init__.py +5 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/cache.py +23 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/config.py +247 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/csrf.py +153 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/exceptions.py +122 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/logfire_setup.py +101 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/middleware.py +99 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/oauth.py +23 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/rate_limit.py +58 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/sanitize.py +271 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/core/security.py +102 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/__init__.py +7 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/base.py +41 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/__init__.py +31 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/conversation.py +319 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/item.py +96 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/session.py +126 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/user.py +218 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/models/webhook.py +244 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/db/session.py +113 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/main.py +326 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/pipelines/__init__.py +9 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/pipelines/base.py +73 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/__init__.py +49 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/base.py +154 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/conversation.py +760 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/item.py +222 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/session.py +318 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/user.py +322 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/repositories/webhook.py +358 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/__init__.py +50 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/base.py +57 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/conversation.py +195 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/item.py +52 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/session.py +42 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/token.py +31 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/user.py +64 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/schemas/webhook.py +89 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/__init__.py +38 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/conversation.py +797 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/item.py +246 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/session.py +333 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/user.py +432 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/services/webhook.py +561 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/__init__.py +5 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/celery_app.py +64 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/taskiq_app.py +38 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/tasks/__init__.py +25 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/tasks/examples.py +106 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/tasks/schedules.py +29 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/app/worker/tasks/taskiq_examples.py +92 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/cli/__init__.py +1 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/cli/commands.py +438 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/pyproject.toml +158 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/scripts/.gitkeep +0 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/__init__.py +1 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/__init__.py +1 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_auth.py +242 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_exceptions.py +151 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_health.py +113 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_items.py +310 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/api/test_users.py +253 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/conftest.py +151 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_agents.py +121 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_clients.py +183 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_commands.py +173 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_core.py +143 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_pipelines.py +118 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_repositories.py +181 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_security.py +124 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_services.py +363 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/backend/tests/test_worker.py +85 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.dev.yml +242 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.frontend.yml +31 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.prod.yml +382 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/docker-compose.yml +241 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/.env.example +12 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/.gitignore +45 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/.prettierignore +19 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/.prettierrc +11 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/Dockerfile +44 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/README.md +693 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/e2e/auth.setup.ts +49 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/e2e/auth.spec.ts +134 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/e2e/chat.spec.ts +207 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/e2e/home.spec.ts +73 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/instrumentation.ts +14 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/messages/en.json +84 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/messages/pl.json +84 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/next.config.ts +76 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/package.json +66 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/playwright.config.ts +101 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/postcss.config.mjs +7 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/(auth)/layout.tsx +11 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/(auth)/login/page.tsx +5 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/(auth)/register/page.tsx +5 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/(dashboard)/chat/page.tsx +20 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/(dashboard)/dashboard/page.tsx +99 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/(dashboard)/layout.tsx +17 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/(dashboard)/profile/page.tsx +156 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/login/route.ts +58 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/logout/route.ts +24 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/me/route.ts +39 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/oauth-callback/route.ts +50 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/refresh/route.ts +54 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/auth/register/route.ts +26 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/conversations/[id]/messages/route.ts +41 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/conversations/[id]/route.ts +108 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/conversations/route.ts +73 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/api/health/route.ts +21 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/auth/callback/page.tsx +96 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/globals.css +108 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/layout.tsx +25 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/page.tsx +73 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/app/providers.tsx +29 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/auth/index.ts +2 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/auth/login-form.tsx +120 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/auth/register-form.tsx +153 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/chat-container.tsx +135 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/chat-input.tsx +73 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/conversation-sidebar.tsx +261 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/index.ts +8 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/message-item.tsx +63 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/message-list.tsx +18 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/tool-call-card.tsx +60 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/icons/google-icon.tsx +32 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/icons/index.ts +3 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/language-switcher.tsx +97 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/layout/header.tsx +45 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/layout/index.ts +2 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/layout/sidebar.tsx +48 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/theme/index.ts +7 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/theme/theme-provider.tsx +53 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/theme/theme-toggle.tsx +83 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/badge.tsx +35 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/button.test.tsx +75 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/button.tsx +54 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/card.tsx +82 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/index.ts +12 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/input.tsx +21 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/ui/label.tsx +21 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/index.ts +6 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/use-auth.ts +97 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/use-chat.ts +203 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/use-conversations.ts +175 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/hooks/use-websocket.ts +105 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/i18n.ts +32 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/api-client.ts +90 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/constants.ts +39 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/server-api.ts +78 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/utils.test.ts +44 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/lib/utils.ts +44 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/middleware.ts +33 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/auth-store.test.ts +72 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/auth-store.ts +48 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/chat-store.ts +65 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/conversation-store.ts +76 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/index.ts +6 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/stores/theme-store.ts +44 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/api.ts +27 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/auth.ts +52 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/chat.ts +81 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/conversation.ts +49 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/types/index.ts +10 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/tsconfig.json +28 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/vitest.config.ts +36 -0
- fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/vitest.setup.ts +56 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import Link from "next/link";
|
|
2
|
+
import { Button, Card, CardHeader, CardTitle, CardContent } from "@/components/ui";
|
|
3
|
+
import { ROUTES } from "@/lib/constants";
|
|
4
|
+
|
|
5
|
+
export default function HomePage() {
|
|
6
|
+
return (
|
|
7
|
+
<div className="min-h-screen bg-background">
|
|
8
|
+
<div className="container mx-auto py-16 px-4">
|
|
9
|
+
<div className="text-center mb-12">
|
|
10
|
+
<h1 className="text-4xl font-bold mb-4">
|
|
11
|
+
{{ cookiecutter.project_name }}
|
|
12
|
+
</h1>
|
|
13
|
+
<p className="text-xl text-muted-foreground max-w-2xl mx-auto">
|
|
14
|
+
{{ cookiecutter.project_description }}
|
|
15
|
+
</p>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3 max-w-5xl mx-auto">
|
|
19
|
+
{% if cookiecutter.use_jwt %}
|
|
20
|
+
<Card>
|
|
21
|
+
<CardHeader>
|
|
22
|
+
<CardTitle>Authentication</CardTitle>
|
|
23
|
+
</CardHeader>
|
|
24
|
+
<CardContent>
|
|
25
|
+
<p className="mb-4 text-muted-foreground">
|
|
26
|
+
Secure JWT-based authentication system
|
|
27
|
+
</p>
|
|
28
|
+
<div className="flex gap-2">
|
|
29
|
+
<Button asChild>
|
|
30
|
+
<Link href={ROUTES.LOGIN}>Login</Link>
|
|
31
|
+
</Button>
|
|
32
|
+
<Button variant="outline" asChild>
|
|
33
|
+
<Link href={ROUTES.REGISTER}>Register</Link>
|
|
34
|
+
</Button>
|
|
35
|
+
</div>
|
|
36
|
+
</CardContent>
|
|
37
|
+
</Card>
|
|
38
|
+
{% endif %}
|
|
39
|
+
|
|
40
|
+
{% if cookiecutter.enable_ai_agent %}
|
|
41
|
+
<Card>
|
|
42
|
+
<CardHeader>
|
|
43
|
+
<CardTitle>AI Assistant</CardTitle>
|
|
44
|
+
</CardHeader>
|
|
45
|
+
<CardContent>
|
|
46
|
+
<p className="mb-4 text-muted-foreground">
|
|
47
|
+
Chat with our AI assistant powered by PydanticAI
|
|
48
|
+
</p>
|
|
49
|
+
<Button asChild>
|
|
50
|
+
<Link href={ROUTES.CHAT}>Start Chat</Link>
|
|
51
|
+
</Button>
|
|
52
|
+
</CardContent>
|
|
53
|
+
</Card>
|
|
54
|
+
{% endif %}
|
|
55
|
+
|
|
56
|
+
<Card>
|
|
57
|
+
<CardHeader>
|
|
58
|
+
<CardTitle>Dashboard</CardTitle>
|
|
59
|
+
</CardHeader>
|
|
60
|
+
<CardContent>
|
|
61
|
+
<p className="mb-4 text-muted-foreground">
|
|
62
|
+
View your dashboard and manage your account
|
|
63
|
+
</p>
|
|
64
|
+
<Button variant="outline" asChild>
|
|
65
|
+
<Link href={ROUTES.DASHBOARD}>Go to Dashboard</Link>
|
|
66
|
+
</Button>
|
|
67
|
+
</CardContent>
|
|
68
|
+
</Card>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
4
|
+
import { useState, type ReactNode } from "react";
|
|
5
|
+
import { ThemeProvider } from "@/components/theme";
|
|
6
|
+
|
|
7
|
+
interface ProvidersProps {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function Providers({ children }: ProvidersProps) {
|
|
12
|
+
const [queryClient] = useState(
|
|
13
|
+
() =>
|
|
14
|
+
new QueryClient({
|
|
15
|
+
defaultOptions: {
|
|
16
|
+
queries: {
|
|
17
|
+
staleTime: 60 * 1000, // 1 minute
|
|
18
|
+
retry: 1,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<QueryClientProvider client={queryClient}>
|
|
26
|
+
<ThemeProvider>{children}</ThemeProvider>
|
|
27
|
+
</QueryClientProvider>
|
|
28
|
+
);
|
|
29
|
+
}
|
fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/auth/login-form.tsx
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { useAuth } from "@/hooks";
|
|
6
|
+
import { Button, Input, Label, Card, CardHeader, CardTitle, CardContent, CardFooter } from "@/components/ui";
|
|
7
|
+
import { ApiError } from "@/lib/api-client";
|
|
8
|
+
import { ROUTES } from "@/lib/constants";
|
|
9
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
10
|
+
import { GoogleIcon } from "@/components/icons/google-icon";
|
|
11
|
+
{%- endif %}
|
|
12
|
+
|
|
13
|
+
export function LoginForm() {
|
|
14
|
+
const { login } = useAuth();
|
|
15
|
+
const [email, setEmail] = useState("");
|
|
16
|
+
const [password, setPassword] = useState("");
|
|
17
|
+
const [error, setError] = useState("");
|
|
18
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
19
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
20
|
+
const [isOAuthLoading, setIsOAuthLoading] = useState(false);
|
|
21
|
+
{%- endif %}
|
|
22
|
+
|
|
23
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
setIsLoading(true);
|
|
26
|
+
setError("");
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
await login({ email, password });
|
|
30
|
+
} catch (err) {
|
|
31
|
+
if (err instanceof ApiError) {
|
|
32
|
+
setError(err.message);
|
|
33
|
+
} else {
|
|
34
|
+
setError("Login failed. Please try again.");
|
|
35
|
+
}
|
|
36
|
+
setIsLoading(false);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
41
|
+
|
|
42
|
+
const handleGoogleLogin = () => {
|
|
43
|
+
setIsOAuthLoading(true);
|
|
44
|
+
// Redirect to backend OAuth endpoint
|
|
45
|
+
window.location.href = `${process.env.NEXT_PUBLIC_API_URL}/api/v1/oauth/google/login`;
|
|
46
|
+
};
|
|
47
|
+
{%- endif %}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Card className="w-full max-w-md mx-auto">
|
|
51
|
+
<CardHeader>
|
|
52
|
+
<CardTitle className="text-2xl text-center">Login</CardTitle>
|
|
53
|
+
</CardHeader>
|
|
54
|
+
<CardContent>
|
|
55
|
+
<form onSubmit={handleSubmit} className="space-y-4">
|
|
56
|
+
<div className="space-y-2">
|
|
57
|
+
<Label htmlFor="email">Email</Label>
|
|
58
|
+
<Input
|
|
59
|
+
id="email"
|
|
60
|
+
type="email"
|
|
61
|
+
placeholder="you@example.com"
|
|
62
|
+
value={email}
|
|
63
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
64
|
+
required
|
|
65
|
+
disabled={isLoading}
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
<div className="space-y-2">
|
|
69
|
+
<Label htmlFor="password">Password</Label>
|
|
70
|
+
<Input
|
|
71
|
+
id="password"
|
|
72
|
+
type="password"
|
|
73
|
+
value={password}
|
|
74
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
75
|
+
required
|
|
76
|
+
disabled={isLoading}
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
{error && (
|
|
80
|
+
<p className="text-sm text-destructive">{error}</p>
|
|
81
|
+
)}
|
|
82
|
+
<Button type="submit" className="w-full" disabled={isLoading}>
|
|
83
|
+
{isLoading ? "Logging in..." : "Login"}
|
|
84
|
+
</Button>
|
|
85
|
+
</form>
|
|
86
|
+
|
|
87
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
88
|
+
|
|
89
|
+
<div className="relative my-6">
|
|
90
|
+
<div className="absolute inset-0 flex items-center">
|
|
91
|
+
<span className="w-full border-t" />
|
|
92
|
+
</div>
|
|
93
|
+
<div className="relative flex justify-center text-xs uppercase">
|
|
94
|
+
<span className="bg-card px-2 text-muted-foreground">Or continue with</span>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<Button
|
|
99
|
+
type="button"
|
|
100
|
+
variant="outline"
|
|
101
|
+
className="w-full"
|
|
102
|
+
onClick={handleGoogleLogin}
|
|
103
|
+
disabled={isOAuthLoading || isLoading}
|
|
104
|
+
>
|
|
105
|
+
<GoogleIcon className="mr-2 h-4 w-4" />
|
|
106
|
+
{isOAuthLoading ? "Redirecting..." : "Continue with Google"}
|
|
107
|
+
</Button>
|
|
108
|
+
{%- endif %}
|
|
109
|
+
</CardContent>
|
|
110
|
+
<CardFooter className="justify-center">
|
|
111
|
+
<p className="text-sm text-muted-foreground">
|
|
112
|
+
Don't have an account?{" "}
|
|
113
|
+
<Link href={ROUTES.REGISTER} className="text-primary hover:underline">
|
|
114
|
+
Register
|
|
115
|
+
</Link>
|
|
116
|
+
</p>
|
|
117
|
+
</CardFooter>
|
|
118
|
+
</Card>
|
|
119
|
+
);
|
|
120
|
+
}
|
fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/auth/register-form.tsx
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { useRouter } from "next/navigation";
|
|
6
|
+
import { useAuth } from "@/hooks";
|
|
7
|
+
import { Button, Input, Label, Card, CardHeader, CardTitle, CardContent, CardFooter } from "@/components/ui";
|
|
8
|
+
import { ApiError } from "@/lib/api-client";
|
|
9
|
+
import { ROUTES } from "@/lib/constants";
|
|
10
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
11
|
+
import { GoogleIcon } from "@/components/icons/google-icon";
|
|
12
|
+
{%- endif %}
|
|
13
|
+
|
|
14
|
+
export function RegisterForm() {
|
|
15
|
+
const router = useRouter();
|
|
16
|
+
const { register } = useAuth();
|
|
17
|
+
const [email, setEmail] = useState("");
|
|
18
|
+
const [password, setPassword] = useState("");
|
|
19
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
20
|
+
const [name, setName] = useState("");
|
|
21
|
+
const [error, setError] = useState("");
|
|
22
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
23
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
24
|
+
const [isOAuthLoading, setIsOAuthLoading] = useState(false);
|
|
25
|
+
{%- endif %}
|
|
26
|
+
|
|
27
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
setError("");
|
|
30
|
+
|
|
31
|
+
if (password !== confirmPassword) {
|
|
32
|
+
setError("Passwords do not match");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setIsLoading(true);
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
await register({ email, password, name: name || undefined });
|
|
40
|
+
router.push(ROUTES.LOGIN + "?registered=true");
|
|
41
|
+
} catch (err) {
|
|
42
|
+
if (err instanceof ApiError) {
|
|
43
|
+
setError(err.message);
|
|
44
|
+
} else {
|
|
45
|
+
setError("Registration failed. Please try again.");
|
|
46
|
+
}
|
|
47
|
+
} finally {
|
|
48
|
+
setIsLoading(false);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
53
|
+
|
|
54
|
+
const handleGoogleSignUp = () => {
|
|
55
|
+
setIsOAuthLoading(true);
|
|
56
|
+
// Redirect to backend OAuth endpoint
|
|
57
|
+
window.location.href = `${process.env.NEXT_PUBLIC_API_URL}/api/v1/oauth/google/login`;
|
|
58
|
+
};
|
|
59
|
+
{%- endif %}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Card className="w-full max-w-md mx-auto">
|
|
63
|
+
<CardHeader>
|
|
64
|
+
<CardTitle className="text-2xl text-center">Create Account</CardTitle>
|
|
65
|
+
</CardHeader>
|
|
66
|
+
<CardContent>
|
|
67
|
+
{%- if cookiecutter.enable_oauth_google %}
|
|
68
|
+
<Button
|
|
69
|
+
type="button"
|
|
70
|
+
variant="outline"
|
|
71
|
+
className="w-full mb-6"
|
|
72
|
+
onClick={handleGoogleSignUp}
|
|
73
|
+
disabled={isOAuthLoading || isLoading}
|
|
74
|
+
>
|
|
75
|
+
<GoogleIcon className="mr-2 h-4 w-4" />
|
|
76
|
+
{isOAuthLoading ? "Redirecting..." : "Sign up with Google"}
|
|
77
|
+
</Button>
|
|
78
|
+
|
|
79
|
+
<div className="relative mb-6">
|
|
80
|
+
<div className="absolute inset-0 flex items-center">
|
|
81
|
+
<span className="w-full border-t" />
|
|
82
|
+
</div>
|
|
83
|
+
<div className="relative flex justify-center text-xs uppercase">
|
|
84
|
+
<span className="bg-card px-2 text-muted-foreground">Or register with email</span>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
{%- endif %}
|
|
88
|
+
|
|
89
|
+
<form onSubmit={handleSubmit} className="space-y-4">
|
|
90
|
+
<div className="space-y-2">
|
|
91
|
+
<Label htmlFor="name">Name (optional)</Label>
|
|
92
|
+
<Input
|
|
93
|
+
id="name"
|
|
94
|
+
type="text"
|
|
95
|
+
placeholder="John Doe"
|
|
96
|
+
value={name}
|
|
97
|
+
onChange={(e) => setName(e.target.value)}
|
|
98
|
+
disabled={isLoading}
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
<div className="space-y-2">
|
|
102
|
+
<Label htmlFor="email">Email</Label>
|
|
103
|
+
<Input
|
|
104
|
+
id="email"
|
|
105
|
+
type="email"
|
|
106
|
+
placeholder="you@example.com"
|
|
107
|
+
value={email}
|
|
108
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
109
|
+
required
|
|
110
|
+
disabled={isLoading}
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
<div className="space-y-2">
|
|
114
|
+
<Label htmlFor="password">Password</Label>
|
|
115
|
+
<Input
|
|
116
|
+
id="password"
|
|
117
|
+
type="password"
|
|
118
|
+
value={password}
|
|
119
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
120
|
+
required
|
|
121
|
+
disabled={isLoading}
|
|
122
|
+
/>
|
|
123
|
+
</div>
|
|
124
|
+
<div className="space-y-2">
|
|
125
|
+
<Label htmlFor="confirmPassword">Confirm Password</Label>
|
|
126
|
+
<Input
|
|
127
|
+
id="confirmPassword"
|
|
128
|
+
type="password"
|
|
129
|
+
value={confirmPassword}
|
|
130
|
+
onChange={(e) => setConfirmPassword(e.target.value)}
|
|
131
|
+
required
|
|
132
|
+
disabled={isLoading}
|
|
133
|
+
/>
|
|
134
|
+
</div>
|
|
135
|
+
{error && (
|
|
136
|
+
<p className="text-sm text-destructive">{error}</p>
|
|
137
|
+
)}
|
|
138
|
+
<Button type="submit" className="w-full" disabled={isLoading}>
|
|
139
|
+
{isLoading ? "Creating account..." : "Register"}
|
|
140
|
+
</Button>
|
|
141
|
+
</form>
|
|
142
|
+
</CardContent>
|
|
143
|
+
<CardFooter className="justify-center">
|
|
144
|
+
<p className="text-sm text-muted-foreground">
|
|
145
|
+
Already have an account?{" "}
|
|
146
|
+
<Link href={ROUTES.LOGIN} className="text-primary hover:underline">
|
|
147
|
+
Login
|
|
148
|
+
</Link>
|
|
149
|
+
</p>
|
|
150
|
+
</CardFooter>
|
|
151
|
+
</Card>
|
|
152
|
+
);
|
|
153
|
+
}
|
fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/chat-container.tsx
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useCallback } from "react";
|
|
4
|
+
import { useChat } from "@/hooks";
|
|
5
|
+
import { MessageList } from "./message-list";
|
|
6
|
+
import { ChatInput } from "./chat-input";
|
|
7
|
+
import { Button } from "@/components/ui";
|
|
8
|
+
import { Wifi, WifiOff, RotateCcw, Bot } from "lucide-react";
|
|
9
|
+
{%- if cookiecutter.enable_conversation_persistence and cookiecutter.use_database %}
|
|
10
|
+
import { useConversationStore, useChatStore } from "@/stores";
|
|
11
|
+
import { useConversations } from "@/hooks";
|
|
12
|
+
{%- endif %}
|
|
13
|
+
|
|
14
|
+
export function ChatContainer() {
|
|
15
|
+
{%- if cookiecutter.enable_conversation_persistence and cookiecutter.use_database %}
|
|
16
|
+
const { currentConversationId, currentMessages } = useConversationStore();
|
|
17
|
+
const { addMessage: addChatMessage } = useChatStore();
|
|
18
|
+
const { fetchConversations } = useConversations();
|
|
19
|
+
|
|
20
|
+
// Load history when conversation changes
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (currentMessages.length > 0) {
|
|
23
|
+
// Convert stored messages to chat messages format
|
|
24
|
+
currentMessages.forEach((msg) => {
|
|
25
|
+
addChatMessage({
|
|
26
|
+
id: msg.id,
|
|
27
|
+
role: msg.role,
|
|
28
|
+
content: msg.content,
|
|
29
|
+
timestamp: new Date(msg.created_at),
|
|
30
|
+
toolCalls: msg.tool_calls?.map((tc) => ({
|
|
31
|
+
id: tc.tool_call_id,
|
|
32
|
+
name: tc.tool_name,
|
|
33
|
+
args: tc.args,
|
|
34
|
+
result: tc.result,
|
|
35
|
+
status: tc.status === "failed" ? "error" : tc.status,
|
|
36
|
+
})),
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}, [currentMessages, addChatMessage]);
|
|
41
|
+
|
|
42
|
+
const handleConversationCreated = useCallback((conversationId: string) => {
|
|
43
|
+
// Refresh conversation list when a new conversation is created
|
|
44
|
+
fetchConversations();
|
|
45
|
+
}, [fetchConversations]);
|
|
46
|
+
|
|
47
|
+
const {
|
|
48
|
+
messages,
|
|
49
|
+
isConnected,
|
|
50
|
+
isProcessing,
|
|
51
|
+
connect,
|
|
52
|
+
disconnect,
|
|
53
|
+
sendMessage,
|
|
54
|
+
clearMessages,
|
|
55
|
+
} = useChat({
|
|
56
|
+
conversationId: currentConversationId,
|
|
57
|
+
onConversationCreated: handleConversationCreated,
|
|
58
|
+
});
|
|
59
|
+
{%- else %}
|
|
60
|
+
const {
|
|
61
|
+
messages,
|
|
62
|
+
isConnected,
|
|
63
|
+
isProcessing,
|
|
64
|
+
connect,
|
|
65
|
+
disconnect,
|
|
66
|
+
sendMessage,
|
|
67
|
+
clearMessages,
|
|
68
|
+
} = useChat();
|
|
69
|
+
{%- endif %}
|
|
70
|
+
|
|
71
|
+
const messagesEndRef = useRef<HTMLDivElement>(null);
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
connect();
|
|
75
|
+
return () => disconnect();
|
|
76
|
+
}, [connect, disconnect]);
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
80
|
+
}, [messages]);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<div className="flex flex-col h-full max-w-4xl mx-auto">
|
|
84
|
+
{/* Messages */}
|
|
85
|
+
<div className="flex-1 overflow-y-auto px-4 py-6 scrollbar-thin">
|
|
86
|
+
{messages.length === 0 ? (
|
|
87
|
+
<div className="flex flex-col items-center justify-center h-full text-muted-foreground gap-4">
|
|
88
|
+
<div className="w-16 h-16 rounded-full bg-secondary flex items-center justify-center">
|
|
89
|
+
<Bot className="h-8 w-8" />
|
|
90
|
+
</div>
|
|
91
|
+
<div className="text-center">
|
|
92
|
+
<p className="text-lg font-medium text-foreground">AI Assistant</p>
|
|
93
|
+
<p className="text-sm">Start a conversation to get help</p>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
) : (
|
|
97
|
+
<MessageList messages={messages} />
|
|
98
|
+
)}
|
|
99
|
+
<div ref={messagesEndRef} />
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
{/* Input area */}
|
|
103
|
+
<div className="px-4 pb-6">
|
|
104
|
+
<div className="rounded-xl border bg-card shadow-sm p-4">
|
|
105
|
+
<ChatInput
|
|
106
|
+
onSend={sendMessage}
|
|
107
|
+
disabled={!isConnected || isProcessing}
|
|
108
|
+
isProcessing={isProcessing}
|
|
109
|
+
/>
|
|
110
|
+
<div className="flex items-center justify-between mt-3 pt-3 border-t">
|
|
111
|
+
<div className="flex items-center gap-2">
|
|
112
|
+
{isConnected ? (
|
|
113
|
+
<Wifi className="h-3.5 w-3.5 text-green-500" />
|
|
114
|
+
) : (
|
|
115
|
+
<WifiOff className="h-3.5 w-3.5 text-red-500" />
|
|
116
|
+
)}
|
|
117
|
+
<span className="text-xs text-muted-foreground">
|
|
118
|
+
{isConnected ? "Connected" : "Disconnected"}
|
|
119
|
+
</span>
|
|
120
|
+
</div>
|
|
121
|
+
<Button
|
|
122
|
+
variant="ghost"
|
|
123
|
+
size="sm"
|
|
124
|
+
onClick={clearMessages}
|
|
125
|
+
className="text-xs h-7 px-2"
|
|
126
|
+
>
|
|
127
|
+
<RotateCcw className="h-3 w-3 mr-1.5" />
|
|
128
|
+
Reset
|
|
129
|
+
</Button>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
}
|
fastapi_gen/template/{{cookiecutter.project_slug}}/frontend/src/components/chat/chat-input.tsx
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useRef, useEffect } from "react";
|
|
4
|
+
import { Button } from "@/components/ui";
|
|
5
|
+
import { Send, Loader2 } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
interface ChatInputProps {
|
|
8
|
+
onSend: (message: string) => void;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
isProcessing?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function ChatInput({ onSend, disabled, isProcessing }: ChatInputProps) {
|
|
14
|
+
const [message, setMessage] = useState("");
|
|
15
|
+
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!isProcessing && textareaRef.current) {
|
|
19
|
+
textareaRef.current.focus();
|
|
20
|
+
}
|
|
21
|
+
}, [isProcessing]);
|
|
22
|
+
|
|
23
|
+
// Auto-resize textarea
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (textareaRef.current) {
|
|
26
|
+
textareaRef.current.style.height = "auto";
|
|
27
|
+
textareaRef.current.style.height = `${Math.min(textareaRef.current.scrollHeight, 200)}px`;
|
|
28
|
+
}
|
|
29
|
+
}, [message]);
|
|
30
|
+
|
|
31
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
if (message.trim() && !disabled) {
|
|
34
|
+
onSend(message.trim());
|
|
35
|
+
setMessage("");
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
40
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
handleSubmit(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<form onSubmit={handleSubmit} className="relative">
|
|
48
|
+
<textarea
|
|
49
|
+
ref={textareaRef}
|
|
50
|
+
value={message}
|
|
51
|
+
onChange={(e) => setMessage(e.target.value)}
|
|
52
|
+
onKeyDown={handleKeyDown}
|
|
53
|
+
placeholder="Type a command or request..."
|
|
54
|
+
disabled={disabled}
|
|
55
|
+
rows={1}
|
|
56
|
+
className="w-full resize-none bg-transparent pr-12 text-sm placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
|
|
57
|
+
/>
|
|
58
|
+
<Button
|
|
59
|
+
type="submit"
|
|
60
|
+
size="icon"
|
|
61
|
+
disabled={disabled || !message.trim()}
|
|
62
|
+
className="absolute right-0 top-0 h-8 w-8 rounded-lg"
|
|
63
|
+
>
|
|
64
|
+
{isProcessing ? (
|
|
65
|
+
<Loader2 className="h-4 w-4 animate-spin" />
|
|
66
|
+
) : (
|
|
67
|
+
<Send className="h-4 w-4" />
|
|
68
|
+
)}
|
|
69
|
+
<span className="sr-only">Send message</span>
|
|
70
|
+
</Button>
|
|
71
|
+
</form>
|
|
72
|
+
);
|
|
73
|
+
}
|