flowlab 0.1.0__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 (178) hide show
  1. flowlab-0.1.0/LICENSE +21 -0
  2. flowlab-0.1.0/PKG-INFO +233 -0
  3. flowlab-0.1.0/README.md +167 -0
  4. flowlab-0.1.0/pyproject.toml +112 -0
  5. flowlab-0.1.0/setup.cfg +4 -0
  6. flowlab-0.1.0/src/flowlab/__init__.py +109 -0
  7. flowlab-0.1.0/src/flowlab/__main__.py +3 -0
  8. flowlab-0.1.0/src/flowlab/_cache.py +42 -0
  9. flowlab-0.1.0/src/flowlab/_commands.py +101 -0
  10. flowlab-0.1.0/src/flowlab/_console.py +37 -0
  11. flowlab-0.1.0/src/flowlab/_database.py +64 -0
  12. flowlab-0.1.0/src/flowlab/_exceptions.py +31 -0
  13. flowlab-0.1.0/src/flowlab/_flowlab.py +454 -0
  14. flowlab-0.1.0/src/flowlab/_handlers.py +55 -0
  15. flowlab-0.1.0/src/flowlab/_module.py +24 -0
  16. flowlab-0.1.0/src/flowlab/_queue.py +27 -0
  17. flowlab-0.1.0/src/flowlab/_routing.py +46 -0
  18. flowlab-0.1.0/src/flowlab/_settings.py +337 -0
  19. flowlab-0.1.0/src/flowlab/_state.py +32 -0
  20. flowlab-0.1.0/src/flowlab/modules/__init__.py +0 -0
  21. flowlab-0.1.0/src/flowlab/modules/auth/__init__.py +52 -0
  22. flowlab-0.1.0/src/flowlab/modules/auth/_api_keys.py +55 -0
  23. flowlab-0.1.0/src/flowlab/modules/auth/_commands.py +123 -0
  24. flowlab-0.1.0/src/flowlab/modules/auth/_dependencies.py +35 -0
  25. flowlab-0.1.0/src/flowlab/modules/auth/_email.py +2 -0
  26. flowlab-0.1.0/src/flowlab/modules/auth/_mcp.py +69 -0
  27. flowlab-0.1.0/src/flowlab/modules/auth/_models.py +62 -0
  28. flowlab-0.1.0/src/flowlab/modules/auth/_routers.py +92 -0
  29. flowlab-0.1.0/src/flowlab/modules/auth/_schema.py +27 -0
  30. flowlab-0.1.0/src/flowlab/modules/auth/_schemas.py +50 -0
  31. flowlab-0.1.0/src/flowlab/modules/auth/_security.py +97 -0
  32. flowlab-0.1.0/src/flowlab/modules/auth/_users.py +134 -0
  33. flowlab-0.1.0/src/flowlab/modules/auth/migrations/0001_01_01_000000_create_users_table.py +20 -0
  34. flowlab-0.1.0/src/flowlab/modules/auth/migrations/0001_01_01_000001_create_api_keys_table.py +25 -0
  35. flowlab-0.1.0/src/flowlab/modules/cache/__init__.py +3 -0
  36. flowlab-0.1.0/src/flowlab/modules/cache/_cache.py +121 -0
  37. flowlab-0.1.0/src/flowlab/modules/cache/adapters/__init__.py +17 -0
  38. flowlab-0.1.0/src/flowlab/modules/cache/adapters/_base.py +38 -0
  39. flowlab-0.1.0/src/flowlab/modules/cache/adapters/_database.py +107 -0
  40. flowlab-0.1.0/src/flowlab/modules/cache/adapters/_memcached.py +57 -0
  41. flowlab-0.1.0/src/flowlab/modules/cache/adapters/_redis.py +19 -0
  42. flowlab-0.1.0/src/flowlab/modules/cache/adapters/_redis_like.py +55 -0
  43. flowlab-0.1.0/src/flowlab/modules/cache/adapters/_shared_memory.py +85 -0
  44. flowlab-0.1.0/src/flowlab/modules/cache/adapters/_valkey.py +19 -0
  45. flowlab-0.1.0/src/flowlab/modules/db/__init__.py +43 -0
  46. flowlab-0.1.0/src/flowlab/modules/db/_exceptions.py +29 -0
  47. flowlab-0.1.0/src/flowlab/modules/db/_helpers.py +48 -0
  48. flowlab-0.1.0/src/flowlab/modules/db/_json.py +30 -0
  49. flowlab-0.1.0/src/flowlab/modules/db/_query_with_params.py +69 -0
  50. flowlab-0.1.0/src/flowlab/modules/db/_threading.py +295 -0
  51. flowlab-0.1.0/src/flowlab/modules/db/adapters/__init__.py +12 -0
  52. flowlab-0.1.0/src/flowlab/modules/db/adapters/_base.py +161 -0
  53. flowlab-0.1.0/src/flowlab/modules/db/adapters/_mysql.py +269 -0
  54. flowlab-0.1.0/src/flowlab/modules/db/adapters/_postgres.py +610 -0
  55. flowlab-0.1.0/src/flowlab/modules/db/adapters/_sqlite.py +364 -0
  56. flowlab-0.1.0/src/flowlab/modules/db/database/__init__.py +9 -0
  57. flowlab-0.1.0/src/flowlab/modules/db/database/_abc.py +278 -0
  58. flowlab-0.1.0/src/flowlab/modules/db/database/_copy.py +149 -0
  59. flowlab-0.1.0/src/flowlab/modules/db/database/_db.py +202 -0
  60. flowlab-0.1.0/src/flowlab/modules/db/database/_introspection.py +152 -0
  61. flowlab-0.1.0/src/flowlab/modules/db/database/_table.py +210 -0
  62. flowlab-0.1.0/src/flowlab/modules/db/dialects/__init__.py +13 -0
  63. flowlab-0.1.0/src/flowlab/modules/db/dialects/_base.py +213 -0
  64. flowlab-0.1.0/src/flowlab/modules/db/dialects/_mysql.py +306 -0
  65. flowlab-0.1.0/src/flowlab/modules/db/dialects/_postgres.py +273 -0
  66. flowlab-0.1.0/src/flowlab/modules/db/dialects/_sql_dialect.py +1197 -0
  67. flowlab-0.1.0/src/flowlab/modules/db/dialects/_sqlite.py +302 -0
  68. flowlab-0.1.0/src/flowlab/modules/db/orm/__init__.py +52 -0
  69. flowlab-0.1.0/src/flowlab/modules/db/orm/_column.py +30 -0
  70. flowlab-0.1.0/src/flowlab/modules/db/orm/_delete.py +222 -0
  71. flowlab-0.1.0/src/flowlab/modules/db/orm/_insert.py +290 -0
  72. flowlab-0.1.0/src/flowlab/modules/db/orm/_loader.py +168 -0
  73. flowlab-0.1.0/src/flowlab/modules/db/orm/_mapper.py +104 -0
  74. flowlab-0.1.0/src/flowlab/modules/db/orm/_meta.py +192 -0
  75. flowlab-0.1.0/src/flowlab/modules/db/orm/_model.py +9 -0
  76. flowlab-0.1.0/src/flowlab/modules/db/orm/_relation.py +212 -0
  77. flowlab-0.1.0/src/flowlab/modules/db/orm/_select.py +50 -0
  78. flowlab-0.1.0/src/flowlab/modules/db/orm/_tree.py +75 -0
  79. flowlab-0.1.0/src/flowlab/modules/db/orm/_update.py +125 -0
  80. flowlab-0.1.0/src/flowlab/modules/db/orm/enums/__init__.py +5 -0
  81. flowlab-0.1.0/src/flowlab/modules/db/orm/enums/_relation.py +8 -0
  82. flowlab-0.1.0/src/flowlab/modules/db/query/__init__.py +41 -0
  83. flowlab-0.1.0/src/flowlab/modules/db/query/_alter_table.py +28 -0
  84. flowlab-0.1.0/src/flowlab/modules/db/query/_condition.py +20 -0
  85. flowlab-0.1.0/src/flowlab/modules/db/query/_condition_group.py +24 -0
  86. flowlab-0.1.0/src/flowlab/modules/db/query/_condition_mixin.py +370 -0
  87. flowlab-0.1.0/src/flowlab/modules/db/query/_create_index.py +61 -0
  88. flowlab-0.1.0/src/flowlab/modules/db/query/_create_table.py +39 -0
  89. flowlab-0.1.0/src/flowlab/modules/db/query/_ddl_mixins.py +310 -0
  90. flowlab-0.1.0/src/flowlab/modules/db/query/_delete.py +31 -0
  91. flowlab-0.1.0/src/flowlab/modules/db/query/_drop_index.py +43 -0
  92. flowlab-0.1.0/src/flowlab/modules/db/query/_drop_table.py +31 -0
  93. flowlab-0.1.0/src/flowlab/modules/db/query/_having_mixin.py +286 -0
  94. flowlab-0.1.0/src/flowlab/modules/db/query/_insert.py +235 -0
  95. flowlab-0.1.0/src/flowlab/modules/db/query/_join.py +293 -0
  96. flowlab-0.1.0/src/flowlab/modules/db/query/_joins_mixin.py +142 -0
  97. flowlab-0.1.0/src/flowlab/modules/db/query/_on_conflict.py +10 -0
  98. flowlab-0.1.0/src/flowlab/modules/db/query/_order_by.py +15 -0
  99. flowlab-0.1.0/src/flowlab/modules/db/query/_query.py +77 -0
  100. flowlab-0.1.0/src/flowlab/modules/db/query/_select.py +79 -0
  101. flowlab-0.1.0/src/flowlab/modules/db/query/_simple_mixins.py +159 -0
  102. flowlab-0.1.0/src/flowlab/modules/db/query/_union.py +15 -0
  103. flowlab-0.1.0/src/flowlab/modules/db/query/_update.py +29 -0
  104. flowlab-0.1.0/src/flowlab/modules/db/query/_where_mixin.py +286 -0
  105. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/__init__.py +38 -0
  106. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_add_column.py +11 -0
  107. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_add_foreign_key_constraint.py +11 -0
  108. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_add_primary_keys.py +10 -0
  109. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_add_unique_constraint.py +11 -0
  110. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_alter.py +7 -0
  111. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_alter_column.py +11 -0
  112. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_column.py +16 -0
  113. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_constraint.py +7 -0
  114. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_drop_column.py +10 -0
  115. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_drop_constraint.py +10 -0
  116. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_foreign_key_constraint.py +16 -0
  117. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_index.py +10 -0
  118. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_raw_alter.py +10 -0
  119. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_raw_constraint.py +10 -0
  120. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_rename_column.py +11 -0
  121. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_table_description.py +91 -0
  122. flowlab-0.1.0/src/flowlab/modules/db/query/ddl/_unique_constraint.py +11 -0
  123. flowlab-0.1.0/src/flowlab/modules/db/query/enums/__init__.py +17 -0
  124. flowlab-0.1.0/src/flowlab/modules/db/query/enums/_chain.py +6 -0
  125. flowlab-0.1.0/src/flowlab/modules/db/query/enums/_condition.py +23 -0
  126. flowlab-0.1.0/src/flowlab/modules/db/query/enums/_join.py +10 -0
  127. flowlab-0.1.0/src/flowlab/modules/db/query/enums/_order_by_dir.py +6 -0
  128. flowlab-0.1.0/src/flowlab/modules/db/query/enums/_referential_action.py +32 -0
  129. flowlab-0.1.0/src/flowlab/modules/db/query/enums/_type.py +10 -0
  130. flowlab-0.1.0/src/flowlab/modules/db/query/enums/_union.py +6 -0
  131. flowlab-0.1.0/src/flowlab/modules/db/query/expressions/__init__.py +22 -0
  132. flowlab-0.1.0/src/flowlab/modules/db/query/expressions/_alias.py +41 -0
  133. flowlab-0.1.0/src/flowlab/modules/db/query/expressions/_current_timestamp.py +19 -0
  134. flowlab-0.1.0/src/flowlab/modules/db/query/expressions/_excluded.py +13 -0
  135. flowlab-0.1.0/src/flowlab/modules/db/query/expressions/_expression.py +26 -0
  136. flowlab-0.1.0/src/flowlab/modules/db/query/expressions/_identifier.py +22 -0
  137. flowlab-0.1.0/src/flowlab/modules/db/query/expressions/_postgres_array.py +33 -0
  138. flowlab-0.1.0/src/flowlab/modules/db/query/expressions/_raw.py +22 -0
  139. flowlab-0.1.0/src/flowlab/modules/db/query/expressions/_sql.py +18 -0
  140. flowlab-0.1.0/src/flowlab/modules/db/query/expressions/_sub_query.py +26 -0
  141. flowlab-0.1.0/src/flowlab/modules/db/result/__init__.py +15 -0
  142. flowlab-0.1.0/src/flowlab/modules/db/result/_base.py +50 -0
  143. flowlab-0.1.0/src/flowlab/modules/db/result/_mysql.py +107 -0
  144. flowlab-0.1.0/src/flowlab/modules/db/result/_postgres.py +178 -0
  145. flowlab-0.1.0/src/flowlab/modules/db/result/_result.py +30 -0
  146. flowlab-0.1.0/src/flowlab/modules/db/result/_sqlite.py +65 -0
  147. flowlab-0.1.0/src/flowlab/modules/migrator/__init__.py +12 -0
  148. flowlab-0.1.0/src/flowlab/modules/migrator/_loader.py +52 -0
  149. flowlab-0.1.0/src/flowlab/modules/migrator/_migration_abc.py +20 -0
  150. flowlab-0.1.0/src/flowlab/modules/migrator/_migrator.py +108 -0
  151. flowlab-0.1.0/src/flowlab/modules/migrator/_schema.py +72 -0
  152. flowlab-0.1.0/src/flowlab/modules/migrator/_template.py +35 -0
  153. flowlab-0.1.0/src/flowlab/modules/queue/__init__.py +29 -0
  154. flowlab-0.1.0/src/flowlab/modules/queue/_commands.py +100 -0
  155. flowlab-0.1.0/src/flowlab/modules/queue/_job.py +134 -0
  156. flowlab-0.1.0/src/flowlab/modules/queue/_queue.py +138 -0
  157. flowlab-0.1.0/src/flowlab/modules/queue/_schema.py +28 -0
  158. flowlab-0.1.0/src/flowlab/modules/queue/_worker.py +126 -0
  159. flowlab-0.1.0/src/flowlab/modules/queue/adapters/__init__.py +17 -0
  160. flowlab-0.1.0/src/flowlab/modules/queue/adapters/_base.py +70 -0
  161. flowlab-0.1.0/src/flowlab/modules/queue/adapters/_database.py +164 -0
  162. flowlab-0.1.0/src/flowlab/modules/queue/adapters/_redis.py +20 -0
  163. flowlab-0.1.0/src/flowlab/modules/queue/adapters/_redis_like.py +164 -0
  164. flowlab-0.1.0/src/flowlab/modules/queue/adapters/_sync.py +43 -0
  165. flowlab-0.1.0/src/flowlab/modules/queue/adapters/_valkey.py +20 -0
  166. flowlab-0.1.0/src/flowlab/modules/queue/migrations/0001_01_01_000002_create_jobs_table.py +41 -0
  167. flowlab-0.1.0/src/flowlab/modules/ratelimit/__init__.py +15 -0
  168. flowlab-0.1.0/src/flowlab/modules/ratelimit/_http.py +62 -0
  169. flowlab-0.1.0/src/flowlab/modules/ratelimit/_limiter.py +69 -0
  170. flowlab-0.1.0/src/flowlab/modules/ratelimit/_limits.py +44 -0
  171. flowlab-0.1.0/src/flowlab/modules/ratelimit/_mcp.py +64 -0
  172. flowlab-0.1.0/src/flowlab/py.typed +0 -0
  173. flowlab-0.1.0/src/flowlab.egg-info/PKG-INFO +233 -0
  174. flowlab-0.1.0/src/flowlab.egg-info/SOURCES.txt +176 -0
  175. flowlab-0.1.0/src/flowlab.egg-info/dependency_links.txt +1 -0
  176. flowlab-0.1.0/src/flowlab.egg-info/entry_points.txt +2 -0
  177. flowlab-0.1.0/src/flowlab.egg-info/requires.txt +48 -0
  178. flowlab-0.1.0/src/flowlab.egg-info/top_level.txt +1 -0
flowlab-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Flowmatic
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.
flowlab-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,233 @@
1
+ Metadata-Version: 2.4
2
+ Name: flowlab
3
+ Version: 0.1.0
4
+ Summary: An API framework on FastAPI that also serves an MCP server and a command runner from the same app, with database, cache, migrations, auth, queues and rate limiting built in.
5
+ Author: Flowmatic, UniForceMusic
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Flowmatic-AI/flowlab
8
+ Project-URL: Repository, https://github.com/Flowmatic-AI/flowlab
9
+ Project-URL: Documentation, https://github.com/Flowmatic-AI/flowlab/tree/main/package/docs
10
+ Project-URL: Issues, https://github.com/Flowmatic-AI/flowlab/issues
11
+ Keywords: fastapi,mcp,typer,framework,database,orm,cache,auth,queue,rate-limit
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Framework :: FastAPI
19
+ Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
20
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.12
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: fastapi>=0.135
26
+ Requires-Dist: fastmcp>=3.0
27
+ Requires-Dist: typer>=0.15
28
+ Requires-Dist: uvicorn[standard]>=0.30
29
+ Requires-Dist: pydantic>=2.0
30
+ Requires-Dist: pydantic-settings>=2.0
31
+ Requires-Dist: email-validator>=2.0
32
+ Requires-Dist: bcrypt>=4.0
33
+ Requires-Dist: PyJWT>=2.8
34
+ Provides-Extra: postgres
35
+ Requires-Dist: psycopg[binary]>=3.1; extra == "postgres"
36
+ Provides-Extra: asyncpg
37
+ Requires-Dist: asyncpg>=0.29; extra == "asyncpg"
38
+ Provides-Extra: mysql
39
+ Requires-Dist: mysql-connector-python>=9.0; extra == "mysql"
40
+ Provides-Extra: redis
41
+ Requires-Dist: redis>=5.0; extra == "redis"
42
+ Provides-Extra: valkey
43
+ Requires-Dist: valkey>=6.0; extra == "valkey"
44
+ Provides-Extra: memcached
45
+ Requires-Dist: pymemcache>=4.0; extra == "memcached"
46
+ Provides-Extra: all
47
+ Requires-Dist: psycopg[binary]>=3.1; extra == "all"
48
+ Requires-Dist: asyncpg>=0.29; extra == "all"
49
+ Requires-Dist: mysql-connector-python>=9.0; extra == "all"
50
+ Requires-Dist: redis>=5.0; extra == "all"
51
+ Requires-Dist: valkey>=6.0; extra == "all"
52
+ Requires-Dist: pymemcache>=4.0; extra == "all"
53
+ Provides-Extra: dev
54
+ Requires-Dist: build>=1.2; extra == "dev"
55
+ Requires-Dist: twine>=5.0; extra == "dev"
56
+ Requires-Dist: pytest>=7.0; extra == "dev"
57
+ Requires-Dist: httpx>=0.27; extra == "dev"
58
+ Requires-Dist: mypy>=1.0; extra == "dev"
59
+ Requires-Dist: ruff>=0.1; extra == "dev"
60
+ Requires-Dist: psycopg[binary]>=3.1; extra == "dev"
61
+ Requires-Dist: mysql-connector-python>=9.0; extra == "dev"
62
+ Requires-Dist: redis>=5.0; extra == "dev"
63
+ Requires-Dist: valkey>=6.0; extra == "dev"
64
+ Requires-Dist: pymemcache>=4.0; extra == "dev"
65
+ Dynamic: license-file
66
+
67
+ # flowlab
68
+
69
+ An API framework like FastAPI that also serves an MCP server at `/mcp` and runs
70
+ console commands, all from one app object. Database, cache, migrations and auth
71
+ are built in.
72
+
73
+ ```bash
74
+ pip install flowlab
75
+ ```
76
+
77
+ ```python
78
+ from flowlab import AuthSettings, FlowLab
79
+
80
+ app = FlowLab(auth_settings=AuthSettings())
81
+
82
+
83
+ @app.get("/")
84
+ def index() -> dict[str, str]:
85
+ return {"message": "Hello"}
86
+
87
+
88
+ @app.tool
89
+ def hello(name: str) -> str:
90
+ return f"Hello, {name}!"
91
+
92
+
93
+ @app.command("hello:say")
94
+ def say(name: str) -> None:
95
+ print(f"Hello, {name}!")
96
+
97
+
98
+ if __name__ == "__main__":
99
+ app.run()
100
+ ```
101
+
102
+ Every migration lives in the project's `migrations/` folder, including the
103
+ ones auth needs. `python main.py auth:install` copies them in (the starter
104
+ project already has them). For extra user fields, pass your own `user_model`;
105
+ see [docs/auth.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/auth.md#your-user-model).
106
+
107
+ ```bash
108
+ python main.py auth:install # once: copies the users and api_keys migrations into migrations/
109
+ python main.py migrations:up
110
+ python main.py server:start # or: flowlab server:start (loads main:app from the cwd)
111
+ ```
112
+
113
+ ## The FlowLab class
114
+
115
+ `FlowLab(fastapi_settings=None, fastmcp_settings=None, typer_settings=None, *, database_settings=None, cache_settings=None, auth_settings=None, user_model=None, project_dir=None, **kwargs)`
116
+
117
+ Every settings argument is optional; when it's left out, the settings are read
118
+ from the environment and `.env`.
119
+
120
+ FlowLab is a singleton: the database, cache, migrator and auth live on the one
121
+ app.
122
+
123
+ - `FlowLab.instance()` returns the app. Before one is created it raises
124
+ `FlowLabNotInitialized`, and so do `get_db()`, `get_cache()` and the `DB` /
125
+ `Cache` dependencies. Creating a second app raises
126
+ `FlowLabAlreadyInitialized`. `FlowLab.reset()` closes and forgets the app
127
+ (for tests); `FlowLab.initialized()` says whether one exists.
128
+ - `app.db`, `app.cache`: the open connections. Outside `app.lifespan()` (or a
129
+ running server / command) they raise `NotConnected`.
130
+ - `app.migrator`: a `Migrator` over the project's `migrations/` folder
131
+ (`app.migrations_dir`). The package never runs migrations of its own.
132
+ - `app.auth`: the `AuthSettings`. Auth is on when `auth_settings` is passed,
133
+ which wires its routes, MCP tools and commands; otherwise
134
+ `app.auth` raises `AuthNotEnabled`.
135
+ - `**kwargs` are passed to `FastAPI(...)`.
136
+ - `project_dir` defaults to the directory of the file that creates the app. A
137
+ relative sqlite `DB_NAME` and the `migrations/` folder resolve against it.
138
+ - `app` is itself an ASGI app (`uvicorn main:app` works). `app.api` is the
139
+ FastAPI instance, `app.mcp` the FastMCP server, `app.cli` the Typer app.
140
+ - Routes: `app.get/post/put/patch/delete/api_route`, `app.include_router`,
141
+ `app.add_middleware`, `app.exception_handler`.
142
+ - MCP: `app.tool`, `app.resource`, `app.prompt`. Served at `MCP_PATH` (`/mcp`)
143
+ as a stateless JSON route.
144
+ - CLI: `app.command("namespace:verb", lifespan=True)`. Commands run inside the
145
+ app lifespan (database and cache open) unless `lifespan=False`.
146
+ - `app.lifespan()` is the one lifecycle used by HTTP, MCP and the CLI.
147
+ `app.add_lifespan(factory)` adds a process-wide client to it. With
148
+ `CACHE_DRIVER=database`, opening the cache at startup runs
149
+ `CREATE TABLE IF NOT EXISTS` for `CACHE_TABLE`; there is no migration for it.
150
+ - `app.include_module(module)` adds a module's routers. A module with
151
+ migration templates gets a `<name>:install` command that copies the ones the
152
+ project doesn't have yet into `migrations/`, and a module with a schema check
153
+ stops the server at startup with `SchemaMismatch` when its tables or columns
154
+ are missing.
155
+ - `app.user_model`: your `BaseUser` subclass, passed as `user_model` (see
156
+ [docs/auth.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/auth.md#your-user-model)).
157
+ - `app.include_router(router, **options)` takes all three kinds of router
158
+ (see below).
159
+
160
+ Built-in commands: `server:start`, `migrations:init|up|down|fresh|make`, `test`,
161
+ `queue:install|work|failed|retry|forget|flush|clear`.
162
+
163
+ Run the CLI with `python main.py <command>`, `flowlab <command>` or
164
+ `python -m flowlab <command>`. The last two load `main:app` from the working
165
+ directory; pick another app with `--app module:attribute` or `FLOWLAB_APP`.
166
+
167
+ ## Routers
168
+
169
+ Split a project over files with one router per surface, then include each one:
170
+
171
+ ```python
172
+ from flowlab import APIRouter, CommandRouter, MCPRouter
173
+
174
+ api = APIRouter(prefix="/posts") # FastAPI's APIRouter
175
+
176
+
177
+ @api.get("/")
178
+ def posts() -> list[str]:
179
+ return []
180
+
181
+
182
+ mcp = MCPRouter("posts") # a FastMCP server
183
+
184
+
185
+ @mcp.tool
186
+ def count_posts() -> int:
187
+ return 0
188
+
189
+
190
+ console = CommandRouter()
191
+
192
+
193
+ @console.command("posts:prune")
194
+ def prune() -> None:
195
+ print("Pruned.")
196
+
197
+
198
+ app.include_router(api, tags=["posts"]) # options go to FastAPI.include_router
199
+ app.include_router(mcp, namespace="posts") # options go to FastMCP.mount; the tool becomes posts_count_posts
200
+ app.include_router(console)
201
+ ```
202
+
203
+ `flowlab` also re-exports the FastAPI names a project needs, so routes can
204
+ import from one place: `APIRouter`, `Depends`, `HTTPException`, `Request`,
205
+ `Response`, `Query`, `Path`, `Body`, `Header`, `Cookie`, `Form`, `File`,
206
+ `UploadFile`, `BackgroundTasks`, `Security`, `WebSocket`, `WebSocketDisconnect`
207
+ and `status`.
208
+
209
+ ## Settings
210
+
211
+ All settings classes live in `flowlab._settings` and are exported from
212
+ `flowlab`: `FastAPISettings`, `FastMCPSettings`, `TyperSettings`,
213
+ `DatabaseSettings`, `CacheSettings`, `QueueSettings`, `AuthSettings`. They read the environment
214
+ and `.env` (from the working directory and from the directory of the script
215
+ being run).
216
+
217
+ ## Modules
218
+
219
+ - `flowlab.modules.db`: query builder and ORM for SQLite,
220
+ PostgreSQL, MySQL and MariaDB. See [docs/db.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/db.md).
221
+ - `flowlab.modules.cache`: memory, database, Redis, Valkey and Memcached
222
+ caches. See [docs/cache.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/cache.md).
223
+ - `flowlab.modules.migrator`: file-based migrations, publishing templates, schema
224
+ drop helpers. See [docs/migrator.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/migrator.md).
225
+ - `flowlab.modules.auth`: users, JWT login, API keys, MCP API key auth. See
226
+ [docs/auth.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/auth.md).
227
+ - `flowlab.modules.ratelimit`: rate limits for routes and MCP tools, counted in
228
+ the cache. See [docs/ratelimit.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/ratelimit.md).
229
+ - `flowlab.modules.queue`: background jobs with `@job`, workers and failed-job
230
+ commands, on the database, Redis or Valkey. See [docs/queue.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/queue.md).
231
+
232
+ Extras: `flowlab[postgres]`, `flowlab[mysql]`, `flowlab[asyncpg]`,
233
+ `flowlab[redis]`, `flowlab[valkey]`, `flowlab[memcached]`, `flowlab[all]`.
@@ -0,0 +1,167 @@
1
+ # flowlab
2
+
3
+ An API framework like FastAPI that also serves an MCP server at `/mcp` and runs
4
+ console commands, all from one app object. Database, cache, migrations and auth
5
+ are built in.
6
+
7
+ ```bash
8
+ pip install flowlab
9
+ ```
10
+
11
+ ```python
12
+ from flowlab import AuthSettings, FlowLab
13
+
14
+ app = FlowLab(auth_settings=AuthSettings())
15
+
16
+
17
+ @app.get("/")
18
+ def index() -> dict[str, str]:
19
+ return {"message": "Hello"}
20
+
21
+
22
+ @app.tool
23
+ def hello(name: str) -> str:
24
+ return f"Hello, {name}!"
25
+
26
+
27
+ @app.command("hello:say")
28
+ def say(name: str) -> None:
29
+ print(f"Hello, {name}!")
30
+
31
+
32
+ if __name__ == "__main__":
33
+ app.run()
34
+ ```
35
+
36
+ Every migration lives in the project's `migrations/` folder, including the
37
+ ones auth needs. `python main.py auth:install` copies them in (the starter
38
+ project already has them). For extra user fields, pass your own `user_model`;
39
+ see [docs/auth.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/auth.md#your-user-model).
40
+
41
+ ```bash
42
+ python main.py auth:install # once: copies the users and api_keys migrations into migrations/
43
+ python main.py migrations:up
44
+ python main.py server:start # or: flowlab server:start (loads main:app from the cwd)
45
+ ```
46
+
47
+ ## The FlowLab class
48
+
49
+ `FlowLab(fastapi_settings=None, fastmcp_settings=None, typer_settings=None, *, database_settings=None, cache_settings=None, auth_settings=None, user_model=None, project_dir=None, **kwargs)`
50
+
51
+ Every settings argument is optional; when it's left out, the settings are read
52
+ from the environment and `.env`.
53
+
54
+ FlowLab is a singleton: the database, cache, migrator and auth live on the one
55
+ app.
56
+
57
+ - `FlowLab.instance()` returns the app. Before one is created it raises
58
+ `FlowLabNotInitialized`, and so do `get_db()`, `get_cache()` and the `DB` /
59
+ `Cache` dependencies. Creating a second app raises
60
+ `FlowLabAlreadyInitialized`. `FlowLab.reset()` closes and forgets the app
61
+ (for tests); `FlowLab.initialized()` says whether one exists.
62
+ - `app.db`, `app.cache`: the open connections. Outside `app.lifespan()` (or a
63
+ running server / command) they raise `NotConnected`.
64
+ - `app.migrator`: a `Migrator` over the project's `migrations/` folder
65
+ (`app.migrations_dir`). The package never runs migrations of its own.
66
+ - `app.auth`: the `AuthSettings`. Auth is on when `auth_settings` is passed,
67
+ which wires its routes, MCP tools and commands; otherwise
68
+ `app.auth` raises `AuthNotEnabled`.
69
+ - `**kwargs` are passed to `FastAPI(...)`.
70
+ - `project_dir` defaults to the directory of the file that creates the app. A
71
+ relative sqlite `DB_NAME` and the `migrations/` folder resolve against it.
72
+ - `app` is itself an ASGI app (`uvicorn main:app` works). `app.api` is the
73
+ FastAPI instance, `app.mcp` the FastMCP server, `app.cli` the Typer app.
74
+ - Routes: `app.get/post/put/patch/delete/api_route`, `app.include_router`,
75
+ `app.add_middleware`, `app.exception_handler`.
76
+ - MCP: `app.tool`, `app.resource`, `app.prompt`. Served at `MCP_PATH` (`/mcp`)
77
+ as a stateless JSON route.
78
+ - CLI: `app.command("namespace:verb", lifespan=True)`. Commands run inside the
79
+ app lifespan (database and cache open) unless `lifespan=False`.
80
+ - `app.lifespan()` is the one lifecycle used by HTTP, MCP and the CLI.
81
+ `app.add_lifespan(factory)` adds a process-wide client to it. With
82
+ `CACHE_DRIVER=database`, opening the cache at startup runs
83
+ `CREATE TABLE IF NOT EXISTS` for `CACHE_TABLE`; there is no migration for it.
84
+ - `app.include_module(module)` adds a module's routers. A module with
85
+ migration templates gets a `<name>:install` command that copies the ones the
86
+ project doesn't have yet into `migrations/`, and a module with a schema check
87
+ stops the server at startup with `SchemaMismatch` when its tables or columns
88
+ are missing.
89
+ - `app.user_model`: your `BaseUser` subclass, passed as `user_model` (see
90
+ [docs/auth.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/auth.md#your-user-model)).
91
+ - `app.include_router(router, **options)` takes all three kinds of router
92
+ (see below).
93
+
94
+ Built-in commands: `server:start`, `migrations:init|up|down|fresh|make`, `test`,
95
+ `queue:install|work|failed|retry|forget|flush|clear`.
96
+
97
+ Run the CLI with `python main.py <command>`, `flowlab <command>` or
98
+ `python -m flowlab <command>`. The last two load `main:app` from the working
99
+ directory; pick another app with `--app module:attribute` or `FLOWLAB_APP`.
100
+
101
+ ## Routers
102
+
103
+ Split a project over files with one router per surface, then include each one:
104
+
105
+ ```python
106
+ from flowlab import APIRouter, CommandRouter, MCPRouter
107
+
108
+ api = APIRouter(prefix="/posts") # FastAPI's APIRouter
109
+
110
+
111
+ @api.get("/")
112
+ def posts() -> list[str]:
113
+ return []
114
+
115
+
116
+ mcp = MCPRouter("posts") # a FastMCP server
117
+
118
+
119
+ @mcp.tool
120
+ def count_posts() -> int:
121
+ return 0
122
+
123
+
124
+ console = CommandRouter()
125
+
126
+
127
+ @console.command("posts:prune")
128
+ def prune() -> None:
129
+ print("Pruned.")
130
+
131
+
132
+ app.include_router(api, tags=["posts"]) # options go to FastAPI.include_router
133
+ app.include_router(mcp, namespace="posts") # options go to FastMCP.mount; the tool becomes posts_count_posts
134
+ app.include_router(console)
135
+ ```
136
+
137
+ `flowlab` also re-exports the FastAPI names a project needs, so routes can
138
+ import from one place: `APIRouter`, `Depends`, `HTTPException`, `Request`,
139
+ `Response`, `Query`, `Path`, `Body`, `Header`, `Cookie`, `Form`, `File`,
140
+ `UploadFile`, `BackgroundTasks`, `Security`, `WebSocket`, `WebSocketDisconnect`
141
+ and `status`.
142
+
143
+ ## Settings
144
+
145
+ All settings classes live in `flowlab._settings` and are exported from
146
+ `flowlab`: `FastAPISettings`, `FastMCPSettings`, `TyperSettings`,
147
+ `DatabaseSettings`, `CacheSettings`, `QueueSettings`, `AuthSettings`. They read the environment
148
+ and `.env` (from the working directory and from the directory of the script
149
+ being run).
150
+
151
+ ## Modules
152
+
153
+ - `flowlab.modules.db`: query builder and ORM for SQLite,
154
+ PostgreSQL, MySQL and MariaDB. See [docs/db.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/db.md).
155
+ - `flowlab.modules.cache`: memory, database, Redis, Valkey and Memcached
156
+ caches. See [docs/cache.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/cache.md).
157
+ - `flowlab.modules.migrator`: file-based migrations, publishing templates, schema
158
+ drop helpers. See [docs/migrator.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/migrator.md).
159
+ - `flowlab.modules.auth`: users, JWT login, API keys, MCP API key auth. See
160
+ [docs/auth.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/auth.md).
161
+ - `flowlab.modules.ratelimit`: rate limits for routes and MCP tools, counted in
162
+ the cache. See [docs/ratelimit.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/ratelimit.md).
163
+ - `flowlab.modules.queue`: background jobs with `@job`, workers and failed-job
164
+ commands, on the database, Redis or Valkey. See [docs/queue.md](https://github.com/Flowmatic-AI/flowlab/blob/main/package/docs/queue.md).
165
+
166
+ Extras: `flowlab[postgres]`, `flowlab[mysql]`, `flowlab[asyncpg]`,
167
+ `flowlab[redis]`, `flowlab[valkey]`, `flowlab[memcached]`, `flowlab[all]`.
@@ -0,0 +1,112 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "flowlab"
7
+ version = "0.1.0"
8
+ description = "An API framework on FastAPI that also serves an MCP server and a command runner from the same app, with database, cache, migrations, auth, queues and rate limiting built in."
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ keywords = ["fastapi", "mcp", "typer", "framework", "database", "orm", "cache", "auth", "queue", "rate-limit"]
14
+
15
+ authors = [
16
+ {name = "Flowmatic"},
17
+ {name = "UniForceMusic"},
18
+ ]
19
+
20
+ classifiers = [
21
+ "Development Status :: 3 - Alpha",
22
+ "Intended Audience :: Developers",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Programming Language :: Python :: 3.14",
27
+ "Framework :: FastAPI",
28
+ "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
29
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
30
+ "Typing :: Typed",
31
+ ]
32
+
33
+ dependencies = [
34
+ "fastapi>=0.135",
35
+ "fastmcp>=3.0",
36
+ "typer>=0.15",
37
+ "uvicorn[standard]>=0.30",
38
+ "pydantic>=2.0",
39
+ "pydantic-settings>=2.0",
40
+ "email-validator>=2.0",
41
+ "bcrypt>=4.0",
42
+ "PyJWT>=2.8",
43
+ ]
44
+
45
+ [project.optional-dependencies]
46
+ postgres = ["psycopg[binary]>=3.1"]
47
+ asyncpg = ["asyncpg>=0.29"]
48
+ mysql = ["mysql-connector-python>=9.0"]
49
+ redis = ["redis>=5.0"]
50
+ valkey = ["valkey>=6.0"]
51
+ memcached = ["pymemcache>=4.0"]
52
+ all = [
53
+ "psycopg[binary]>=3.1",
54
+ "asyncpg>=0.29",
55
+ "mysql-connector-python>=9.0",
56
+ "redis>=5.0",
57
+ "valkey>=6.0",
58
+ "pymemcache>=4.0",
59
+ ]
60
+ dev = [
61
+ "build>=1.2",
62
+ "twine>=5.0",
63
+ "pytest>=7.0",
64
+ "httpx>=0.27",
65
+ "mypy>=1.0",
66
+ "ruff>=0.1",
67
+ "psycopg[binary]>=3.1",
68
+ "mysql-connector-python>=9.0",
69
+ "redis>=5.0",
70
+ "valkey>=6.0",
71
+ "pymemcache>=4.0",
72
+ ]
73
+
74
+ [project.scripts]
75
+ flowlab = "flowlab._console:main"
76
+
77
+ [project.urls]
78
+ Homepage = "https://github.com/Flowmatic-AI/flowlab"
79
+ Repository = "https://github.com/Flowmatic-AI/flowlab"
80
+ Documentation = "https://github.com/Flowmatic-AI/flowlab/tree/main/package/docs"
81
+ Issues = "https://github.com/Flowmatic-AI/flowlab/issues"
82
+
83
+ [tool.setuptools.packages.find]
84
+ where = ["src"]
85
+
86
+ [tool.setuptools.package-data]
87
+ flowlab = ["py.typed", "**/migrations/*.py"]
88
+
89
+ [tool.pytest.ini_options]
90
+ testpaths = ["tests"]
91
+ python_files = ["test_*.py"]
92
+ addopts = ["--import-mode=importlib"]
93
+
94
+ [tool.mypy]
95
+ strict = true
96
+ python_version = "3.12"
97
+ ignore_missing_imports = true
98
+
99
+ [tool.ruff]
100
+ target-version = "py312"
101
+ line-length = 120
102
+
103
+ [tool.ruff.lint]
104
+ ignore = ["UP040", "UP046", "UP047"]
105
+
106
+ [tool.ruff.lint.flake8-bugbear]
107
+ extend-immutable-calls = [
108
+ "flowlab.modules.auth.CurrentMCPUser",
109
+ "flowlab.modules.auth._mcp.CurrentMCPUser",
110
+ "flowlab.modules.ratelimit.MCPRateLimit",
111
+ "flowlab.modules.ratelimit._mcp.MCPRateLimit",
112
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,109 @@
1
+ from importlib.metadata import PackageNotFoundError, version
2
+
3
+ from fastapi import (
4
+ APIRouter,
5
+ BackgroundTasks,
6
+ Body,
7
+ Cookie,
8
+ Depends,
9
+ File,
10
+ Form,
11
+ Header,
12
+ HTTPException,
13
+ Path,
14
+ Query,
15
+ Request,
16
+ Response,
17
+ Security,
18
+ UploadFile,
19
+ WebSocket,
20
+ WebSocketDisconnect,
21
+ status,
22
+ )
23
+ from fastmcp.dependencies import Depends as MCPDepends
24
+
25
+ from flowlab._cache import Cache, get_cache
26
+ from flowlab._database import DB, INTEGRITY_ERRORS, get_db
27
+ from flowlab._exceptions import (
28
+ AuthNotEnabled,
29
+ FlowLabAlreadyInitialized,
30
+ FlowLabError,
31
+ FlowLabNotInitialized,
32
+ NotConnected,
33
+ SchemaMismatch,
34
+ )
35
+ from flowlab._flowlab import FlowLab
36
+ from flowlab._module import Module
37
+ from flowlab._queue import get_queue
38
+ from flowlab._routing import Command, CommandRouter, MCPRouter
39
+ from flowlab._settings import (
40
+ AppEnv,
41
+ AuthSettings,
42
+ CacheDriver,
43
+ CacheSettings,
44
+ DatabaseSettings,
45
+ DBDriver,
46
+ FastAPISettings,
47
+ FastMCPSettings,
48
+ QueueDriver,
49
+ QueueSettings,
50
+ TyperSettings,
51
+ )
52
+ from flowlab._state import get_app
53
+
54
+ try:
55
+ __version__ = version("flowlab")
56
+ except PackageNotFoundError: # pragma: no cover - running from a source tree without metadata
57
+ __version__ = "0.0.0"
58
+
59
+ __all__ = [
60
+ "DB",
61
+ "INTEGRITY_ERRORS",
62
+ "APIRouter",
63
+ "AppEnv",
64
+ "AuthNotEnabled",
65
+ "AuthSettings",
66
+ "BackgroundTasks",
67
+ "Body",
68
+ "Cache",
69
+ "CacheDriver",
70
+ "CacheSettings",
71
+ "Command",
72
+ "CommandRouter",
73
+ "Cookie",
74
+ "DBDriver",
75
+ "DatabaseSettings",
76
+ "Depends",
77
+ "FastAPISettings",
78
+ "FastMCPSettings",
79
+ "File",
80
+ "FlowLab",
81
+ "FlowLabAlreadyInitialized",
82
+ "FlowLabError",
83
+ "FlowLabNotInitialized",
84
+ "Form",
85
+ "HTTPException",
86
+ "Header",
87
+ "MCPDepends",
88
+ "MCPRouter",
89
+ "Module",
90
+ "NotConnected",
91
+ "Path",
92
+ "Query",
93
+ "QueueDriver",
94
+ "QueueSettings",
95
+ "Request",
96
+ "Response",
97
+ "SchemaMismatch",
98
+ "Security",
99
+ "TyperSettings",
100
+ "UploadFile",
101
+ "WebSocket",
102
+ "WebSocketDisconnect",
103
+ "__version__",
104
+ "get_app",
105
+ "get_cache",
106
+ "get_db",
107
+ "get_queue",
108
+ "status",
109
+ ]
@@ -0,0 +1,3 @@
1
+ from flowlab._console import main
2
+
3
+ main()