litestar-start 0.1.0a2__tar.gz

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.
Files changed (74) hide show
  1. litestar_start-0.1.0a2/.gitignore +13 -0
  2. litestar_start-0.1.0a2/LICENSE +21 -0
  3. litestar_start-0.1.0a2/PKG-INFO +87 -0
  4. litestar_start-0.1.0a2/README.md +58 -0
  5. litestar_start-0.1.0a2/pyproject.toml +48 -0
  6. litestar_start-0.1.0a2/src/litestar_start/__init__.py +15 -0
  7. litestar_start-0.1.0a2/src/litestar_start/backends/__init__.py +5 -0
  8. litestar_start-0.1.0a2/src/litestar_start/backends/base.py +185 -0
  9. litestar_start-0.1.0a2/src/litestar_start/backends/fastapi/__init__.py +5 -0
  10. litestar_start-0.1.0a2/src/litestar_start/backends/fastapi/generator.py +110 -0
  11. litestar_start-0.1.0a2/src/litestar_start/backends/fastapi/plugins/__init__.py +15 -0
  12. litestar_start-0.1.0a2/src/litestar_start/backends/fastapi/plugins/sqlalchemy.py +393 -0
  13. litestar_start-0.1.0a2/src/litestar_start/backends/fastapi/templates/api/__init__.py.jinja +1 -0
  14. litestar_start-0.1.0a2/src/litestar_start/backends/fastapi/templates/api/routes.py.jinja +11 -0
  15. litestar_start-0.1.0a2/src/litestar_start/backends/fastapi/templates/app/__init__.py.jinja +1 -0
  16. litestar_start-0.1.0a2/src/litestar_start/backends/fastapi/templates/app/config.py.jinja +23 -0
  17. litestar_start-0.1.0a2/src/litestar_start/backends/fastapi/templates/app/main.py.jinja +55 -0
  18. litestar_start-0.1.0a2/src/litestar_start/backends/fastapi/templates/gitignore.jinja +12 -0
  19. litestar_start-0.1.0a2/src/litestar_start/backends/fastapi/templates/pyproject.toml.jinja +28 -0
  20. litestar_start-0.1.0a2/src/litestar_start/backends/litestar/__init__.py +5 -0
  21. litestar_start-0.1.0a2/src/litestar_start/backends/litestar/generator.py +110 -0
  22. litestar_start-0.1.0a2/src/litestar_start/backends/litestar/plugins/__init__.py +15 -0
  23. litestar_start-0.1.0a2/src/litestar_start/backends/litestar/plugins/sqlalchemy.py +424 -0
  24. litestar_start-0.1.0a2/src/litestar_start/backends/litestar/templates/app/__init__.py.jinja +1 -0
  25. litestar_start-0.1.0a2/src/litestar_start/backends/litestar/templates/app/config.py.jinja +23 -0
  26. litestar_start-0.1.0a2/src/litestar_start/backends/litestar/templates/app/main.py.jinja +38 -0
  27. litestar_start-0.1.0a2/src/litestar_start/backends/litestar/templates/controllers/__init__.py.jinja +1 -0
  28. litestar_start-0.1.0a2/src/litestar_start/backends/litestar/templates/controllers/base.py.jinja +17 -0
  29. litestar_start-0.1.0a2/src/litestar_start/backends/litestar/templates/gitignore.jinja +12 -0
  30. litestar_start-0.1.0a2/src/litestar_start/backends/litestar/templates/pyproject.toml.jinja +28 -0
  31. litestar_start-0.1.0a2/src/litestar_start/backends/templates/.dockerignore +42 -0
  32. litestar_start-0.1.0a2/src/litestar_start/backends/templates/.gitignore +55 -0
  33. litestar_start-0.1.0a2/src/litestar_start/backends/templates/Dockerfile +35 -0
  34. litestar_start-0.1.0a2/src/litestar_start/backends/templates/README.md +116 -0
  35. litestar_start-0.1.0a2/src/litestar_start/backends/templates/tests/__init__.py +1 -0
  36. litestar_start-0.1.0a2/src/litestar_start/backends/templates/tests/conftest.py +9 -0
  37. litestar_start-0.1.0a2/src/litestar_start/backends/templates/tests/test_main.py +16 -0
  38. litestar_start-0.1.0a2/src/litestar_start/cli.py +311 -0
  39. litestar_start-0.1.0a2/src/litestar_start/core/__init__.py +13 -0
  40. litestar_start-0.1.0a2/src/litestar_start/core/base.py +107 -0
  41. litestar_start-0.1.0a2/src/litestar_start/core/config.py +104 -0
  42. litestar_start-0.1.0a2/src/litestar_start/core/context.py +51 -0
  43. litestar_start-0.1.0a2/src/litestar_start/core/merger.py +204 -0
  44. litestar_start-0.1.0a2/src/litestar_start/core/plugin.py +99 -0
  45. litestar_start-0.1.0a2/src/litestar_start/core/renderer.py +89 -0
  46. litestar_start-0.1.0a2/src/litestar_start/core/templates/base/env.example.jinja +5 -0
  47. litestar_start-0.1.0a2/src/litestar_start/core/templates/base/gitignore.jinja +23 -0
  48. litestar_start-0.1.0a2/src/litestar_start/core/templates/base/readme.md.jinja +17 -0
  49. litestar_start-0.1.0a2/src/litestar_start/core/templates/macros/javascript.jinja +21 -0
  50. litestar_start-0.1.0a2/src/litestar_start/core/templates/macros/python.jinja +31 -0
  51. litestar_start-0.1.0a2/src/litestar_start/core/templates.py +243 -0
  52. litestar_start-0.1.0a2/src/litestar_start/core/utils.py +44 -0
  53. litestar_start-0.1.0a2/src/litestar_start/frontends/__init__.py +5 -0
  54. litestar_start-0.1.0a2/src/litestar_start/frontends/base.py +121 -0
  55. litestar_start-0.1.0a2/src/litestar_start/frontends/react/__init__.py +5 -0
  56. litestar_start-0.1.0a2/src/litestar_start/frontends/react/generator.py +234 -0
  57. litestar_start-0.1.0a2/src/litestar_start/frontends/templates/.dockerignore +41 -0
  58. litestar_start-0.1.0a2/src/litestar_start/frontends/templates/.env.example +2 -0
  59. litestar_start-0.1.0a2/src/litestar_start/frontends/templates/.eslintrc.json +33 -0
  60. litestar_start-0.1.0a2/src/litestar_start/frontends/templates/.gitignore +41 -0
  61. litestar_start-0.1.0a2/src/litestar_start/frontends/templates/.prettierrc +9 -0
  62. litestar_start-0.1.0a2/src/litestar_start/frontends/templates/Dockerfile +27 -0
  63. litestar_start-0.1.0a2/src/litestar_start/frontends/templates/README.md +110 -0
  64. litestar_start-0.1.0a2/src/litestar_start/frontends/templates/nginx.conf +51 -0
  65. litestar_start-0.1.0a2/src/litestar_start/generator.py +949 -0
  66. litestar_start-0.1.0a2/src/litestar_start/generators/__init__.py +5 -0
  67. litestar_start-0.1.0a2/src/litestar_start/generators/loader.py +20 -0
  68. litestar_start-0.1.0a2/src/litestar_start/generators/project.py +303 -0
  69. litestar_start-0.1.0a2/src/litestar_start/generators/registry.py +181 -0
  70. litestar_start-0.1.0a2/src/litestar_start/generators/templates/.env.example +37 -0
  71. litestar_start-0.1.0a2/src/litestar_start/generators/templates/.github/workflows/backend.yml +72 -0
  72. litestar_start-0.1.0a2/src/litestar_start/generators/templates/.github/workflows/frontend.yml +67 -0
  73. litestar_start-0.1.0a2/src/litestar_start/generators/templates/README.md +86 -0
  74. litestar_start-0.1.0a2/src/litestar_start/generators/templates/docker-compose.yml +98 -0
@@ -0,0 +1,13 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+ .tmp
12
+ .github/prompts
13
+ docs/prd
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Harshal Laheri
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,87 @@
1
+ Metadata-Version: 2.4
2
+ Name: litestar-start
3
+ Version: 0.1.0a2
4
+ Summary: Interactive CLI to scaffold fullstack projects with modular choices
5
+ Project-URL: Documentation, https://github.com/Harshal6927/litestar-start#readme
6
+ Project-URL: Issues, https://github.com/Harshal6927/litestar-start/issues
7
+ Project-URL: Source, https://github.com/Harshal6927/litestar-start
8
+ Author-email: Harshal Laheri <harshal@harshallaheri.me>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: cli,fullstack,generator,litestar,scaffolding,template
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Code Generators
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: jinja2>=3.1.6
24
+ Requires-Dist: msgspec>=0.20.0
25
+ Requires-Dist: pydantic>=2.12.5
26
+ Requires-Dist: questionary>=2.1.1
27
+ Requires-Dist: rich>=14.2.0
28
+ Description-Content-Type: text/markdown
29
+
30
+ # Litestar Start
31
+
32
+ **Litestar Start** is an interactive CLI tool designed to scaffold production-ready fullstack applications with modular choices. It combines modern python tooling with established patterns to get you up and running quickly.
33
+
34
+ ## Features
35
+
36
+ * **Interactive CLI**: Beautiful terminal interface using `rich` and `questionary`.
37
+ * **Backend Frameworks**:
38
+ * [Litestar](https://litestar.dev/)
39
+ * [FastAPI](https://fastapi.tiangolo.com/)
40
+ * **Frontend Frameworks**:
41
+ * [React](https://react.dev/)
42
+ * **Database Support**:
43
+ * PostgreSQL
44
+ * MySQL
45
+ * SQLite
46
+ * MongoDB
47
+ * **ORM Integration**:
48
+ * [SQLAlchemy](https://www.sqlalchemy.org/)
49
+ * **Tooling**:
50
+ * Docker & Docker Compose support
51
+ * GitHub Actions CI/CD workflows
52
+ * Ruff & Pre-commit linting configuration
53
+
54
+ ## Installation
55
+
56
+ You can install and run `litestar-start` using `uvx` or `pipx`:
57
+
58
+ ```bash
59
+ uvx litestar-start
60
+
61
+ # or
62
+
63
+ pipx run litestar-start
64
+ ```
65
+
66
+ ## Usage
67
+
68
+ Simply run the command and follow the interactive prompts:
69
+
70
+ ```bash
71
+ litestar-start
72
+ ```
73
+
74
+ You will be asked to configure:
75
+ 1. **Project Details**: Name and description.
76
+ 2. **Tech Stack**: Backend, Frontend, Database, ORM.
77
+ 3. **Features**: Docker, CI/CD, Testing, Linting.
78
+
79
+ ## Contributing
80
+
81
+ We welcome contributions! Whether it's adding a new framework, fixing a bug, or improving documentation.
82
+
83
+ Please read our [Developer Guide](DEVELOPMENT.md) to get started with setting up the project locally.
84
+
85
+ ## License
86
+
87
+ MIT
@@ -0,0 +1,58 @@
1
+ # Litestar Start
2
+
3
+ **Litestar Start** is an interactive CLI tool designed to scaffold production-ready fullstack applications with modular choices. It combines modern python tooling with established patterns to get you up and running quickly.
4
+
5
+ ## Features
6
+
7
+ * **Interactive CLI**: Beautiful terminal interface using `rich` and `questionary`.
8
+ * **Backend Frameworks**:
9
+ * [Litestar](https://litestar.dev/)
10
+ * [FastAPI](https://fastapi.tiangolo.com/)
11
+ * **Frontend Frameworks**:
12
+ * [React](https://react.dev/)
13
+ * **Database Support**:
14
+ * PostgreSQL
15
+ * MySQL
16
+ * SQLite
17
+ * MongoDB
18
+ * **ORM Integration**:
19
+ * [SQLAlchemy](https://www.sqlalchemy.org/)
20
+ * **Tooling**:
21
+ * Docker & Docker Compose support
22
+ * GitHub Actions CI/CD workflows
23
+ * Ruff & Pre-commit linting configuration
24
+
25
+ ## Installation
26
+
27
+ You can install and run `litestar-start` using `uvx` or `pipx`:
28
+
29
+ ```bash
30
+ uvx litestar-start
31
+
32
+ # or
33
+
34
+ pipx run litestar-start
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ Simply run the command and follow the interactive prompts:
40
+
41
+ ```bash
42
+ litestar-start
43
+ ```
44
+
45
+ You will be asked to configure:
46
+ 1. **Project Details**: Name and description.
47
+ 2. **Tech Stack**: Backend, Frontend, Database, ORM.
48
+ 3. **Features**: Docker, CI/CD, Testing, Linting.
49
+
50
+ ## Contributing
51
+
52
+ We welcome contributions! Whether it's adding a new framework, fixing a bug, or improving documentation.
53
+
54
+ Please read our [Developer Guide](DEVELOPMENT.md) to get started with setting up the project locally.
55
+
56
+ ## License
57
+
58
+ MIT
@@ -0,0 +1,48 @@
1
+ [project]
2
+ authors = [{ name = "Harshal Laheri", email = "harshal@harshallaheri.me" }]
3
+ classifiers = [
4
+ "Development Status :: 3 - Alpha",
5
+ "Environment :: Console",
6
+ "Intended Audience :: Developers",
7
+ "License :: OSI Approved :: MIT License",
8
+ "Programming Language :: Python :: 3",
9
+ "Programming Language :: Python :: 3.10",
10
+ "Programming Language :: Python :: 3.11",
11
+ "Programming Language :: Python :: 3.12",
12
+ "Programming Language :: Python :: 3.13",
13
+ "Topic :: Software Development :: Code Generators",
14
+ ]
15
+ dependencies = ["questionary>=2.1.1", "rich>=14.2.0", "jinja2>=3.1.6", "pydantic>=2.12.5", "msgspec>=0.20.0"]
16
+ description = "Interactive CLI to scaffold fullstack projects with modular choices"
17
+ keywords = ["litestar", "scaffolding", "cli", "fullstack", "template", "generator"]
18
+ license = "MIT"
19
+ name = "litestar-start"
20
+ readme = "README.md"
21
+ requires-python = ">=3.10"
22
+ version = "0.1.0a2"
23
+
24
+ [project.scripts]
25
+ litestar-start = "litestar_start.cli:main"
26
+
27
+ [project.urls]
28
+ Documentation = "https://github.com/Harshal6927/litestar-start#readme"
29
+ Issues = "https://github.com/Harshal6927/litestar-start/issues"
30
+ Source = "https://github.com/Harshal6927/litestar-start"
31
+
32
+ [build-system]
33
+ build-backend = "hatchling.build"
34
+ requires = ["hatchling"]
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["src/litestar_start"]
38
+
39
+ [tool.hatch.build.targets.sdist]
40
+ include = ["/src", "/templates"]
41
+
42
+
43
+ [tool.ruff]
44
+ line-length = 120
45
+ lint.ignore = ["CPY001", "D100"]
46
+
47
+ [dependency-groups]
48
+ dev = ["pre-commit>=4.5.1", "pytest>=9.0.2"]
@@ -0,0 +1,15 @@
1
+ """Litestar Start - Interactive CLI for scaffolding fullstack projects."""
2
+
3
+ from litestar_start.core.config import ProjectConfig
4
+ from litestar_start.generators.loader import register_all_generators
5
+ from litestar_start.generators.project import ProjectOrchestrator
6
+ from litestar_start.generators.registry import GeneratorRegistry
7
+
8
+ __version__ = "0.1.0a2"
9
+
10
+ __all__ = [
11
+ "GeneratorRegistry",
12
+ "ProjectConfig",
13
+ "ProjectOrchestrator",
14
+ "register_all_generators",
15
+ ]
@@ -0,0 +1,5 @@
1
+ """Backend generators package."""
2
+
3
+ from litestar_start.backends.base import BackendGenerator
4
+
5
+ __all__ = ["BackendGenerator"]
@@ -0,0 +1,185 @@
1
+ """Base class for backend generators."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import shutil
6
+ from abc import abstractmethod
7
+ from pathlib import Path
8
+ from typing import TYPE_CHECKING
9
+
10
+ from litestar_start.core.base import BaseGenerator
11
+ from litestar_start.core.utils import ensure_dir, write_file
12
+
13
+ if TYPE_CHECKING:
14
+ from litestar_start.core.base import GeneratorContext
15
+
16
+
17
+ class BackendGenerator(BaseGenerator):
18
+ """Abstract base class for backend generators."""
19
+
20
+ def generate(self, context: GeneratorContext) -> None:
21
+ """Generate backend code.
22
+
23
+ Args:
24
+ context: Generator context.
25
+
26
+ """
27
+ backend_dir = context.output_dir / "backend"
28
+ ensure_dir(backend_dir)
29
+
30
+ # Generate pyproject.toml
31
+ self._generate_pyproject(backend_dir, context)
32
+
33
+ # Generate app structure
34
+ self._generate_app_structure(backend_dir, context)
35
+
36
+ # Copy template files (Dockerfile, README, etc.)
37
+ self._copy_template_files(backend_dir, context)
38
+
39
+ # Apply plugins
40
+ self._apply_plugins(backend_dir, context)
41
+
42
+ @abstractmethod
43
+ def _generate_pyproject(self, backend_dir: Path, context: GeneratorContext) -> None:
44
+ """Generate pyproject.toml for the backend.
45
+
46
+ Args:
47
+ backend_dir: Backend directory path.
48
+ context: Generator context.
49
+
50
+ """
51
+ ...
52
+
53
+ @abstractmethod
54
+ def _generate_app_structure(self, backend_dir: Path, context: GeneratorContext) -> None:
55
+ """Generate the application structure.
56
+
57
+ Args:
58
+ backend_dir: Backend directory path.
59
+ context: Generator context.
60
+
61
+ """
62
+ ...
63
+
64
+ def _apply_plugins(self, backend_dir: Path, context: GeneratorContext) -> None:
65
+ """Apply plugins to enhance the backend.
66
+
67
+ Args:
68
+ backend_dir: Backend directory path.
69
+ context: Generator context.
70
+
71
+ """
72
+ # Plugin application will be implemented when plugins are created
73
+
74
+ def _copy_template_files(self, backend_dir: Path, context: GeneratorContext) -> None:
75
+ """Copy template files to backend directory.
76
+
77
+ Args:
78
+ backend_dir: Backend directory path.
79
+ context: Generator context.
80
+
81
+ """
82
+ templates_dir = Path(__file__).parent / "templates"
83
+
84
+ # Copy Dockerfile
85
+ if (templates_dir / "Dockerfile").exists():
86
+ shutil.copy2(templates_dir / "Dockerfile", backend_dir / "Dockerfile")
87
+
88
+ # Copy .dockerignore
89
+ if (templates_dir / ".dockerignore").exists():
90
+ shutil.copy2(templates_dir / ".dockerignore", backend_dir / ".dockerignore")
91
+
92
+ # Copy .gitignore
93
+ if (templates_dir / ".gitignore").exists():
94
+ shutil.copy2(templates_dir / ".gitignore", backend_dir / ".gitignore")
95
+
96
+ # Copy README (with templating)
97
+ if (templates_dir / "README.md").exists():
98
+ readme_template = (templates_dir / "README.md").read_text()
99
+ readme_content = readme_template.replace("{{ project_name }}", context.project_name)
100
+ readme_content = readme_content.replace("{{ project_slug }}", context.project_slug)
101
+ readme_content = readme_content.replace("{{ description }}", context.description or "")
102
+ write_file(backend_dir / "README.md", readme_content)
103
+
104
+ # Copy tests directory
105
+ tests_template_dir = templates_dir / "tests"
106
+ if tests_template_dir.exists():
107
+ tests_dir = backend_dir / "tests"
108
+ ensure_dir(tests_dir)
109
+ for test_file in tests_template_dir.glob("*.py"):
110
+ shutil.copy2(test_file, tests_dir / test_file.name)
111
+
112
+ @staticmethod
113
+ def _create_pyproject_content(
114
+ project_name: str,
115
+ dependencies: list[str],
116
+ dev_dependencies: list[str] | None = None,
117
+ ) -> str:
118
+ """Create pyproject.toml content.
119
+
120
+ Args:
121
+ project_name: Project name.
122
+ dependencies: List of dependencies.
123
+ dev_dependencies: Optional list of dev dependencies.
124
+
125
+ Returns:
126
+ Pyproject.toml content as string.
127
+
128
+ """
129
+ dev_dependencies = dev_dependencies or [
130
+ "pytest>=8.0.0",
131
+ "pytest-cov>=4.1.0",
132
+ "pytest-asyncio>=0.23.0",
133
+ "ruff>=0.4.0",
134
+ "mypy>=1.9.0",
135
+ ]
136
+
137
+ deps_str = "\n".join(f' "{dep}",' for dep in dependencies)
138
+ dev_deps_str = "\n".join(f' "{dep}",' for dep in dev_dependencies)
139
+
140
+ return f"""[project]
141
+ name = "{project_name}-backend"
142
+ version = "0.1.0"
143
+ description = "Backend for {project_name}"
144
+ readme = "README.md"
145
+ requires-python = ">=3.11"
146
+ dependencies = [
147
+ {deps_str}
148
+ ]
149
+
150
+ [project.optional-dependencies]
151
+ dev = [
152
+ {dev_deps_str}
153
+ ]
154
+
155
+ [build-system]
156
+ requires = ["hatchling"]
157
+ build-backend = "hatchling.build"
158
+
159
+ [tool.uv]
160
+ dev-dependencies = [
161
+ {dev_deps_str}
162
+ ]
163
+
164
+ [tool.ruff]
165
+ line-length = 120
166
+ target-version = "py311"
167
+
168
+ [tool.ruff.lint]
169
+ select = ["E", "F", "I", "UP", "B", "SIM"]
170
+ ignore = ["E501"]
171
+
172
+ [tool.pytest.ini_options]
173
+ asyncio_mode = "auto"
174
+ testpaths = ["tests"]
175
+ python_files = "test_*.py"
176
+ python_classes = "Test*"
177
+ python_functions = "test_*"
178
+
179
+ [tool.mypy]
180
+ python_version = "3.11"
181
+ strict = true
182
+ warn_return_any = true
183
+ warn_unused_configs = true
184
+ disallow_untyped_defs = true
185
+ """
@@ -0,0 +1,5 @@
1
+ """FastAPI backend generator package."""
2
+
3
+ from litestar_start.backends.fastapi.generator import FastAPIGenerator
4
+
5
+ __all__ = ["FastAPIGenerator"]
@@ -0,0 +1,110 @@
1
+ """FastAPI backend generator."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import TYPE_CHECKING
7
+
8
+ from litestar_start.backends.base import BackendGenerator
9
+ from litestar_start.core.templates import TemplateLoader
10
+ from litestar_start.core.utils import ensure_dir, write_file
11
+
12
+ if TYPE_CHECKING:
13
+ from litestar_start.core.base import GeneratorContext
14
+
15
+
16
+ class FastAPIGenerator(BackendGenerator):
17
+ """Generator for FastAPI backend projects."""
18
+
19
+ def __init__(self) -> None:
20
+ """Initialize the FastAPI generator."""
21
+ super().__init__()
22
+ self.template_loader = TemplateLoader()
23
+ # Register FastAPI-specific templates
24
+ self.template_loader.register_template_dir("fastapi", Path(__file__).parent / "templates")
25
+
26
+ @property
27
+ def name(self) -> str:
28
+ """Generator name."""
29
+ return "fastapi"
30
+
31
+ @property
32
+ def display_name(self) -> str:
33
+ """Human-readable name."""
34
+ return "FastAPI"
35
+
36
+ def get_dependencies(self) -> list[str]:
37
+ """Get FastAPI dependencies.
38
+
39
+ Returns:
40
+ List of package dependencies.
41
+
42
+ """
43
+ return [
44
+ "fastapi>=0.109.0",
45
+ "uvicorn[standard]>=0.27.0",
46
+ "python-dotenv>=1.0.0",
47
+ "msgspec>=0.20.0",
48
+ ]
49
+
50
+ def _generate_pyproject(self, backend_dir: Path, context: GeneratorContext) -> None:
51
+ """Generate pyproject.toml for FastAPI.
52
+
53
+ Args:
54
+ backend_dir: Backend directory path.
55
+ context: Generator context.
56
+
57
+ """
58
+ template_context = {
59
+ "project_slug": context.project_slug,
60
+ "description": context.description,
61
+ "dependencies": self.get_dependencies(),
62
+ }
63
+ content = self.template_loader.render("fastapi:pyproject.toml.jinja", template_context)
64
+ write_file(backend_dir / "pyproject.toml", content)
65
+
66
+ # Create .python-version for uv
67
+ write_file(backend_dir / ".python-version", "3.12\n")
68
+
69
+ # Create .gitignore
70
+ gitignore_content = self.template_loader.render("fastapi:gitignore.jinja", {})
71
+ write_file(backend_dir / ".gitignore", gitignore_content)
72
+
73
+ def _generate_app_structure(self, backend_dir: Path, context: GeneratorContext) -> None:
74
+ """Generate FastAPI application structure.
75
+
76
+ Args:
77
+ backend_dir: Backend directory path.
78
+ context: Generator context.
79
+
80
+ """
81
+ app_dir = backend_dir / "app"
82
+ ensure_dir(app_dir)
83
+
84
+ template_context = {
85
+ "project_name": context.project_name,
86
+ "project_slug": context.project_slug,
87
+ "description": context.description,
88
+ }
89
+
90
+ # Create __init__.py
91
+ init_content = self.template_loader.render("fastapi:app/__init__.py.jinja", {})
92
+ write_file(app_dir / "__init__.py", init_content)
93
+
94
+ # Create main.py
95
+ main_content = self.template_loader.render("fastapi:app/main.py.jinja", template_context)
96
+ write_file(app_dir / "main.py", main_content)
97
+
98
+ # Create config.py
99
+ config_content = self.template_loader.render("fastapi:app/config.py.jinja", template_context)
100
+ write_file(app_dir / "config.py", config_content)
101
+
102
+ # Create api directory
103
+ api_dir = app_dir / "api"
104
+ ensure_dir(api_dir)
105
+ api_init_content = self.template_loader.render("fastapi:api/__init__.py.jinja", {})
106
+ write_file(api_dir / "__init__.py", api_init_content)
107
+
108
+ # Create routes.py
109
+ routes_content = self.template_loader.render("fastapi:api/routes.py.jinja", {})
110
+ write_file(api_dir / "routes.py", routes_content)
@@ -0,0 +1,15 @@
1
+ """Plugins for FastAPI backend."""
2
+
3
+ from litestar_start.generators.registry import GeneratorRegistry
4
+
5
+ from .sqlalchemy import SQLAlchemyPlugin
6
+
7
+ # Register all plugins for FastAPI
8
+ _plugins = [
9
+ SQLAlchemyPlugin,
10
+ ]
11
+
12
+ for plugin in _plugins:
13
+ GeneratorRegistry.register_plugin("fastapi", plugin)
14
+
15
+ __all__ = ["SQLAlchemyPlugin"]