project-initializer 0.1.0__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.
Files changed (97) hide show
  1. project_initializer/__init__.py +3 -0
  2. project_initializer/cli.py +113 -0
  3. project_initializer/templates/.env.example +13 -0
  4. project_initializer/templates/.gitignore +207 -0
  5. project_initializer/templates/.vscode/launch.json +47 -0
  6. project_initializer/templates/.vscode/settings.json +26 -0
  7. project_initializer/templates/LICENSE +21 -0
  8. project_initializer/templates/README.md +1 -0
  9. project_initializer/templates/api/.claude/CLAUDE.md +87 -0
  10. project_initializer/templates/api/.dockerignore +66 -0
  11. project_initializer/templates/api/.env.example +17 -0
  12. project_initializer/templates/api/Dockerfile +61 -0
  13. project_initializer/templates/api/README.md +0 -0
  14. project_initializer/templates/api/alembic/README +1 -0
  15. project_initializer/templates/api/alembic/env.py +77 -0
  16. project_initializer/templates/api/alembic/script.py.mako +28 -0
  17. project_initializer/templates/api/alembic.ini +142 -0
  18. project_initializer/templates/api/app/__init__.py +3 -0
  19. project_initializer/templates/api/app/api/__init__.py +39 -0
  20. project_initializer/templates/api/app/api/v1/__init__.py +130 -0
  21. project_initializer/templates/api/app/api/v1/chatbot.py +237 -0
  22. project_initializer/templates/api/app/api/v1/router.py +13 -0
  23. project_initializer/templates/api/app/api/v1/test.py +242 -0
  24. project_initializer/templates/api/app/config.py +103 -0
  25. project_initializer/templates/api/app/database.py +511 -0
  26. project_initializer/templates/api/app/dependencies.py +306 -0
  27. project_initializer/templates/api/app/exceptions.py +640 -0
  28. project_initializer/templates/api/app/main.py +223 -0
  29. project_initializer/templates/api/app/middleware/__init__.py +98 -0
  30. project_initializer/templates/api/app/middleware/logging.py +122 -0
  31. project_initializer/templates/api/app/middleware/rate_limiting.py +103 -0
  32. project_initializer/templates/api/app/middleware/security.py +84 -0
  33. project_initializer/templates/api/app/models/__init__.py +17 -0
  34. project_initializer/templates/api/app/models/base.py +68 -0
  35. project_initializer/templates/api/app/models/user.py +67 -0
  36. project_initializer/templates/api/app/repositories/__init__.py +218 -0
  37. project_initializer/templates/api/app/repositories/base.py +272 -0
  38. project_initializer/templates/api/app/schemas/__init__.py +250 -0
  39. project_initializer/templates/api/app/schemas/chatbot.py +92 -0
  40. project_initializer/templates/api/app/services/__init__.py +248 -0
  41. project_initializer/templates/api/app/services/chatbot_service.py +81 -0
  42. project_initializer/templates/api/baml_src/chatbot.baml +59 -0
  43. project_initializer/templates/api/baml_src/clients.baml +94 -0
  44. project_initializer/templates/api/baml_src/generators.baml +18 -0
  45. project_initializer/templates/api/entrypoint.sh +22 -0
  46. project_initializer/templates/api/requirements.txt +34 -0
  47. project_initializer/templates/docker-compose.yml +63 -0
  48. project_initializer/templates/frontend/.claude/CLAUDE.md +47 -0
  49. project_initializer/templates/frontend/.editorconfig +17 -0
  50. project_initializer/templates/frontend/.gitignore +43 -0
  51. project_initializer/templates/frontend/.postcssrc.json +5 -0
  52. project_initializer/templates/frontend/.vscode/extensions.json +4 -0
  53. project_initializer/templates/frontend/.vscode/launch.json +20 -0
  54. project_initializer/templates/frontend/.vscode/tasks.json +42 -0
  55. project_initializer/templates/frontend/Dockerfile +48 -0
  56. project_initializer/templates/frontend/README.md +59 -0
  57. project_initializer/templates/frontend/angular.json +93 -0
  58. project_initializer/templates/frontend/nginx.conf +44 -0
  59. project_initializer/templates/frontend/package-lock.json +9453 -0
  60. project_initializer/templates/frontend/package.json +47 -0
  61. project_initializer/templates/frontend/public/favicon.ico +0 -0
  62. project_initializer/templates/frontend/src/app/app.config.ts +14 -0
  63. project_initializer/templates/frontend/src/app/app.css +0 -0
  64. project_initializer/templates/frontend/src/app/app.html +2 -0
  65. project_initializer/templates/frontend/src/app/app.routes.ts +32 -0
  66. project_initializer/templates/frontend/src/app/app.spec.ts +25 -0
  67. project_initializer/templates/frontend/src/app/app.ts +12 -0
  68. project_initializer/templates/frontend/src/app/auth/login/login.css +0 -0
  69. project_initializer/templates/frontend/src/app/auth/login/login.html +116 -0
  70. project_initializer/templates/frontend/src/app/auth/login/login.ts +87 -0
  71. project_initializer/templates/frontend/src/app/guards/auth.guard.ts +51 -0
  72. project_initializer/templates/frontend/src/app/pages/home/home.css +1 -0
  73. project_initializer/templates/frontend/src/app/pages/home/home.html +4 -0
  74. project_initializer/templates/frontend/src/app/pages/home/home.ts +13 -0
  75. project_initializer/templates/frontend/src/app/services/auth.service.ts +142 -0
  76. project_initializer/templates/frontend/src/app/shared/layout/layout.css +0 -0
  77. project_initializer/templates/frontend/src/app/shared/layout/layout.html +50 -0
  78. project_initializer/templates/frontend/src/app/shared/layout/layout.ts +95 -0
  79. project_initializer/templates/frontend/src/app/shared/sidebar/sidebar.css +0 -0
  80. project_initializer/templates/frontend/src/app/shared/sidebar/sidebar.html +101 -0
  81. project_initializer/templates/frontend/src/app/shared/sidebar/sidebar.ts +83 -0
  82. project_initializer/templates/frontend/src/assets/favicon.ico +0 -0
  83. project_initializer/templates/frontend/src/environments/environment.model.ts +3 -0
  84. project_initializer/templates/frontend/src/environments/environment.prod.ts +6 -0
  85. project_initializer/templates/frontend/src/environments/environment.ts +5 -0
  86. project_initializer/templates/frontend/src/index.html +13 -0
  87. project_initializer/templates/frontend/src/main.ts +6 -0
  88. project_initializer/templates/frontend/src/styles.css +2 -0
  89. project_initializer/templates/frontend/tsconfig.app.json +15 -0
  90. project_initializer/templates/frontend/tsconfig.json +34 -0
  91. project_initializer/templates/frontend/tsconfig.spec.json +14 -0
  92. project_initializer-0.1.0.dist-info/METADATA +105 -0
  93. project_initializer-0.1.0.dist-info/RECORD +97 -0
  94. project_initializer-0.1.0.dist-info/WHEEL +5 -0
  95. project_initializer-0.1.0.dist-info/entry_points.txt +2 -0
  96. project_initializer-0.1.0.dist-info/licenses/LICENSE +21 -0
  97. project_initializer-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,3 @@
1
+ """Project Initializer - CLI tool to scaffold full-stack projects."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,113 @@
1
+ """CLI entry point for project-initializer."""
2
+
3
+ import argparse
4
+ import os
5
+ import shutil
6
+ import sys
7
+ from pathlib import Path
8
+
9
+ from . import __version__
10
+
11
+
12
+ def get_templates_dir() -> Path:
13
+ """Get the path to the templates directory."""
14
+ return Path(__file__).parent / "templates"
15
+
16
+
17
+ def copy_template(dest_dir: Path, project_name: str | None = None) -> None:
18
+ """Copy template files to destination directory."""
19
+ templates_dir = get_templates_dir()
20
+
21
+ if not templates_dir.exists():
22
+ print(f"Error: Templates directory not found at {templates_dir}")
23
+ sys.exit(1)
24
+
25
+ # Files and directories to skip
26
+ skip_patterns = {
27
+ "__pycache__",
28
+ ".pyc",
29
+ "node_modules",
30
+ ".git",
31
+ ".env",
32
+ "*.egg-info",
33
+ "dist",
34
+ "build",
35
+ }
36
+
37
+ def should_skip(name: str) -> bool:
38
+ return any(
39
+ name == pattern or name.endswith(pattern.lstrip("*"))
40
+ for pattern in skip_patterns
41
+ )
42
+
43
+ def copy_tree(src: Path, dst: Path) -> None:
44
+ """Recursively copy directory tree."""
45
+ dst.mkdir(parents=True, exist_ok=True)
46
+
47
+ for item in src.iterdir():
48
+ if should_skip(item.name):
49
+ continue
50
+
51
+ dest_item = dst / item.name
52
+
53
+ if item.is_dir():
54
+ copy_tree(item, dest_item)
55
+ else:
56
+ shutil.copy2(item, dest_item)
57
+ print(f" Created: {dest_item.relative_to(dest_dir)}")
58
+
59
+ print(f"Creating project in: {dest_dir}")
60
+ print("-" * 40)
61
+
62
+ copy_tree(templates_dir, dest_dir)
63
+
64
+ print("-" * 40)
65
+ print(f"Project created successfully!")
66
+ print(f"\nNext steps:")
67
+ print(f" cd {dest_dir.name}")
68
+ print(f" docker-compose up -d")
69
+
70
+
71
+ def main() -> None:
72
+ """Main entry point for the CLI."""
73
+ parser = argparse.ArgumentParser(
74
+ prog="project-initializer",
75
+ description="Initialize a new full-stack project with FastAPI, Angular, and Docker",
76
+ )
77
+ parser.add_argument(
78
+ "project_name",
79
+ nargs="?",
80
+ default=".",
81
+ help="Name of the project directory to create (default: current directory)",
82
+ )
83
+ parser.add_argument(
84
+ "-v", "--version",
85
+ action="version",
86
+ version=f"%(prog)s {__version__}",
87
+ )
88
+ parser.add_argument(
89
+ "-f", "--force",
90
+ action="store_true",
91
+ help="Overwrite existing files without prompting",
92
+ )
93
+
94
+ args = parser.parse_args()
95
+
96
+ # Determine destination directory
97
+ if args.project_name == ".":
98
+ dest_dir = Path.cwd()
99
+ else:
100
+ dest_dir = Path.cwd() / args.project_name
101
+
102
+ # Check if directory exists and has content
103
+ if dest_dir.exists() and any(dest_dir.iterdir()) and not args.force:
104
+ response = input(f"Directory '{dest_dir}' is not empty. Continue? [y/N]: ")
105
+ if response.lower() != "y":
106
+ print("Aborted.")
107
+ sys.exit(0)
108
+
109
+ copy_template(dest_dir, args.project_name)
110
+
111
+
112
+ if __name__ == "__main__":
113
+ main()
@@ -0,0 +1,13 @@
1
+ OPENAI_API_KEY=your_openai_api_key_here
2
+
3
+ ANTHROPIC_API_KEY=your_anthropic_api_key_here
4
+
5
+ GOOGLE_API_KEY=your_google_api_key_here
6
+
7
+ # Azure OpenAI (for BAML)
8
+ OPENAI_KEY=your_azure_openai_key_here
9
+ OPENAI_ENDPOINT=https://your-resource.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview
10
+ OPENAI_RESOURCE_NAME=your-resource-name
11
+ OPENAI_API_VERSION=2025-01-01-preview
12
+ OPENAI_GPT4O_DEPLOYMENT_ID=gpt-4o
13
+ OPENAI_GPT5_DEPLOYMENT_ID=gpt-5.2
@@ -0,0 +1,207 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
@@ -0,0 +1,47 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "API (Development)",
6
+ "type": "debugpy",
7
+ "request": "launch",
8
+ "module": "uvicorn",
9
+ "cwd": "${workspaceFolder}/api",
10
+ "args": [
11
+ "app.main:app",
12
+ "--reload",
13
+ "--port",
14
+ "8000",
15
+ "--host",
16
+ "0.0.0.0",
17
+ "--log-level",
18
+ "debug"
19
+ ],
20
+ "python": "/Users/silviobaratto/anaconda3/envs/app/bin/python",
21
+ "jinja": true,
22
+ "envFile": "${workspaceFolder}/.env.dev",
23
+ "console": "integratedTerminal"
24
+ },
25
+ {
26
+ "name": "API (Production)",
27
+ "type": "debugpy",
28
+ "request": "launch",
29
+ "module": "uvicorn",
30
+ "cwd": "${workspaceFolder}/api",
31
+ "args": [
32
+ "app.main:app",
33
+ "--reload",
34
+ "--port",
35
+ "8000",
36
+ "--host",
37
+ "0.0.0.0",
38
+ "--log-level",
39
+ "info"
40
+ ],
41
+ "python": "/Users/silviobaratto/anaconda3/envs/app/bin/python",
42
+ "jinja": true,
43
+ "envFile": "${workspaceFolder}/.env.prod",
44
+ "console": "integratedTerminal"
45
+ }
46
+ ]
47
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "python.testing.pytestArgs": [
3
+ "tests",
4
+ "--no-cov",
5
+ "--tb=short"
6
+ ],
7
+ "python.testing.unittestEnabled": false,
8
+ "python.testing.pytestEnabled": true,
9
+ "python.testing.cwd": "${workspaceFolder}/api",
10
+ "python.defaultInterpreterPath": "/Users/silviobaratto/anaconda3/envs/app/bin/python",
11
+ "python.testing.autoTestDiscoverOnSaveEnabled": true,
12
+ "python.analysis.typeCheckingMode": "standard",
13
+ "editor.formatOnSave": true,
14
+ "[typescript]": {
15
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
16
+ },
17
+ "[html]": {
18
+ "editor.defaultFormatter": "vscode.html-language-features"
19
+ },
20
+ "[python]": {
21
+ "editor.defaultFormatter": "ms-python.black-formatter"
22
+ },
23
+ "[json]": {
24
+ "editor.defaultFormatter": "vscode.json-language-features"
25
+ }
26
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Silvio Angelo Baratto Roldan
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 @@
1
+ # project-initializer-
@@ -0,0 +1,87 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Build & Run Commands
6
+
7
+ ```bash
8
+ # Install dependencies
9
+ pip install -r requirements.txt
10
+
11
+ # Run development server (port 8000)
12
+ uvicorn app.main:app --reload
13
+
14
+ # Run with specific host/port
15
+ uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
16
+
17
+ # Run tests
18
+ pytest
19
+
20
+ # Run single test file
21
+ pytest path/to/test_file.py
22
+
23
+ # Database migrations
24
+ alembic upgrade head # Apply migrations
25
+ alembic revision --autogenerate -m "description" # Create migration
26
+ alembic downgrade -1 # Rollback one migration
27
+
28
+ # Regenerate BAML client (after modifying .baml files)
29
+ baml-cli generate
30
+ ```
31
+
32
+ ## Architecture Overview
33
+
34
+ This is a FastAPI application with BAML-powered AI chatbot functionality.
35
+
36
+ ### Core Structure
37
+
38
+ ```
39
+ app/
40
+ ├── main.py # Application factory, middleware setup, lifespan events
41
+ ├── config.py # Settings via pydantic-settings (loads from .env)
42
+ ├── database.py # DatabaseManager with sync SQLAlchemy + psycopg2 pooling
43
+ ├── dependencies.py # FastAPI dependencies (auth, pagination, rate limiting)
44
+ ├── exceptions.py # Custom exceptions with centralized handlers
45
+ ├── api/v1/ # API endpoints (router.py aggregates all routes)
46
+ ├── models/ # SQLAlchemy models (Base in base.py)
47
+ ├── schemas/ # Pydantic schemas for validation
48
+ ├── services/ # Business logic layer
49
+ └── middleware/ # Security, logging, rate limiting middleware
50
+
51
+ baml_src/ # BAML definitions for LLM functions
52
+ baml_client/ # Auto-generated BAML Python client (don't edit)
53
+ ```
54
+
55
+ ### Key Patterns
56
+
57
+ **Database Access**: Use `get_db` dependency or `database_manager.get_session()` context manager. Sessions use `autoflush=False` and `expire_on_commit=False`.
58
+
59
+ **API Routes**: All v1 routes go through `/api/v1` prefix. Add new routers in `app/api/v1/router.py`.
60
+
61
+ **BAML Integration**: Define LLM functions in `baml_src/*.baml`, regenerate client with `baml-cli generate`. Access via `from baml_client.async_client import b as baml_async_client`.
62
+
63
+ **Schema Naming**: `<Entity>Create`, `<Entity>Update`, `<Entity>Response` pattern.
64
+
65
+ **Models**: Inherit from `Base` (for custom) or `BaseModel` (includes UUID PK + timestamps).
66
+
67
+ ### Environment Configuration
68
+
69
+ Settings are loaded from `.env` file. Key variables:
70
+ - `DATABASE_URL` - PostgreSQL connection string
71
+ - `ANTHROPIC_API_KEY` - For Claude models via BAML
72
+ - `ENVIRONMENT` - "development", "staging", or "production"
73
+ - `DEBUG` - Enable debug mode
74
+
75
+ ### Middleware Stack (execution order)
76
+
77
+ 1. CORS (outermost)
78
+ 2. Rate limiting (production/staging only)
79
+ 3. Security headers
80
+ 4. Request logging (debug mode)
81
+
82
+ ### BAML Clients
83
+
84
+ Defined in `baml_src/clients.baml`. Currently configured:
85
+ - `CustomSonnet45` - Claude Sonnet 4.5 (default for chatbot)
86
+ - `CustomOpus45` - Claude Opus 4.5
87
+ - `CustomGPT5`, `Gemini`, `Ollama` - Alternative providers
@@ -0,0 +1,66 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ env/
8
+ venv/
9
+ ENV/
10
+ VENV/
11
+ .venv
12
+ pip-log.txt
13
+ pip-delete-this-directory.txt
14
+ .tox/
15
+ .coverage
16
+ .coverage.*
17
+ .cache
18
+ nosetests.xml
19
+ coverage.xml
20
+ *.cover
21
+ .hypothesis/
22
+ .pytest_cache/
23
+
24
+ # Environment and configs
25
+ .env
26
+ .env.*
27
+ !.env.example
28
+ docker-compose.yml
29
+ docker-compose.*.yml
30
+ !docker-compose.prod.yml
31
+ Dockerfile
32
+ !Dockerfile.fly
33
+
34
+ # Development
35
+ .git/
36
+ .gitignore
37
+ .vscode/
38
+ .idea/
39
+ *.swp
40
+ *.swo
41
+ *~
42
+ .DS_Store
43
+
44
+ # Documentation
45
+ README.md
46
+ README.*.md
47
+ docs/
48
+ *.md
49
+
50
+ # Scripts and CI
51
+ scripts/
52
+ .github/
53
+ .gitlab-ci.yml
54
+
55
+ # Fly.io specific
56
+ fly.toml
57
+ !fly.toml.example
58
+
59
+ # Redis data
60
+ redis_data/
61
+ *.rdb
62
+ *.aof
63
+
64
+ # Logs
65
+ logs/
66
+ *.log
@@ -0,0 +1,17 @@
1
+ # Database Configuration
2
+ DATABASE_URL=postgresql://user:password@db:5432/appdb
3
+
4
+ # Azure OpenAI Configuration (for chatbot)
5
+ AZURE_OPENAI_RESOURCE_NAME=your-resource-name
6
+ AZURE_OPENAI_GPT5_DEPLOYMENT_ID=your-deployment-id
7
+ AZURE_OPENAI_API_VERSION=2024-02-15-preview
8
+ AZURE_OPENAI_KEY=your-azure-openai-key
9
+
10
+ # Alternative: Anthropic API (if you want to use Claude instead)
11
+ ANTHROPIC_API_KEY=your-anthropic-api-key
12
+
13
+ # Alternative: OpenAI API (if you want to use OpenAI instead)
14
+ OPENAI_API_KEY=your-openai-api-key
15
+
16
+ # Optional: Ollama for local testing
17
+ OLLAMA_BASE_URL=http://localhost:11434/v1
@@ -0,0 +1,61 @@
1
+ # Build stage
2
+ FROM python:3.12-slim as builder
3
+
4
+ WORKDIR /app
5
+
6
+ # Install system dependencies
7
+ RUN apt-get update && apt-get install -y \
8
+ gcc \
9
+ postgresql-client \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ # Copy requirements and install dependencies
13
+ COPY requirements.txt .
14
+ RUN pip install --no-cache-dir --user -r requirements.txt
15
+
16
+ # Runtime stage
17
+ FROM python:3.12-slim
18
+
19
+ WORKDIR /app
20
+
21
+ # Install runtime dependencies
22
+ RUN apt-get update && apt-get install -y \
23
+ postgresql-client \
24
+ && rm -rf /var/lib/apt/lists/*
25
+
26
+ # Create non-root user first
27
+ RUN useradd -m -u 1000 appuser
28
+
29
+ # Copy Python dependencies from builder to appuser's home
30
+ COPY --from=builder /root/.local /home/appuser/.local
31
+
32
+ # Copy application code
33
+ COPY . .
34
+
35
+ # Copy and make entrypoint script executable
36
+ COPY entrypoint.sh /entrypoint.sh
37
+ RUN chmod +x /entrypoint.sh
38
+
39
+ # Change ownership
40
+ RUN chown -R appuser:appuser /app && \
41
+ chown -R appuser:appuser /home/appuser/.local && \
42
+ chown appuser:appuser /entrypoint.sh
43
+
44
+ # Switch to non-root user
45
+ USER appuser
46
+
47
+ # Make sure scripts in .local are usable
48
+ ENV PATH=/home/appuser/.local/bin:$PATH
49
+
50
+ # Expose port
51
+ EXPOSE 8000
52
+
53
+ # Health check
54
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
55
+ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health').read()"
56
+
57
+ # Use entrypoint script to run migrations and setup before starting the app
58
+ ENTRYPOINT ["/entrypoint.sh"]
59
+
60
+ # Run the application
61
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
File without changes
@@ -0,0 +1 @@
1
+ Generic single-database configuration.