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
fastapi_gen/config.py
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"""Configuration models for project generation."""
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field, computed_field
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DatabaseType(str, Enum):
|
|
10
|
+
"""Supported database types."""
|
|
11
|
+
|
|
12
|
+
POSTGRESQL = "postgresql"
|
|
13
|
+
MONGODB = "mongodb"
|
|
14
|
+
SQLITE = "sqlite"
|
|
15
|
+
NONE = "none"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class AuthType(str, Enum):
|
|
19
|
+
"""Supported authentication types."""
|
|
20
|
+
|
|
21
|
+
JWT = "jwt"
|
|
22
|
+
API_KEY = "api_key"
|
|
23
|
+
BOTH = "both"
|
|
24
|
+
NONE = "none"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class BackgroundTaskType(str, Enum):
|
|
28
|
+
"""Supported background task systems."""
|
|
29
|
+
|
|
30
|
+
NONE = "none"
|
|
31
|
+
CELERY = "celery"
|
|
32
|
+
TASKIQ = "taskiq"
|
|
33
|
+
ARQ = "arq"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class CIType(str, Enum):
|
|
37
|
+
"""Supported CI/CD systems."""
|
|
38
|
+
|
|
39
|
+
GITHUB = "github"
|
|
40
|
+
GITLAB = "gitlab"
|
|
41
|
+
NONE = "none"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class FrontendType(str, Enum):
|
|
45
|
+
"""Supported frontend frameworks."""
|
|
46
|
+
|
|
47
|
+
NONE = "none"
|
|
48
|
+
NEXTJS = "nextjs"
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class WebSocketAuthType(str, Enum):
|
|
52
|
+
"""WebSocket authentication types for AI Agent."""
|
|
53
|
+
|
|
54
|
+
NONE = "none"
|
|
55
|
+
JWT = "jwt"
|
|
56
|
+
API_KEY = "api_key"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class AdminEnvironmentType(str, Enum):
|
|
60
|
+
"""Admin panel environment restriction types."""
|
|
61
|
+
|
|
62
|
+
ALL = "all" # Available in all environments
|
|
63
|
+
DEV_ONLY = "dev_only" # Only in development
|
|
64
|
+
DEV_STAGING = "dev_staging" # Development + Staging (recommended)
|
|
65
|
+
DISABLED = "disabled" # Disabled everywhere
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class OAuthProvider(str, Enum):
|
|
69
|
+
"""Supported OAuth2 providers."""
|
|
70
|
+
|
|
71
|
+
NONE = "none"
|
|
72
|
+
GOOGLE = "google"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class LogfireFeatures(BaseModel):
|
|
76
|
+
"""Logfire instrumentation features."""
|
|
77
|
+
|
|
78
|
+
fastapi: bool = True
|
|
79
|
+
database: bool = True
|
|
80
|
+
redis: bool = False
|
|
81
|
+
celery: bool = False
|
|
82
|
+
httpx: bool = False
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class ProjectConfig(BaseModel):
|
|
86
|
+
"""Full project configuration."""
|
|
87
|
+
|
|
88
|
+
# Basic info
|
|
89
|
+
project_name: str = Field(..., min_length=1, pattern=r"^[a-z][a-z0-9_]*$")
|
|
90
|
+
project_description: str = "A FastAPI project"
|
|
91
|
+
|
|
92
|
+
author_name: str = "Your Name"
|
|
93
|
+
author_email: str = "your@email.com"
|
|
94
|
+
|
|
95
|
+
# Database
|
|
96
|
+
database: DatabaseType = DatabaseType.POSTGRESQL
|
|
97
|
+
db_pool_size: int = 5
|
|
98
|
+
db_max_overflow: int = 10
|
|
99
|
+
db_pool_timeout: int = 30
|
|
100
|
+
|
|
101
|
+
# Authentication
|
|
102
|
+
auth: AuthType = AuthType.JWT
|
|
103
|
+
oauth_provider: OAuthProvider = OAuthProvider.NONE
|
|
104
|
+
enable_session_management: bool = False
|
|
105
|
+
|
|
106
|
+
# Observability
|
|
107
|
+
enable_logfire: bool = True
|
|
108
|
+
logfire_features: LogfireFeatures = Field(default_factory=LogfireFeatures)
|
|
109
|
+
|
|
110
|
+
# Background tasks
|
|
111
|
+
background_tasks: BackgroundTaskType = BackgroundTaskType.NONE
|
|
112
|
+
|
|
113
|
+
# Optional integrations
|
|
114
|
+
enable_redis: bool = False
|
|
115
|
+
enable_caching: bool = False
|
|
116
|
+
enable_rate_limiting: bool = False
|
|
117
|
+
rate_limit_requests: int = 100
|
|
118
|
+
rate_limit_period: int = 60
|
|
119
|
+
enable_pagination: bool = True
|
|
120
|
+
enable_sentry: bool = False
|
|
121
|
+
enable_prometheus: bool = False
|
|
122
|
+
enable_admin_panel: bool = False
|
|
123
|
+
admin_environments: AdminEnvironmentType = AdminEnvironmentType.DEV_STAGING
|
|
124
|
+
admin_require_auth: bool = True
|
|
125
|
+
enable_websockets: bool = False
|
|
126
|
+
enable_file_storage: bool = False
|
|
127
|
+
enable_ai_agent: bool = False
|
|
128
|
+
enable_conversation_persistence: bool = False
|
|
129
|
+
enable_webhooks: bool = False
|
|
130
|
+
websocket_auth: WebSocketAuthType = WebSocketAuthType.NONE
|
|
131
|
+
enable_cors: bool = True
|
|
132
|
+
enable_orjson: bool = True
|
|
133
|
+
|
|
134
|
+
# Frontend features
|
|
135
|
+
enable_i18n: bool = False
|
|
136
|
+
|
|
137
|
+
# Example CRUD
|
|
138
|
+
include_example_crud: bool = True
|
|
139
|
+
|
|
140
|
+
# Dev tools
|
|
141
|
+
enable_pytest: bool = True
|
|
142
|
+
enable_precommit: bool = True
|
|
143
|
+
enable_makefile: bool = True
|
|
144
|
+
enable_docker: bool = True
|
|
145
|
+
ci_type: CIType = CIType.GITHUB
|
|
146
|
+
enable_kubernetes: bool = False
|
|
147
|
+
generate_env: bool = True
|
|
148
|
+
|
|
149
|
+
# Python version
|
|
150
|
+
python_version: str = "3.12"
|
|
151
|
+
|
|
152
|
+
# Frontend
|
|
153
|
+
frontend: FrontendType = FrontendType.NONE
|
|
154
|
+
frontend_port: int = 3000
|
|
155
|
+
|
|
156
|
+
# Backend
|
|
157
|
+
backend_port: int = 8000
|
|
158
|
+
|
|
159
|
+
@computed_field
|
|
160
|
+
@property
|
|
161
|
+
def project_slug(self) -> str:
|
|
162
|
+
"""Return project slug (underscores instead of hyphens)."""
|
|
163
|
+
return self.project_name.replace("-", "_")
|
|
164
|
+
|
|
165
|
+
def to_cookiecutter_context(self) -> dict[str, Any]:
|
|
166
|
+
"""Convert config to cookiecutter context."""
|
|
167
|
+
return {
|
|
168
|
+
"project_name": self.project_name,
|
|
169
|
+
"project_slug": self.project_slug,
|
|
170
|
+
"project_description": self.project_description,
|
|
171
|
+
"author_name": self.author_name,
|
|
172
|
+
"author_email": self.author_email,
|
|
173
|
+
# Database
|
|
174
|
+
"database": self.database.value,
|
|
175
|
+
"use_postgresql": self.database == DatabaseType.POSTGRESQL,
|
|
176
|
+
"use_mongodb": self.database == DatabaseType.MONGODB,
|
|
177
|
+
"use_sqlite": self.database == DatabaseType.SQLITE,
|
|
178
|
+
"use_database": self.database != DatabaseType.NONE,
|
|
179
|
+
"db_pool_size": self.db_pool_size,
|
|
180
|
+
"db_max_overflow": self.db_max_overflow,
|
|
181
|
+
"db_pool_timeout": self.db_pool_timeout,
|
|
182
|
+
# Auth
|
|
183
|
+
"auth": self.auth.value,
|
|
184
|
+
"use_jwt": self.auth in (AuthType.JWT, AuthType.BOTH),
|
|
185
|
+
"use_api_key": self.auth in (AuthType.API_KEY, AuthType.BOTH),
|
|
186
|
+
"use_auth": self.auth != AuthType.NONE,
|
|
187
|
+
# OAuth
|
|
188
|
+
"oauth_provider": self.oauth_provider.value,
|
|
189
|
+
"enable_oauth": self.oauth_provider != OAuthProvider.NONE,
|
|
190
|
+
"enable_oauth_google": self.oauth_provider == OAuthProvider.GOOGLE,
|
|
191
|
+
# Session Management
|
|
192
|
+
"enable_session_management": self.enable_session_management,
|
|
193
|
+
# Logfire
|
|
194
|
+
"enable_logfire": self.enable_logfire,
|
|
195
|
+
"logfire_fastapi": self.logfire_features.fastapi,
|
|
196
|
+
"logfire_database": self.logfire_features.database,
|
|
197
|
+
"logfire_redis": self.logfire_features.redis,
|
|
198
|
+
"logfire_celery": self.logfire_features.celery,
|
|
199
|
+
"logfire_httpx": self.logfire_features.httpx,
|
|
200
|
+
# Background tasks
|
|
201
|
+
"background_tasks": self.background_tasks.value,
|
|
202
|
+
"use_celery": self.background_tasks == BackgroundTaskType.CELERY,
|
|
203
|
+
"use_taskiq": self.background_tasks == BackgroundTaskType.TASKIQ,
|
|
204
|
+
"use_arq": self.background_tasks == BackgroundTaskType.ARQ,
|
|
205
|
+
# Integrations
|
|
206
|
+
"enable_redis": self.enable_redis,
|
|
207
|
+
"enable_caching": self.enable_caching,
|
|
208
|
+
"enable_rate_limiting": self.enable_rate_limiting,
|
|
209
|
+
"rate_limit_requests": self.rate_limit_requests,
|
|
210
|
+
"rate_limit_period": self.rate_limit_period,
|
|
211
|
+
"enable_pagination": self.enable_pagination,
|
|
212
|
+
"enable_sentry": self.enable_sentry,
|
|
213
|
+
"enable_prometheus": self.enable_prometheus,
|
|
214
|
+
"enable_admin_panel": self.enable_admin_panel,
|
|
215
|
+
"admin_environments": self.admin_environments.value,
|
|
216
|
+
"admin_env_all": self.admin_environments == AdminEnvironmentType.ALL,
|
|
217
|
+
"admin_env_dev_only": self.admin_environments == AdminEnvironmentType.DEV_ONLY,
|
|
218
|
+
"admin_env_dev_staging": self.admin_environments == AdminEnvironmentType.DEV_STAGING,
|
|
219
|
+
"admin_env_disabled": self.admin_environments == AdminEnvironmentType.DISABLED,
|
|
220
|
+
"admin_require_auth": self.admin_require_auth,
|
|
221
|
+
"enable_websockets": self.enable_websockets,
|
|
222
|
+
"enable_file_storage": self.enable_file_storage,
|
|
223
|
+
"enable_ai_agent": self.enable_ai_agent,
|
|
224
|
+
"enable_conversation_persistence": self.enable_conversation_persistence,
|
|
225
|
+
"enable_webhooks": self.enable_webhooks,
|
|
226
|
+
"websocket_auth": self.websocket_auth.value,
|
|
227
|
+
"websocket_auth_jwt": self.websocket_auth == WebSocketAuthType.JWT,
|
|
228
|
+
"websocket_auth_api_key": self.websocket_auth == WebSocketAuthType.API_KEY,
|
|
229
|
+
"websocket_auth_none": self.websocket_auth == WebSocketAuthType.NONE,
|
|
230
|
+
"enable_cors": self.enable_cors,
|
|
231
|
+
"enable_orjson": self.enable_orjson,
|
|
232
|
+
# Frontend features
|
|
233
|
+
"enable_i18n": self.enable_i18n,
|
|
234
|
+
# Example CRUD
|
|
235
|
+
"include_example_crud": self.include_example_crud,
|
|
236
|
+
# Dev tools
|
|
237
|
+
"enable_pytest": self.enable_pytest,
|
|
238
|
+
"enable_precommit": self.enable_precommit,
|
|
239
|
+
"enable_makefile": self.enable_makefile,
|
|
240
|
+
"enable_docker": self.enable_docker,
|
|
241
|
+
"ci_type": self.ci_type.value,
|
|
242
|
+
"use_github_actions": self.ci_type == CIType.GITHUB,
|
|
243
|
+
"use_gitlab_ci": self.ci_type == CIType.GITLAB,
|
|
244
|
+
"enable_kubernetes": self.enable_kubernetes,
|
|
245
|
+
"generate_env": self.generate_env,
|
|
246
|
+
# Python version
|
|
247
|
+
"python_version": self.python_version,
|
|
248
|
+
# Frontend
|
|
249
|
+
"frontend": self.frontend.value,
|
|
250
|
+
"use_frontend": self.frontend != FrontendType.NONE,
|
|
251
|
+
"use_nextjs": self.frontend == FrontendType.NEXTJS,
|
|
252
|
+
"frontend_port": self.frontend_port,
|
|
253
|
+
# Backend
|
|
254
|
+
"backend_port": self.backend_port,
|
|
255
|
+
}
|
fastapi_gen/generator.py
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"""Project generation logic."""
|
|
2
|
+
|
|
3
|
+
import shutil
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from cookiecutter.main import cookiecutter
|
|
7
|
+
from rich.console import Console
|
|
8
|
+
from rich.progress import Progress, SpinnerColumn, TextColumn
|
|
9
|
+
|
|
10
|
+
from .config import FrontendType, ProjectConfig
|
|
11
|
+
|
|
12
|
+
console = Console()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _find_template_dir() -> Path:
|
|
16
|
+
"""Find the template directory.
|
|
17
|
+
|
|
18
|
+
Works both in development (template at project root) and when installed
|
|
19
|
+
(template bundled inside the package).
|
|
20
|
+
"""
|
|
21
|
+
# Development: template is at project root (sibling to fastapi_gen/)
|
|
22
|
+
dev_path = Path(__file__).parent.parent / "template"
|
|
23
|
+
if dev_path.exists() and (dev_path / "cookiecutter.json").exists():
|
|
24
|
+
return dev_path
|
|
25
|
+
|
|
26
|
+
# Installed: template is inside the package
|
|
27
|
+
installed_path = Path(__file__).parent / "template"
|
|
28
|
+
if installed_path.exists() and (installed_path / "cookiecutter.json").exists():
|
|
29
|
+
return installed_path
|
|
30
|
+
|
|
31
|
+
raise FileNotFoundError(
|
|
32
|
+
"Could not find cookiecutter template. "
|
|
33
|
+
"Expected at 'template/' (development) or 'fastapi_gen/template/' (installed)."
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
TEMPLATE_DIR = _find_template_dir()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_template_path() -> str:
|
|
41
|
+
"""Get the path to the cookiecutter template."""
|
|
42
|
+
return str(TEMPLATE_DIR)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def generate_project(config: ProjectConfig, output_dir: Path | None = None) -> Path:
|
|
46
|
+
"""Generate a new FastAPI project from configuration.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
config: Project configuration
|
|
50
|
+
output_dir: Output directory (defaults to current directory)
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
Path to the generated project
|
|
54
|
+
|
|
55
|
+
Raises:
|
|
56
|
+
ValueError: If target directory exists and is not empty
|
|
57
|
+
"""
|
|
58
|
+
if output_dir is None:
|
|
59
|
+
output_dir = Path.cwd()
|
|
60
|
+
|
|
61
|
+
# Check if target directory already exists and is not empty
|
|
62
|
+
target_dir = output_dir / config.project_slug
|
|
63
|
+
if target_dir.exists() and any(target_dir.iterdir()):
|
|
64
|
+
raise ValueError(f"Directory '{target_dir}' already exists and is not empty")
|
|
65
|
+
|
|
66
|
+
context = config.to_cookiecutter_context()
|
|
67
|
+
template_path = get_template_path()
|
|
68
|
+
|
|
69
|
+
with Progress(
|
|
70
|
+
SpinnerColumn(),
|
|
71
|
+
TextColumn("[progress.description]{task.description}"),
|
|
72
|
+
console=console,
|
|
73
|
+
) as progress:
|
|
74
|
+
progress.add_task(description="Generating project...", total=None)
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
# Generate project using cookiecutter
|
|
78
|
+
project_path = cookiecutter(
|
|
79
|
+
template_path,
|
|
80
|
+
extra_context=context,
|
|
81
|
+
output_dir=str(output_dir),
|
|
82
|
+
no_input=True,
|
|
83
|
+
)
|
|
84
|
+
except Exception:
|
|
85
|
+
# Cleanup partial files on failure
|
|
86
|
+
if target_dir.exists():
|
|
87
|
+
shutil.rmtree(target_dir)
|
|
88
|
+
raise
|
|
89
|
+
|
|
90
|
+
return Path(project_path)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def post_generation_tasks(project_path: Path, config: ProjectConfig) -> None:
|
|
94
|
+
"""Run post-generation tasks.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
project_path: Path to the generated project
|
|
98
|
+
config: Project configuration
|
|
99
|
+
"""
|
|
100
|
+
console.print()
|
|
101
|
+
console.print(f"[bold green]Project created at:[/] {project_path}")
|
|
102
|
+
console.print()
|
|
103
|
+
console.print("[bold cyan]Next steps:[/]")
|
|
104
|
+
console.print()
|
|
105
|
+
console.print(f" cd {project_path.name}")
|
|
106
|
+
|
|
107
|
+
step = 1
|
|
108
|
+
if config.frontend != FrontendType.NONE:
|
|
109
|
+
# Full-stack project
|
|
110
|
+
console.print()
|
|
111
|
+
if config.generate_env:
|
|
112
|
+
console.print(f"[bold]{step}. Environment:[/]")
|
|
113
|
+
console.print(" .env files are pre-configured for development")
|
|
114
|
+
console.print(" # Review and update settings as needed")
|
|
115
|
+
else:
|
|
116
|
+
console.print(f"[bold]{step}. Configure environment:[/]")
|
|
117
|
+
console.print(" cp backend/.env.example backend/.env")
|
|
118
|
+
console.print(" cp frontend/.env.example frontend/.env.local")
|
|
119
|
+
console.print(" # Edit with your settings (database, secrets, etc.)")
|
|
120
|
+
step += 1
|
|
121
|
+
console.print()
|
|
122
|
+
console.print(f"[bold]{step}. Install backend dependencies:[/]")
|
|
123
|
+
console.print(" make install")
|
|
124
|
+
step += 1
|
|
125
|
+
if config.database.value != "none":
|
|
126
|
+
console.print()
|
|
127
|
+
console.print(f"[bold]{step}. Database setup:[/]")
|
|
128
|
+
console.print(" make docker-db # Start PostgreSQL")
|
|
129
|
+
console.print(" make db-migrate # Create initial migration")
|
|
130
|
+
console.print(" make db-upgrade # Apply migrations")
|
|
131
|
+
step += 1
|
|
132
|
+
console.print()
|
|
133
|
+
console.print(f"[bold]{step}. Run backend:[/]")
|
|
134
|
+
console.print(" make run")
|
|
135
|
+
step += 1
|
|
136
|
+
console.print()
|
|
137
|
+
console.print(f"[bold]{step}. Frontend setup (in new terminal):[/]")
|
|
138
|
+
console.print(" cd frontend")
|
|
139
|
+
console.print(" bun install")
|
|
140
|
+
console.print(" bun run dev")
|
|
141
|
+
else:
|
|
142
|
+
# Backend-only project
|
|
143
|
+
console.print()
|
|
144
|
+
if config.generate_env:
|
|
145
|
+
console.print(f"[bold]{step}. Environment:[/]")
|
|
146
|
+
console.print(" .env file is pre-configured for development")
|
|
147
|
+
console.print(" # Review and update settings as needed")
|
|
148
|
+
else:
|
|
149
|
+
console.print(f"[bold]{step}. Configure environment:[/]")
|
|
150
|
+
console.print(" cd backend && cp .env.example .env")
|
|
151
|
+
console.print(" # Edit .env with your settings")
|
|
152
|
+
step += 1
|
|
153
|
+
console.print()
|
|
154
|
+
console.print(f"[bold]{step}. Install dependencies:[/]")
|
|
155
|
+
console.print(" make install")
|
|
156
|
+
step += 1
|
|
157
|
+
if config.database.value != "none":
|
|
158
|
+
console.print()
|
|
159
|
+
console.print(f"[bold]{step}. Database setup:[/]")
|
|
160
|
+
console.print(" make docker-db # Start PostgreSQL")
|
|
161
|
+
console.print(" make db-migrate # Create initial migration")
|
|
162
|
+
console.print(" make db-upgrade # Apply migrations")
|
|
163
|
+
step += 1
|
|
164
|
+
console.print()
|
|
165
|
+
console.print(f"[bold]{step}. Run server:[/]")
|
|
166
|
+
console.print(" make run")
|
|
167
|
+
|
|
168
|
+
console.print()
|
|
169
|
+
|
|
170
|
+
if config.enable_logfire:
|
|
171
|
+
console.print("[dim]To enable Logfire, set LOGFIRE_TOKEN in your .env file[/]")
|
|
172
|
+
console.print("[dim]Get your token at: https://logfire.pydantic.dev[/]")
|
|
173
|
+
console.print()
|
|
174
|
+
|
|
175
|
+
if config.frontend == FrontendType.NEXTJS:
|
|
176
|
+
console.print(f"[dim]Frontend runs on http://localhost:{config.frontend_port}[/]")
|
|
177
|
+
console.print(f"[dim]Backend API runs on http://localhost:{config.backend_port}[/]")
|
|
178
|
+
else:
|
|
179
|
+
console.print(f"[dim]API runs on http://localhost:{config.backend_port}[/]")
|
|
180
|
+
console.print(f"[dim]API docs: http://localhost:{config.backend_port}/docs[/]")
|
|
181
|
+
console.print()
|