mdb-engine 0.1.6__py3-none-any.whl → 0.2.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 (87) hide show
  1. mdb_engine/__init__.py +104 -11
  2. mdb_engine/auth/ARCHITECTURE.md +112 -0
  3. mdb_engine/auth/README.md +648 -11
  4. mdb_engine/auth/__init__.py +136 -29
  5. mdb_engine/auth/audit.py +592 -0
  6. mdb_engine/auth/base.py +252 -0
  7. mdb_engine/auth/casbin_factory.py +264 -69
  8. mdb_engine/auth/config_helpers.py +7 -6
  9. mdb_engine/auth/cookie_utils.py +3 -7
  10. mdb_engine/auth/csrf.py +373 -0
  11. mdb_engine/auth/decorators.py +3 -10
  12. mdb_engine/auth/dependencies.py +47 -50
  13. mdb_engine/auth/helpers.py +3 -3
  14. mdb_engine/auth/integration.py +53 -80
  15. mdb_engine/auth/jwt.py +2 -6
  16. mdb_engine/auth/middleware.py +77 -34
  17. mdb_engine/auth/oso_factory.py +18 -38
  18. mdb_engine/auth/provider.py +270 -171
  19. mdb_engine/auth/rate_limiter.py +504 -0
  20. mdb_engine/auth/restrictions.py +8 -24
  21. mdb_engine/auth/session_manager.py +14 -29
  22. mdb_engine/auth/shared_middleware.py +600 -0
  23. mdb_engine/auth/shared_users.py +759 -0
  24. mdb_engine/auth/token_store.py +14 -28
  25. mdb_engine/auth/users.py +54 -113
  26. mdb_engine/auth/utils.py +213 -15
  27. mdb_engine/cli/commands/generate.py +545 -9
  28. mdb_engine/cli/commands/validate.py +3 -7
  29. mdb_engine/cli/utils.py +3 -3
  30. mdb_engine/config.py +7 -21
  31. mdb_engine/constants.py +65 -0
  32. mdb_engine/core/README.md +117 -6
  33. mdb_engine/core/__init__.py +39 -7
  34. mdb_engine/core/app_registration.py +22 -41
  35. mdb_engine/core/app_secrets.py +290 -0
  36. mdb_engine/core/connection.py +18 -9
  37. mdb_engine/core/encryption.py +223 -0
  38. mdb_engine/core/engine.py +1057 -93
  39. mdb_engine/core/index_management.py +12 -16
  40. mdb_engine/core/manifest.py +459 -150
  41. mdb_engine/core/ray_integration.py +435 -0
  42. mdb_engine/core/seeding.py +10 -18
  43. mdb_engine/core/service_initialization.py +12 -23
  44. mdb_engine/core/types.py +2 -5
  45. mdb_engine/database/README.md +140 -17
  46. mdb_engine/database/__init__.py +17 -6
  47. mdb_engine/database/abstraction.py +25 -37
  48. mdb_engine/database/connection.py +11 -18
  49. mdb_engine/database/query_validator.py +367 -0
  50. mdb_engine/database/resource_limiter.py +204 -0
  51. mdb_engine/database/scoped_wrapper.py +713 -196
  52. mdb_engine/dependencies.py +426 -0
  53. mdb_engine/di/__init__.py +34 -0
  54. mdb_engine/di/container.py +248 -0
  55. mdb_engine/di/providers.py +205 -0
  56. mdb_engine/di/scopes.py +139 -0
  57. mdb_engine/embeddings/README.md +54 -24
  58. mdb_engine/embeddings/__init__.py +31 -24
  59. mdb_engine/embeddings/dependencies.py +37 -154
  60. mdb_engine/embeddings/service.py +11 -25
  61. mdb_engine/exceptions.py +92 -0
  62. mdb_engine/indexes/README.md +30 -13
  63. mdb_engine/indexes/__init__.py +1 -0
  64. mdb_engine/indexes/helpers.py +1 -1
  65. mdb_engine/indexes/manager.py +50 -114
  66. mdb_engine/memory/README.md +2 -2
  67. mdb_engine/memory/__init__.py +1 -2
  68. mdb_engine/memory/service.py +30 -87
  69. mdb_engine/observability/README.md +4 -2
  70. mdb_engine/observability/__init__.py +26 -9
  71. mdb_engine/observability/health.py +8 -9
  72. mdb_engine/observability/metrics.py +32 -12
  73. mdb_engine/repositories/__init__.py +34 -0
  74. mdb_engine/repositories/base.py +325 -0
  75. mdb_engine/repositories/mongo.py +233 -0
  76. mdb_engine/repositories/unit_of_work.py +166 -0
  77. mdb_engine/routing/README.md +1 -1
  78. mdb_engine/routing/__init__.py +1 -3
  79. mdb_engine/routing/websockets.py +25 -60
  80. mdb_engine-0.2.0.dist-info/METADATA +313 -0
  81. mdb_engine-0.2.0.dist-info/RECORD +96 -0
  82. mdb_engine-0.1.6.dist-info/METADATA +0 -213
  83. mdb_engine-0.1.6.dist-info/RECORD +0 -75
  84. {mdb_engine-0.1.6.dist-info → mdb_engine-0.2.0.dist-info}/WHEEL +0 -0
  85. {mdb_engine-0.1.6.dist-info → mdb_engine-0.2.0.dist-info}/entry_points.txt +0 -0
  86. {mdb_engine-0.1.6.dist-info → mdb_engine-0.2.0.dist-info}/licenses/LICENSE +0 -0
  87. {mdb_engine-0.1.6.dist-info → mdb_engine-0.2.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,313 @@
1
+ Metadata-Version: 2.4
2
+ Name: mdb-engine
3
+ Version: 0.2.0
4
+ Summary: MongoDB Engine
5
+ Home-page: https://github.com/ranfysvalle02/mdb-engine
6
+ Author: Your Name
7
+ Author-email: Your Name <your.email@example.com>
8
+ License: AGPL-3.0
9
+ Project-URL: Homepage, https://github.com/ranfysvalle02/mdb-engine
10
+ Project-URL: Documentation, https://github.com/ranfysvalle02/mdb-engine#readme
11
+ Project-URL: Repository, https://github.com/ranfysvalle02/mdb-engine
12
+ Project-URL: Issues, https://github.com/ranfysvalle02/mdb-engine/issues
13
+ Keywords: mongodb,runtime,engine,database,scoping
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Topic :: Database
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: motor>=3.0.0
28
+ Requires-Dist: pymongo>=4.0.0
29
+ Requires-Dist: fastapi>=0.100.0
30
+ Requires-Dist: pydantic>=2.0.0
31
+ Requires-Dist: pyjwt>=2.8.0
32
+ Requires-Dist: jsonschema>=4.0.0
33
+ Requires-Dist: bcrypt>=4.0.0
34
+ Requires-Dist: cryptography>=41.0.0
35
+ Requires-Dist: mem0ai>=1.0.0
36
+ Requires-Dist: semantic-text-splitter>=0.9.0
37
+ Requires-Dist: numpy<2.0.0,>=1.0.0
38
+ Requires-Dist: openai>=1.0.0
39
+ Requires-Dist: azure-identity>=1.15.0
40
+ Requires-Dist: click>=8.0.0
41
+ Provides-Extra: casbin
42
+ Requires-Dist: casbin>=1.0.0; extra == "casbin"
43
+ Requires-Dist: casbin-motor-adapter>=0.1.0; extra == "casbin"
44
+ Provides-Extra: oso
45
+ Requires-Dist: oso-cloud>=0.1.0; extra == "oso"
46
+ Provides-Extra: llm
47
+ Provides-Extra: test
48
+ Requires-Dist: pytest>=7.4.0; extra == "test"
49
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
50
+ Requires-Dist: pytest-cov>=4.1.0; extra == "test"
51
+ Requires-Dist: pytest-mock>=3.11.0; extra == "test"
52
+ Requires-Dist: pytest-timeout>=2.1.0; extra == "test"
53
+ Requires-Dist: testcontainers>=3.7.0; extra == "test"
54
+ Provides-Extra: dev
55
+ Requires-Dist: ruff>=0.4.0; extra == "dev"
56
+ Requires-Dist: semgrep>=1.50.0; extra == "dev"
57
+ Provides-Extra: all
58
+ Requires-Dist: casbin>=1.0.0; extra == "all"
59
+ Requires-Dist: casbin-motor-adapter>=0.1.0; extra == "all"
60
+ Requires-Dist: oso-cloud>=0.1.0; extra == "all"
61
+ Dynamic: author
62
+ Dynamic: home-page
63
+ Dynamic: license-file
64
+ Dynamic: requires-python
65
+
66
+ # mdb-engine
67
+
68
+ **The MongoDB Engine for Python Apps** — Auto-sandboxing, index management, and auth in one package.
69
+
70
+ [![PyPI](https://img.shields.io/pypi/v/mdb-engine)](https://pypi.org/project/mdb-engine/)
71
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
72
+ [![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](https://opensource.org/licenses/AGPL-3.0)
73
+
74
+ ---
75
+
76
+ ## Installation
77
+
78
+ ```bash
79
+ pip install mdb-engine
80
+ ```
81
+
82
+ ---
83
+
84
+ ## 30-Second Quick Start
85
+
86
+ ```python
87
+ from pathlib import Path
88
+ from fastapi import Depends
89
+ from mdb_engine import MongoDBEngine
90
+ from mdb_engine.dependencies import get_scoped_db
91
+
92
+ # 1. Initialize the engine
93
+ engine = MongoDBEngine(
94
+ mongo_uri="mongodb://localhost:27017",
95
+ db_name="my_database"
96
+ )
97
+
98
+ # 2. Create a FastAPI app with automatic lifecycle management
99
+ app = engine.create_app(slug="my_app", manifest=Path("manifest.json"))
100
+
101
+ # 3. Use request-scoped dependencies - all queries automatically isolated
102
+ @app.post("/tasks")
103
+ async def create_task(task: dict, db=Depends(get_scoped_db)):
104
+ result = await db.tasks.insert_one(task)
105
+ return {"id": str(result.inserted_id)}
106
+ ```
107
+
108
+ That's it. Your data is automatically sandboxed, indexes are created, and cleanup is handled.
109
+
110
+ ---
111
+
112
+ ## Basic Examples
113
+
114
+ ### 1. Index Management
115
+
116
+ Define indexes in your `manifest.json` — they're auto-created on startup:
117
+
118
+ ```json
119
+ {
120
+ "schema_version": "2.0",
121
+ "slug": "my_app",
122
+ "name": "My App",
123
+ "status": "active",
124
+ "managed_indexes": {
125
+ "tasks": [
126
+ {
127
+ "type": "regular",
128
+ "keys": {"status": 1, "created_at": -1},
129
+ "name": "status_sort"
130
+ },
131
+ {
132
+ "type": "regular",
133
+ "keys": {"priority": -1},
134
+ "name": "priority_idx"
135
+ }
136
+ ],
137
+ "users": [
138
+ {
139
+ "type": "regular",
140
+ "keys": {"email": 1},
141
+ "name": "email_unique",
142
+ "unique": true
143
+ }
144
+ ]
145
+ }
146
+ }
147
+ ```
148
+
149
+ Supported index types: `regular`, `text`, `vector`, `ttl`, `compound`.
150
+
151
+ ### 2. CRUD Operations (Auto-Scoped)
152
+
153
+ All database operations are automatically scoped to your app. Use `Depends(get_scoped_db)` in route handlers:
154
+
155
+ ```python
156
+ from mdb_engine.dependencies import get_scoped_db
157
+
158
+ @app.post("/tasks")
159
+ async def create_task(task: dict, db=Depends(get_scoped_db)):
160
+ result = await db.tasks.insert_one(task)
161
+ return {"id": str(result.inserted_id)}
162
+
163
+ @app.get("/tasks")
164
+ async def list_tasks(db=Depends(get_scoped_db)):
165
+ return await db.tasks.find({"status": "pending"}).to_list(length=10)
166
+
167
+ @app.put("/tasks/{task_id}")
168
+ async def update_task(task_id: str, db=Depends(get_scoped_db)):
169
+ await db.tasks.update_one({"_id": task_id}, {"$set": {"status": "done"}})
170
+ return {"updated": True}
171
+
172
+ @app.delete("/tasks/{task_id}")
173
+ async def delete_task(task_id: str, db=Depends(get_scoped_db)):
174
+ await db.tasks.delete_one({"_id": task_id})
175
+ return {"deleted": True}
176
+ ```
177
+
178
+ **What happens under the hood:**
179
+ ```python
180
+ # You write:
181
+ await db.tasks.find({}).to_list(length=10)
182
+
183
+ # Engine executes:
184
+ # Collection: my_app_tasks
185
+ # Query: {"app_id": "my_app"}
186
+ ```
187
+
188
+ ### 3. Health Checks
189
+
190
+ Built-in observability:
191
+
192
+ ```python
193
+ @app.get("/health")
194
+ async def health():
195
+ status = await engine.get_health_status()
196
+ return {"status": status.get("status", "unknown")}
197
+ ```
198
+
199
+ ---
200
+
201
+ ## Why mdb-engine?
202
+
203
+ - **Zero boilerplate** — No more connection setup, index creation scripts, or auth handlers
204
+ - **Data isolation** — Multi-tenant ready with automatic app sandboxing
205
+ - **Manifest-driven** — Define your app's "DNA" in JSON, not scattered code
206
+ - **No lock-in** — Standard Motor/PyMongo underneath; export anytime with `mongodump --query='{"app_id":"my_app"}'`
207
+
208
+ ---
209
+
210
+ ## Advanced Features
211
+
212
+ | Feature | Description | Learn More |
213
+ |---------|-------------|------------|
214
+ | **Authentication** | JWT + Casbin/OSO RBAC | [Auth Guide](https://github.com/ranfysvalle02/mdb-engine/blob/main/docs/AUTHZ.md) |
215
+ | **Vector Search** | Atlas Vector Search + embeddings | [RAG Example](https://github.com/ranfysvalle02/mdb-engine/tree/main/examples/basic/interactive_rag) |
216
+ | **Memory Service** | Persistent AI memory with Mem0 | [Chat Example](https://github.com/ranfysvalle02/mdb-engine/tree/main/examples/basic/chit_chat) |
217
+ | **WebSockets** | Real-time updates from manifest | [Docs](https://github.com/ranfysvalle02/mdb-engine/blob/main/docs/ARCHITECTURE.md) |
218
+ | **Multi-App** | Secure cross-app data access | [Multi-App Example](https://github.com/ranfysvalle02/mdb-engine/tree/main/examples/advanced/multi_app) |
219
+ | **SSO** | Shared auth across apps | [Shared Auth Example](https://github.com/ranfysvalle02/mdb-engine/tree/main/examples/advanced/multi_app_shared) |
220
+
221
+ ### AppContext — All Services in One Place ✨
222
+
223
+ ```python
224
+ from fastapi import Depends
225
+ from mdb_engine.dependencies import AppContext
226
+
227
+ @app.post("/ai-chat")
228
+ async def chat(query: str, ctx: AppContext = Depends()):
229
+ user = ctx.require_user() # 401 if not logged in
230
+ ctx.require_role("user") # 403 if missing role
231
+
232
+ # Everything available: ctx.db, ctx.embedding_service, ctx.memory, ctx.llm
233
+ if ctx.llm:
234
+ response = ctx.llm.chat.completions.create(
235
+ model=ctx.llm_model,
236
+ messages=[{"role": "user", "content": query}]
237
+ )
238
+ return {"response": response.choices[0].message.content}
239
+ ```
240
+
241
+ ---
242
+
243
+ ## Full Examples
244
+
245
+ Clone and run:
246
+
247
+ ```bash
248
+ git clone https://github.com/ranfysvalle02/mdb-engine.git
249
+ cd mdb-engine/examples/basic/chit_chat
250
+ docker-compose up --build
251
+ ```
252
+
253
+ ### Basic Examples
254
+
255
+ | Example | Description |
256
+ |---------|-------------|
257
+ | [chit_chat](https://github.com/ranfysvalle02/mdb-engine/tree/main/examples/basic/chit_chat) | AI chat with persistent memory |
258
+ | [interactive_rag](https://github.com/ranfysvalle02/mdb-engine/tree/main/examples/basic/interactive_rag) | RAG with vector search |
259
+ | [oso_hello_world](https://github.com/ranfysvalle02/mdb-engine/tree/main/examples/basic/oso_hello_world) | OSO Cloud authorization |
260
+ | [parallax](https://github.com/ranfysvalle02/mdb-engine/tree/main/examples/basic/parallax) | Dynamic schema generation |
261
+ | [vector_hacking](https://github.com/ranfysvalle02/mdb-engine/tree/main/examples/basic/vector_hacking) | Vector embeddings & attacks |
262
+
263
+ ### Advanced Examples
264
+
265
+ | Example | Description |
266
+ |---------|-------------|
267
+ | [simple_app](https://github.com/ranfysvalle02/mdb-engine/tree/main/examples/advanced/simple_app) | Task management with `create_app()` pattern |
268
+ | [multi_app](https://github.com/ranfysvalle02/mdb-engine/tree/main/examples/advanced/multi_app) | Multi-tenant with cross-app access |
269
+ | [multi_app_shared](https://github.com/ranfysvalle02/mdb-engine/tree/main/examples/advanced/multi_app_shared) | SSO with shared user pool |
270
+
271
+ ---
272
+
273
+ ## Manual Setup (Alternative)
274
+
275
+ If you need more control over the FastAPI lifecycle:
276
+
277
+ ```python
278
+ from pathlib import Path
279
+ from fastapi import FastAPI
280
+ from mdb_engine import MongoDBEngine
281
+
282
+ app = FastAPI()
283
+ engine = MongoDBEngine(mongo_uri="mongodb://localhost:27017", db_name="my_database")
284
+
285
+ @app.on_event("startup")
286
+ async def startup():
287
+ await engine.initialize()
288
+ manifest = await engine.load_manifest(Path("manifest.json"))
289
+ await engine.register_app(manifest, create_indexes=True)
290
+
291
+ @app.on_event("shutdown")
292
+ async def shutdown():
293
+ await engine.shutdown()
294
+
295
+ @app.get("/items")
296
+ async def get_items():
297
+ db = engine.get_scoped_db("my_app")
298
+ return await db.items.find({}).to_list(length=10)
299
+ ```
300
+
301
+ ---
302
+
303
+ ## Links
304
+
305
+ - [GitHub Repository](https://github.com/ranfysvalle02/mdb-engine)
306
+ - [Documentation](https://github.com/ranfysvalle02/mdb-engine/tree/main/docs)
307
+ - [All Examples](https://github.com/ranfysvalle02/mdb-engine/tree/main/examples)
308
+ - [Quick Start Guide](https://github.com/ranfysvalle02/mdb-engine/blob/main/docs/QUICK_START.md)
309
+ - [Contributing](https://github.com/ranfysvalle02/mdb-engine/blob/main/CONTRIBUTING.md)
310
+
311
+ ---
312
+
313
+ **Stop building scaffolding. Start building features.**
@@ -0,0 +1,96 @@
1
+ mdb_engine/README.md,sha256=T3EFGcPopY9LslYW3lxgG3hohWkAOmBNbYG0FDMUJiY,3502
2
+ mdb_engine/__init__.py,sha256=FILWpL9ZgfAnRj38lGF9QSZNY_OBKz9gZtC8ki2SYvc,3008
3
+ mdb_engine/config.py,sha256=EsB0PHrRCCt24db6Ly88s6PQ3sm1esSLMa2G4AHpt5k,7315
4
+ mdb_engine/constants.py,sha256=eaotvW57TVOg7rRbLziGrVNoP7adgw_G9iVByHezc_A,7837
5
+ mdb_engine/dependencies.py,sha256=bkKwYz6CnucDNDcXdxTvRCqmQpsWbAXQFf5w-AcKMH8,14107
6
+ mdb_engine/exceptions.py,sha256=N8WYOgh1fOH0yJeR9I3FTXqpACIL_EQX3zcfUgrFvPI,8521
7
+ mdb_engine/auth/ARCHITECTURE.md,sha256=JXZsjEIpNz4Szk18KaOiEabhEuz1pmYWXQRN-EJEHDM,4076
8
+ mdb_engine/auth/README.md,sha256=STL4PHyMlYpSNEAqo4RBKTEm4kz1GbWpI9c_lS94nV4,36802
9
+ mdb_engine/auth/__init__.py,sha256=QemWqAVvqlxjF-UbzMTGP5AUOeuaAsUEtK4PMxmozmA,5852
10
+ mdb_engine/auth/audit.py,sha256=LtdG9GdwYTSMI30zMygB0K8w4l179GaGvkNbxWgoQ2I,17461
11
+ mdb_engine/auth/base.py,sha256=tIcC30_ViVuhmR8PCpY-MYBzu6Y9Ak1DZkAQishQyMg,7434
12
+ mdb_engine/auth/casbin_factory.py,sha256=66unyPRqNPydi0Bln8NNpsPt8gMwl7Hwc_nEsqfJj9U,16633
13
+ mdb_engine/auth/casbin_models.py,sha256=7XtFmRBhhjw1nKprnluvjyJoTj5fzdPeQwVvo6fI-r0,955
14
+ mdb_engine/auth/config_defaults.py,sha256=7JYX8CFI7OP7GHFIDHTf3Jns09LJcQ7f0_GL9yBnyuA,2018
15
+ mdb_engine/auth/config_helpers.py,sha256=DpQ8QZAO2FVVKFmhTJIa4FYPS8Iy8O7vcVh_tg0INLg,6309
16
+ mdb_engine/auth/cookie_utils.py,sha256=F88p6_aMG0aSmGXCn0KYjweSMPHqfce1lrKHU4P5yQk,4913
17
+ mdb_engine/auth/csrf.py,sha256=Rx9qYt8owSJJwwj7Z_w4nzkaLbaqWoVpNv13qnqosIA,12458
18
+ mdb_engine/auth/decorators.py,sha256=47uyOK_6WmK18J6ELRKwwgaIkcp6kHOILXuARj82Ijw,12288
19
+ mdb_engine/auth/dependencies.py,sha256=-JooBflCsyndw8oUJ864nX01QOX9Pq09KQhY43oaSJk,27156
20
+ mdb_engine/auth/helpers.py,sha256=BCrid985cYh-3h5ZMUV9TES0q40uJXio4oYKQZta7KA,1970
21
+ mdb_engine/auth/integration.py,sha256=zaTeo4ZXnxnTbw6iZCawZ6dDXDQQCaX6XYc6cbRw6xs,22759
22
+ mdb_engine/auth/jwt.py,sha256=aRXLfgFjsebIARmPqgfcA5zSgSN44HD7BgSyOEFaQCM,7244
23
+ mdb_engine/auth/middleware.py,sha256=uMx1dOO1NaR4K2nDet3k_ASR7rc7ZbKD0HlEkVYGJvU,10869
24
+ mdb_engine/auth/oso_factory.py,sha256=FPDzL5zYrFWd--amBoqKk_1FHET8QzlmiYTLinZeezU,11289
25
+ mdb_engine/auth/provider.py,sha256=m7G1rMgMezalALcV_74Kb0G77exyAIP-eOGyI2XfApc,26595
26
+ mdb_engine/auth/rate_limiter.py,sha256=kYuYIDlgkmYB2jx_UUmM9VrndUq2iTkdP7DZV-Jfu8o,15825
27
+ mdb_engine/auth/restrictions.py,sha256=TXa2lO3lZQeMtokhyVLP19-XbWwq2R8JMTw2KfaiDMg,8852
28
+ mdb_engine/auth/session_manager.py,sha256=XjYeE4i1998tBIefhp8VH3Oe7reyA_CC_qjw6zZ5EVY,15459
29
+ mdb_engine/auth/shared_middleware.py,sha256=nrW-JN3P6SQ-WjJcXU9scX8auuS3-LdKEQX9Iy-IjJw,22343
30
+ mdb_engine/auth/shared_users.py,sha256=7f1Wl0u-egcnaMPj1a2XzclMnulrYXpzOcFQM6Mvvus,26828
31
+ mdb_engine/auth/token_lifecycle.py,sha256=NiYDEUyooZRNAaT79yPHAyAfTK3MGOu8eNJtClR-PL0,6753
32
+ mdb_engine/auth/token_store.py,sha256=Mpvln3sPEE0l5zQmFtWxpVUKYjelWv8FJTLhOOn55MY,9161
33
+ mdb_engine/auth/users.py,sha256=gMEHC936aTkjtnGN5E3YzA1k5IThDcLFhzs0-02ujxI,50037
34
+ mdb_engine/auth/utils.py,sha256=g5ILBsrSxvBbhHKsJc9oVjlnmodrM3QJjQQKbnEy4Mk,26126
35
+ mdb_engine/cli/__init__.py,sha256=PANRi4THmL34d1mawlqxIrnuItXMdqoMTq5Z1zHd7rM,301
36
+ mdb_engine/cli/main.py,sha256=Y5ELFhvsr8zxFWv4WScOGNHiLUTdSXAJeUFLpRXCelg,811
37
+ mdb_engine/cli/utils.py,sha256=0bpxHB5PmHapnCRjlN4T2YRp5kzJsp87Uh_65MsCFJY,2766
38
+ mdb_engine/cli/commands/__init__.py,sha256=ZSzMhKdV9ILD5EbOSxDV9nURHo1e4bQ0c8AWpqsTEqM,115
39
+ mdb_engine/cli/commands/generate.py,sha256=2XDnyROYm5OOcEFczGeS6P0AtFgM74XigQbxbMTPvU4,17329
40
+ mdb_engine/cli/commands/migrate.py,sha256=VqNiobSq-ykUhv7NyHJZ-wZ60a8X0B6OqXz8OACsCr0,2077
41
+ mdb_engine/cli/commands/show.py,sha256=-PmyMfzzG1HP-PsD9n8LECyxwvlXypNS3g_VDwFg4oY,1914
42
+ mdb_engine/cli/commands/validate.py,sha256=tD8GkhuW8LKsRMUXvBs-wvVWQunw1XFlLvbpE_SQ9Zg,1688
43
+ mdb_engine/core/README.md,sha256=cl19Sw4Hj-BPBsh_FIhPpop_6S88V-KaHC6rnUCx8xw,17039
44
+ mdb_engine/core/__init__.py,sha256=xhnXyXWZ0a2Qr49QrYvLE5QuqSalcpo05hHHRVtDz_M,1952
45
+ mdb_engine/core/app_registration.py,sha256=zRK2JTeT0rDW4XdOgFAV-j9Og7xijXdov4u1VVp7p1Y,13386
46
+ mdb_engine/core/app_secrets.py,sha256=ipLsC_QdnIFhrCLNQ3nXvBAfndSor4WNRJyqPc0-J8Q,10555
47
+ mdb_engine/core/connection.py,sha256=9WRccQ2Zz8K6PS6yC2XXxhZkppALvAWZJhfLmsJBnbI,8383
48
+ mdb_engine/core/encryption.py,sha256=jblhUuu_L_lht0qlbn5vqDsdj9rN80uL9DCFDCD-zxw,7540
49
+ mdb_engine/core/engine.py,sha256=YmsoTNqMaLi4kcUFySSpCQZ1O8Fd41YryhwubfMfc0g,69566
50
+ mdb_engine/core/index_management.py,sha256=9-r7MIy3JnjQ35sGqsbj8K_I07vAUWtAVgSWC99lJcE,5555
51
+ mdb_engine/core/manifest.py,sha256=4Dk7iDOoxOrpZ20BA2onaX6cqMhWVSIA0bryeKPsXDQ,133677
52
+ mdb_engine/core/ray_integration.py,sha256=Qe3jAYQhOKeBBlWFAcqzciDWN2zctJh_6uMTIai1tS0,13617
53
+ mdb_engine/core/seeding.py,sha256=I5g43xdoEdC4rNwc_Ih0L6QOZguPcpAWrS6HvJ2a3fE,6433
54
+ mdb_engine/core/service_initialization.py,sha256=gJNIB0As4vg6UXRgt1EDo5p3zzlHfF8NZqjCAlB75mA,12997
55
+ mdb_engine/core/types.py,sha256=v_lSnBTyl2JHX39cPvPsnOxXhu8xaGC92UektvYPOvg,11239
56
+ mdb_engine/database/README.md,sha256=-31mVxBeVQaYsF3AD1-gQbD2NCYVcPjdFoA6sZ6b02Y,19354
57
+ mdb_engine/database/__init__.py,sha256=rrc3eZFli3K2zrvVdDbMBi8YkmoHYzP6JNT0AUBE5VU,981
58
+ mdb_engine/database/abstraction.py,sha256=FLVhFuS4OTZIRQyDkUBZdIlhqRndqNA89EO0cJvNsN0,23462
59
+ mdb_engine/database/connection.py,sha256=PDmwkjb4wYhLTUjlcYHscorces69rIuSxt5wdYixGQw,13777
60
+ mdb_engine/database/query_validator.py,sha256=AIWkQ-c6HAqJ-ixn-hq_0yfC2vdf1-jbEpzYZNmfEqs,13275
61
+ mdb_engine/database/resource_limiter.py,sha256=n54-I6bjEk5jxNGMXyb6_fArDCiyJ69_h9goFW5GzUs,6936
62
+ mdb_engine/database/scoped_wrapper.py,sha256=S_QIqGVyCteKAYlSUHNIqqc0S80jWhzHV-Lfa-ezNG4,94794
63
+ mdb_engine/di/__init__.py,sha256=uy9Q153a0QE678TkJ_AEwLuxPY3OyEum2I42_JsuwrI,912
64
+ mdb_engine/di/container.py,sha256=Wf4-O69Kg_hLC3aHmAf847K7p0sHLh4aYKMGOTmvzok,7441
65
+ mdb_engine/di/providers.py,sha256=jCgez_w1NkfAHCa6O3tsoGHiKcZt-fAbmgvn7KXmTCU,5940
66
+ mdb_engine/di/scopes.py,sha256=0pNzm2I5aRr7H_IBCRhcwd4dW4LzwD4uC2PmWyZI1Ps,4187
67
+ mdb_engine/embeddings/README.md,sha256=XjGWUXSdbSpXCAEEVfYmcJoFKBVmXDoM3eTjenrM5Z0,5926
68
+ mdb_engine/embeddings/__init__.py,sha256=BM8tfcekVZv_iPQj3OuZBQ3hHr0eRQetNLEMysRTZkE,2129
69
+ mdb_engine/embeddings/dependencies.py,sha256=BphKvHYF5iYo6k7v4rYkEOYKZCtlGsPfMdrT6v1J430,2195
70
+ mdb_engine/embeddings/service.py,sha256=v5Ch4VMADDUw-tqNs8XbaG9JJktvO7cqniNJ8Mes56k,25991
71
+ mdb_engine/indexes/README.md,sha256=r7duq-1vtqHhBk1cwoBMYYh_dfTzxiaQaPE3mLB_3JQ,15341
72
+ mdb_engine/indexes/__init__.py,sha256=9QFJ6qo_yD26dZcKyKjj-hhesFpaomBt-mWTtYTQvqc,613
73
+ mdb_engine/indexes/helpers.py,sha256=v5iYqS3yOekqwxdbgnI1ifYH4oESatgXYJiJO1GvhSU,4259
74
+ mdb_engine/indexes/manager.py,sha256=CkA62LofmRLtfcm1cyzyx89p6Nge8yb3MIshmWAWPC8,32472
75
+ mdb_engine/memory/README.md,sha256=vy2FSXADcqG18YrFBfrMph9a1vYKuLijhs8ziNFdvRk,10631
76
+ mdb_engine/memory/__init__.py,sha256=e4kAYgxd_-WAH8GovTwjEBO9hvASu_kXEupMgksAL-U,1008
77
+ mdb_engine/memory/service.py,sha256=evoQhnslLVc3fEUhikdby_mt5iz9_T2LPeCEQX4Psd0,47553
78
+ mdb_engine/observability/README.md,sha256=CMgQaC1H8ESmCitfbhJifz6-XoXH_FPNE4MvuZ-oFas,13085
79
+ mdb_engine/observability/__init__.py,sha256=jjLsrW6Gy2ayrbfLrgHsDB61NxWWkYLHwv0q-N3fxjA,1213
80
+ mdb_engine/observability/health.py,sha256=kZ9LXcJ3_8tKXRWXNNCz3qsj0PkZ0BSTdzisc8ds2vw,9197
81
+ mdb_engine/observability/logging.py,sha256=yo_KnUtqjPx_KvqNrAxW8ud6HQjI7Lk6T7Lj7IMW1uY,4073
82
+ mdb_engine/observability/metrics.py,sha256=EL9-ZFOaxxIdU8PWIqPRyPZHhP3fc4VyUawRSS2GIY4,10726
83
+ mdb_engine/repositories/__init__.py,sha256=048N4QmFLVhJyLdYrWHTTBqujhaF--B8g0z6fUSMuJs,858
84
+ mdb_engine/repositories/base.py,sha256=-Llwhn5NxEh-5S6CJAzZx1nF6J2Sch0WxIpMaaPQhs4,8575
85
+ mdb_engine/repositories/mongo.py,sha256=aR_JFDYtWIZiZA616tDbOPrLN_Gi8diD6Hc9UfeaT-w,7177
86
+ mdb_engine/repositories/unit_of_work.py,sha256=obTsGCcZgsNhQdFOvNGLtvq-guyykmPZzBo-GM_ROAo,5146
87
+ mdb_engine/routing/README.md,sha256=WVvTQXDq0amryrjkCu0wP_piOEwFjLukjmPz2mroWHY,13658
88
+ mdb_engine/routing/__init__.py,sha256=reupjHi_RTc2ZBA4AH5XzobAmqy4EQIsfSUcTkFknUM,2438
89
+ mdb_engine/routing/websockets.py,sha256=X6-MG0mAN8ZEgdmZD8edaiDx8DqMCN-hV3coIOdgZNc,29346
90
+ mdb_engine/utils/__init__.py,sha256=_xjHB5p6WLWBql1DyDqf5zdjj2xpfMlK25Y6BH9-oFk,145
91
+ mdb_engine-0.2.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
92
+ mdb_engine-0.2.0.dist-info/METADATA,sha256=uJJNixiSiX8qERmvxc6hJ4YbDulOg2cn7j3XSm41PxI,10470
93
+ mdb_engine-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
94
+ mdb_engine-0.2.0.dist-info/entry_points.txt,sha256=INCbYdFbBzJalwPwxliEzLmPfR57IvQ7RAXG_pn8cL8,48
95
+ mdb_engine-0.2.0.dist-info/top_level.txt,sha256=PH0UEBwTtgkm2vWvC9He_EOMn7hVn_Wg_Jyc0SmeO8k,11
96
+ mdb_engine-0.2.0.dist-info/RECORD,,
@@ -1,213 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: mdb-engine
3
- Version: 0.1.6
4
- Summary: MongoDB Engine
5
- Home-page: https://github.com/ranfysvalle02/mdb-engine
6
- Author: Your Name
7
- Author-email: Your Name <your.email@example.com>
8
- License: AGPL-3.0
9
- Project-URL: Homepage, https://github.com/ranfysvalle02/mdb-engine
10
- Project-URL: Documentation, https://github.com/ranfysvalle02/mdb-engine#readme
11
- Project-URL: Repository, https://github.com/ranfysvalle02/mdb-engine
12
- Project-URL: Issues, https://github.com/ranfysvalle02/mdb-engine/issues
13
- Keywords: mongodb,runtime,engine,database,scoping
14
- Classifier: Development Status :: 4 - Beta
15
- Classifier: Intended Audience :: Developers
16
- Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
17
- Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3.8
19
- Classifier: Programming Language :: Python :: 3.9
20
- Classifier: Programming Language :: Python :: 3.10
21
- Classifier: Programming Language :: Python :: 3.11
22
- Classifier: Topic :: Database
23
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
- Requires-Python: >=3.8
25
- Description-Content-Type: text/markdown
26
- License-File: LICENSE
27
- Requires-Dist: motor>=3.0.0
28
- Requires-Dist: pymongo>=4.0.0
29
- Requires-Dist: fastapi>=0.100.0
30
- Requires-Dist: pydantic>=2.0.0
31
- Requires-Dist: pyjwt>=2.8.0
32
- Requires-Dist: jsonschema>=4.0.0
33
- Requires-Dist: bcrypt>=4.0.0
34
- Requires-Dist: mem0ai>=1.0.0
35
- Requires-Dist: semantic-text-splitter>=0.9.0
36
- Requires-Dist: numpy<2.0.0,>=1.0.0
37
- Requires-Dist: openai>=1.0.0
38
- Requires-Dist: azure-identity>=1.15.0
39
- Requires-Dist: click>=8.0.0
40
- Provides-Extra: casbin
41
- Requires-Dist: casbin>=1.0.0; extra == "casbin"
42
- Requires-Dist: casbin-motor-adapter>=0.1.0; extra == "casbin"
43
- Provides-Extra: oso
44
- Requires-Dist: oso-cloud>=0.1.0; extra == "oso"
45
- Provides-Extra: llm
46
- Provides-Extra: test
47
- Requires-Dist: pytest>=7.4.0; extra == "test"
48
- Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
49
- Requires-Dist: pytest-cov>=4.1.0; extra == "test"
50
- Requires-Dist: pytest-mock>=3.11.0; extra == "test"
51
- Requires-Dist: pytest-timeout>=2.1.0; extra == "test"
52
- Requires-Dist: testcontainers>=3.7.0; extra == "test"
53
- Provides-Extra: dev
54
- Requires-Dist: black>=24.1.0; extra == "dev"
55
- Requires-Dist: isort>=5.13.0; extra == "dev"
56
- Requires-Dist: flake8>=7.0.0; extra == "dev"
57
- Requires-Dist: flake8-docstrings>=1.7.0; extra == "dev"
58
- Requires-Dist: flake8-bugbear>=24.2.0; extra == "dev"
59
- Requires-Dist: flake8-comprehensions>=3.14.0; extra == "dev"
60
- Requires-Dist: flake8-import-order>=0.18.2; extra == "dev"
61
- Provides-Extra: all
62
- Requires-Dist: casbin>=1.0.0; extra == "all"
63
- Requires-Dist: casbin-motor-adapter>=0.1.0; extra == "all"
64
- Requires-Dist: oso-cloud>=0.1.0; extra == "all"
65
- Dynamic: author
66
- Dynamic: home-page
67
- Dynamic: license-file
68
- Dynamic: requires-python
69
-
70
- # MDB_ENGINE Package Documentation
71
-
72
- MongoDB Engine - Package-level documentation.
73
-
74
- ## Package Overview
75
-
76
- MDB_ENGINE provides a complete MongoDB Engine for building MongoDB applications with automatic data isolation, authentication, and resource management.
77
-
78
- ## Core Modules
79
-
80
- ### `core` - MongoDB Engine
81
-
82
- **MongoDBEngine** (`core/engine.py`)
83
- - Central orchestration for all engine components
84
- - Manages database connections, app registration, and lifecycle
85
- - Provides health checks and metrics
86
-
87
- **Manifest System** (`core/manifest.py`)
88
- - JSON schema validation with versioning (v1.0, v2.0)
89
- - Manifest parsing and migration
90
- - Index definition validation
91
-
92
- ### `database` - Database Layer
93
-
94
- **ScopedMongoWrapper** (`database/scoped_wrapper.py`)
95
- - Automatic app isolation
96
- - Transparent query filtering by `app_id`
97
- - MongoDB-style API with automatic scoping
98
-
99
- **Connection Management** (`database/connection.py`)
100
- - Shared connection pooling for efficient resource usage
101
- - Pool metrics and monitoring
102
-
103
- ### `auth` - Authentication & Authorization
104
-
105
- **AuthorizationProvider** (`auth/provider.py`)
106
- - Pluggable authorization interface
107
- - Casbin and OSO adapters
108
- - Caching for performance
109
-
110
- **JWT & Dependencies** (`auth/jwt.py`, `auth/dependencies.py`)
111
- - JWT token handling
112
- - FastAPI dependencies for auth
113
-
114
- ### `indexes` - Index Management
115
-
116
- **Index Orchestration** (`indexes/manager.py`)
117
- - High-level index creation from manifest definitions
118
- - Support for all index types (regular, vector, search, TTL, etc.)
119
-
120
- **Helper Functions** (`indexes/helpers.py`)
121
- - Common index operations
122
- - Key normalization and validation
123
-
124
- ### `observability` - Monitoring & Metrics
125
-
126
- **Metrics** (`observability/metrics.py`)
127
- - Operation timing and statistics
128
- - Error rate tracking
129
- - Performance metrics
130
-
131
- **Logging** (`observability/logging.py`)
132
- - Structured logging with correlation IDs
133
- - App context tracking
134
- - Contextual logger adapter
135
-
136
- **Health Checks** (`observability/health.py`)
137
- - MongoDB health checks
138
- - Engine health status
139
- - Connection pool monitoring
140
-
141
- ### `utils` - Utilities
142
-
143
- **Validation** (`utils/validation.py`)
144
- - Collection name validation
145
- - App slug validation
146
- - MongoDB URI validation
147
-
148
- **Constants** (`constants.py`)
149
- - All shared constants in one place
150
- - No magic numbers
151
-
152
- ## Usage Examples
153
-
154
- ### Basic Engine Usage
155
-
156
- ```python
157
- from mdb_engine import MongoDBEngine
158
-
159
- engine = MongoDBEngine(
160
- mongo_uri="mongodb://localhost:27017",
161
- db_name="my_database"
162
- )
163
-
164
- await engine.initialize()
165
- db = engine.get_scoped_db("my_app")
166
- ```
167
-
168
- ### Manifest Validation
169
-
170
- ```python
171
- from mdb_engine.core import ManifestValidator
172
-
173
- validator = ManifestValidator()
174
- is_valid, error, paths = validator.validate(manifest)
175
- ```
176
-
177
- ### Database Scoping
178
-
179
- ```python
180
- from mdb_engine.database import ScopedMongoWrapper
181
-
182
- # All queries automatically scoped to app
183
- db = engine.get_scoped_db("my_app")
184
- docs = await db.collection.find({"status": "active"}).to_list(length=10)
185
- ```
186
-
187
- ### Observability
188
-
189
- ```python
190
- from mdb_engine.observability import get_metrics_collector, get_logger
191
-
192
- # Metrics
193
- collector = get_metrics_collector()
194
- summary = collector.get_summary()
195
-
196
- # Structured logging
197
- logger = get_logger(__name__)
198
- logger.info("Operation completed")
199
- ```
200
-
201
- ## API Reference
202
-
203
- See individual module docstrings for detailed API documentation.
204
-
205
- ## Status
206
-
207
- ✅ **Production Ready** - All core features implemented and tested
208
- ✅ **Code Quality** - Comprehensive test suite, type hints, observability
209
- ✅ **Documentation** - Complete API documentation
210
-
211
- ## License
212
-
213
- MIT License