magnexisdb 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 (38) hide show
  1. magnexisdb-0.1.0/LICENSE +16 -0
  2. magnexisdb-0.1.0/PKG-INFO +253 -0
  3. magnexisdb-0.1.0/README.md +237 -0
  4. magnexisdb-0.1.0/api/__init__.py +1 -0
  5. magnexisdb-0.1.0/api/routes/__init__.py +1 -0
  6. magnexisdb-0.1.0/api/routes/collections.py +52 -0
  7. magnexisdb-0.1.0/api/routes/documents.py +147 -0
  8. magnexisdb-0.1.0/api/routes/observability.py +61 -0
  9. magnexisdb-0.1.0/api/routes/query.py +41 -0
  10. magnexisdb-0.1.0/api/routes/restful.py +52 -0
  11. magnexisdb-0.1.0/api/server.py +123 -0
  12. magnexisdb-0.1.0/backend/__init__.py +1 -0
  13. magnexisdb-0.1.0/backend/config.py +33 -0
  14. magnexisdb-0.1.0/backend/main.py +27 -0
  15. magnexisdb-0.1.0/cli/__init__.py +1 -0
  16. magnexisdb-0.1.0/cli/main.py +722 -0
  17. magnexisdb-0.1.0/core/__init__.py +1 -0
  18. magnexisdb-0.1.0/core/engine.py +1001 -0
  19. magnexisdb-0.1.0/core/indexer.py +72 -0
  20. magnexisdb-0.1.0/core/query_engine.py +479 -0
  21. magnexisdb-0.1.0/core/runtime.py +111 -0
  22. magnexisdb-0.1.0/core/rust_ipc.py +61 -0
  23. magnexisdb-0.1.0/core/storage.py +769 -0
  24. magnexisdb-0.1.0/core/transaction.py +17 -0
  25. magnexisdb-0.1.0/magnexisdb.egg-info/PKG-INFO +253 -0
  26. magnexisdb-0.1.0/magnexisdb.egg-info/SOURCES.txt +36 -0
  27. magnexisdb-0.1.0/magnexisdb.egg-info/dependency_links.txt +1 -0
  28. magnexisdb-0.1.0/magnexisdb.egg-info/entry_points.txt +3 -0
  29. magnexisdb-0.1.0/magnexisdb.egg-info/requires.txt +6 -0
  30. magnexisdb-0.1.0/magnexisdb.egg-info/top_level.txt +7 -0
  31. magnexisdb-0.1.0/models/__init__.py +1 -0
  32. magnexisdb-0.1.0/models/document.py +268 -0
  33. magnexisdb-0.1.0/pyproject.toml +29 -0
  34. magnexisdb-0.1.0/realtime/__init__.py +1 -0
  35. magnexisdb-0.1.0/realtime/websocket.py +41 -0
  36. magnexisdb-0.1.0/setup.cfg +4 -0
  37. magnexisdb-0.1.0/utils/__init__.py +1 -0
  38. magnexisdb-0.1.0/utils/parsing.py +113 -0
@@ -0,0 +1,16 @@
1
+ Copyright (c) Magnexis. All rights reserved.
2
+
3
+ This software, source code, documentation, associated assets, and all related
4
+ materials in this repository are proprietary to Magnexis.
5
+
6
+ No permission is granted to use, copy, modify, merge, publish, distribute,
7
+ sublicense, sell, reverse engineer, create derivative works from, or otherwise
8
+ exploit this repository or any portion of it without prior written permission
9
+ from Magnexis.
10
+
11
+ Access to this repository does not grant any license or other rights, whether
12
+ express, implied, by estoppel, or otherwise, in or to any intellectual
13
+ property rights of Magnexis.
14
+
15
+ For licensing, commercial inquiries, or written permission requests, contact
16
+ Magnexis directly.
@@ -0,0 +1,253 @@
1
+ Metadata-Version: 2.4
2
+ Name: magnexisdb
3
+ Version: 0.1.0
4
+ Summary: MagnexisDB - a developer-first document database with realtime observability.
5
+ License: All rights reserved. Copyright Magnexis.
6
+ Requires-Python: >=3.11
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: fastapi>=0.115.0
10
+ Requires-Dist: httpx>=0.27.0
11
+ Requires-Dist: pydantic>=2.8.0
12
+ Requires-Dist: typer>=0.12.3
13
+ Requires-Dist: uvicorn>=0.30.0
14
+ Requires-Dist: websockets>=13.0
15
+ Dynamic: license-file
16
+
17
+ # MagnexisDB
18
+ <img src="assets/magnexis-logo.svg" alt="Magnexis logo" width="150" />
19
+
20
+ ![License: All Rights Reserved](https://img.shields.io/badge/License-All%20Rights%20Reserved-c62828?style=for-the-badge&logo=bookstack&logoColor=white)
21
+ ![Status: Private](https://img.shields.io/badge/Status-Private-6a1b9a?style=for-the-badge&logo=shield&logoColor=white)
22
+ ![Python](https://img.shields.io/badge/Python-3.11%2B-3776AB?style=for-the-badge&logo=python&logoColor=FFD43B)
23
+ ![FastAPI](https://img.shields.io/badge/FastAPI-Backend-009688?style=for-the-badge&logo=fastapi&logoColor=white)
24
+ ![WebSockets](https://img.shields.io/badge/WebSockets-Live%20Streams-1565C0?style=for-the-badge&logo=socketdotio&logoColor=white)
25
+ ![CLI](https://img.shields.io/badge/CLI-Typer%20Powered-F57C00?style=for-the-badge&logo=gnubash&logoColor=white)
26
+ ![Railway](https://img.shields.io/badge/Deploy-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white)
27
+
28
+
29
+ MagnexisDB is a production-oriented document database built for developer experience, realtime updates, and transparent observability.
30
+
31
+ ## Backend architecture
32
+
33
+ ```text
34
+ [ Rust Core ]
35
+ - storage engine
36
+ - indexing
37
+ - query execution
38
+ - time-travel system
39
+
40
+ ↓ (FFI / IPC)
41
+
42
+ [ Python Layer (FastAPI) ]
43
+ - REST API
44
+ - WebSocket streams
45
+ - auth (later)
46
+ - query parsing
47
+
48
+
49
+
50
+ [ CLI (Typer) ]
51
+ - magnexis query
52
+ - magnexis trace
53
+ - magnexis replay
54
+ ```
55
+
56
+ The Python engine remains the active execution path today, while the Rust core is scaffolded under `rust/` and exposed through a shared runtime boundary so MagnexisDB can move toward Rust-backed execution without changing the API or CLI surfaces.
57
+
58
+ ## Proprietary status
59
+
60
+ This repository is proprietary Magnexis software.
61
+
62
+ - External contributions are not being accepted.
63
+ - This is not an open contribution project.
64
+ - All rights are reserved by Magnexis.
65
+
66
+ See [LICENSE](LICENSE) for the full terms.
67
+
68
+ ## What changed
69
+
70
+ This repo now has a deployable split:
71
+
72
+ - `frontend`: React + Vite admin console, ready for Vercel
73
+ - `backend`: Railway-ready FastAPI service entrypoint
74
+ - `api`, `core`, `models`, `realtime`, `utils`: shared database engine and HTTP surface
75
+ - `cli`: expanded operator CLI with local, remote, and release-oriented commands
76
+ - `rust`: workspace for the emerging Magnexis execution core
77
+
78
+ ## Highlights
79
+
80
+ - JSON document storage with nested fields and dynamic schemas
81
+ - Query engine with equality, comparison, inclusion, sorting, and pagination
82
+ - Field indexes backed by SQLite persistence and WAL durability
83
+ - FastAPI HTTP API plus WebSocket live collection streams
84
+ - React operator console for collections, queries, tracing, and insights
85
+ - Typer CLI for local administration, remote calls, streaming, and release metadata
86
+ - Query Replay and Smart Query Insights built in
87
+ - Snapshot export, snapshot import, operation-log recovery replay, and collection introspection
88
+ - Mongo-like `find`, `findOne`, `insertOne`, `updateOne`, `replaceOne`, `deleteOne`, `countDocuments`
89
+ - Mongo-like `insertMany`, `updateMany`, `deleteMany`, aggregation pipelines, `$lookup`, `$facet`, `$bucket`, and array filters
90
+ - Built-in execution tracing, natural query language, zero-setup sync import/deploy, and REST-style collection endpoints
91
+
92
+ ## Monorepo layout
93
+
94
+ ```text
95
+ MagnexisDB/
96
+ |-- backend/ # Railway entrypoint and env config
97
+ |-- frontend/ # Vercel deployable console
98
+ |-- api/ # FastAPI routes and app factory
99
+ |-- cli/ # Typer CLI
100
+ |-- core/ # storage, query engine, indexes, orchestration
101
+ |-- models/ # request/response models
102
+ |-- realtime/ # subscription hub
103
+ |-- rust/ # Rust core workspace and IPC entrypoint
104
+ |-- assets/ # shared Magnexis branding
105
+ |-- scripts/ # smoke and release helpers
106
+ `-- packaging/ # PyInstaller spec for CLI artifacts
107
+ ```
108
+
109
+ ## Local quick start
110
+
111
+ ```bash
112
+ python -m venv .venv
113
+ .venv\Scripts\activate
114
+ pip install -e .
115
+ magnexisdb serve --host 127.0.0.1 --port 8000
116
+ ```
117
+
118
+ Frontend:
119
+
120
+ ```bash
121
+ cd frontend
122
+ npm install
123
+ npm run dev
124
+ ```
125
+
126
+ Set `VITE_MAGNEXISDB_API_URL` if your backend is not on `http://127.0.0.1:8000`.
127
+
128
+ ## Runtime modes
129
+
130
+ - Default mode is `python`, which uses the current Python storage and query engine.
131
+ - Set `MAGNEXISDB_ENGINE=rust-ipc` to expose Rust-core-oriented runtime metadata as the sidecar execution path matures.
132
+ - In `rust-ipc` mode, read-only `query`, `explain`, and `trace` now execute through the Rust core over stdio JSON IPC, while writes, recovery, and mutation flows remain on the Python engine.
133
+ - Use `magnexisdb architecture` or `magnexisdb doctor` to inspect the active backend layout and Rust workspace status.
134
+
135
+ ## Deploy split
136
+
137
+ ### Backend on Railway
138
+
139
+ Use the repo on Railway and start the backend with:
140
+
141
+ ```bash
142
+ python -m backend.main
143
+ ```
144
+
145
+ Recommended environment:
146
+
147
+ ```env
148
+ MAGNEXISDB_DB_PATH=data/magnexis.db
149
+ MAGNEXISDB_ALLOWED_ORIGINS=https://your-vercel-frontend.vercel.app
150
+ MAGNEXISDB_LOG_LEVEL=info
151
+ MAGNEXISDB_VERSION=0.1.0
152
+ ```
153
+
154
+ Health endpoint:
155
+
156
+ ```text
157
+ GET /health
158
+ ```
159
+
160
+ ### Frontend on Vercel
161
+
162
+ Set the Vercel root directory to:
163
+
164
+ ```text
165
+ frontend
166
+ ```
167
+
168
+ Set:
169
+
170
+ ```env
171
+ VITE_MAGNEXISDB_API_URL=https://your-railway-backend.up.railway.app
172
+ ```
173
+
174
+ ## CLI surface
175
+
176
+ Local commands:
177
+
178
+ - `magnexisdb serve`
179
+ - `magnexisdb health`
180
+ - `magnexisdb doctor`
181
+ - `magnexisdb architecture`
182
+ - `magnexisdb create-collection users`
183
+ - `magnexisdb list-indexes users`
184
+ - `magnexisdb describe users`
185
+ - `magnexisdb insert users "{\"name\":\"John\"}"`
186
+ - `magnexisdb query users --filter "{\"age\":{\"$gt\":18}}"`
187
+ - `magnexisdb explain .\query.json`
188
+ - `magnexisdb trace .\query.json`
189
+ - `magnexisdb profile-query .\query.json`
190
+ - `magnexisdb watch users --filter "{\"status\":\"active\"}"`
191
+ - `magnexisdb shell`
192
+ - `magnexisdb release-manifest`
193
+
194
+ Remote commands:
195
+
196
+ - `magnexisdb remote health --url https://your-backend`
197
+ - `magnexisdb remote collections --url https://your-backend`
198
+ - `magnexisdb remote query .\query.json --url https://your-backend`
199
+ - `magnexisdb remote explain .\query.json --url https://your-backend`
200
+ - `magnexisdb remote trace .\query.json --url https://your-backend`
201
+ - `magnexisdb remote insert users "{\"name\":\"John\"}" --url https://your-backend`
202
+
203
+ ## Release artifacts
204
+
205
+ The repo now includes:
206
+
207
+ - `packaging/magnexisdb-cli.spec` for PyInstaller
208
+ - `scripts/build_release.py` for local wheel + binary builds
209
+ - `.github/workflows/release-cli.yml` for cross-platform CLI release artifacts
210
+
211
+ Local build:
212
+
213
+ ```bash
214
+ python -m pip install build pyinstaller
215
+ python scripts/build_release.py
216
+ ```
217
+
218
+ ## Developer scripts
219
+
220
+ PowerShell helpers are in [scripts/dev.ps1](scripts/dev.ps1):
221
+
222
+ ```powershell
223
+ powershell -ExecutionPolicy Bypass -File .\scripts\dev.ps1 install
224
+ powershell -ExecutionPolicy Bypass -File .\scripts\dev.ps1 start
225
+ powershell -ExecutionPolicy Bypass -File .\scripts\dev.ps1 smoke
226
+ ```
227
+
228
+ ## Validation
229
+
230
+ - `powershell -ExecutionPolicy Bypass -File .\scripts\dev.ps1 smoke`
231
+ - `python -m compileall api backend cli core models realtime utils scripts`
232
+ - `npm run build` from `frontend`
233
+
234
+ ## Mongo-like behavior
235
+
236
+ MagnexisDB supports a familiar subset of MongoDB-style operators:
237
+
238
+ - query: `$and`, `$or`, `$nor`, `$not`, `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`, `$in`, `$nin`, `$exists`, `$regex`, `$elemMatch`
239
+ - update: `$set`, `$unset`, `$inc`, `$push`
240
+ - bulk: `insertMany`, `updateMany`, `deleteMany`
241
+ - single-write parity: `replaceOne`, `deleteOne`, `countDocuments`, `upsert`
242
+ - array-filtered updates: `arrayFilters`
243
+ - aggregation stages: `$match`, `$sort`, `$sortByCount`, `$skip`, `$limit`, `$project`, `$group`, `$unwind`, `$addFields`, `$count`, `$lookup`, `$facet`, `$bucket`
244
+ - group accumulators: `$sum`, `$avg`, `$min`, `$max`, `$first`, `$last`
245
+ - expression helpers: `$concat`, `$add`, `$subtract`, `$setUnion`
246
+
247
+ API docs are available at `/docs`.
248
+
249
+ ## License
250
+
251
+ Copyright Magnexis. All rights reserved.
252
+
253
+ No license is granted for public use, redistribution, modification, or contribution without prior written permission from Magnexis.
@@ -0,0 +1,237 @@
1
+ # MagnexisDB
2
+ <img src="assets/magnexis-logo.svg" alt="Magnexis logo" width="150" />
3
+
4
+ ![License: All Rights Reserved](https://img.shields.io/badge/License-All%20Rights%20Reserved-c62828?style=for-the-badge&logo=bookstack&logoColor=white)
5
+ ![Status: Private](https://img.shields.io/badge/Status-Private-6a1b9a?style=for-the-badge&logo=shield&logoColor=white)
6
+ ![Python](https://img.shields.io/badge/Python-3.11%2B-3776AB?style=for-the-badge&logo=python&logoColor=FFD43B)
7
+ ![FastAPI](https://img.shields.io/badge/FastAPI-Backend-009688?style=for-the-badge&logo=fastapi&logoColor=white)
8
+ ![WebSockets](https://img.shields.io/badge/WebSockets-Live%20Streams-1565C0?style=for-the-badge&logo=socketdotio&logoColor=white)
9
+ ![CLI](https://img.shields.io/badge/CLI-Typer%20Powered-F57C00?style=for-the-badge&logo=gnubash&logoColor=white)
10
+ ![Railway](https://img.shields.io/badge/Deploy-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white)
11
+
12
+
13
+ MagnexisDB is a production-oriented document database built for developer experience, realtime updates, and transparent observability.
14
+
15
+ ## Backend architecture
16
+
17
+ ```text
18
+ [ Rust Core ]
19
+ - storage engine
20
+ - indexing
21
+ - query execution
22
+ - time-travel system
23
+
24
+ ↓ (FFI / IPC)
25
+
26
+ [ Python Layer (FastAPI) ]
27
+ - REST API
28
+ - WebSocket streams
29
+ - auth (later)
30
+ - query parsing
31
+
32
+
33
+
34
+ [ CLI (Typer) ]
35
+ - magnexis query
36
+ - magnexis trace
37
+ - magnexis replay
38
+ ```
39
+
40
+ The Python engine remains the active execution path today, while the Rust core is scaffolded under `rust/` and exposed through a shared runtime boundary so MagnexisDB can move toward Rust-backed execution without changing the API or CLI surfaces.
41
+
42
+ ## Proprietary status
43
+
44
+ This repository is proprietary Magnexis software.
45
+
46
+ - External contributions are not being accepted.
47
+ - This is not an open contribution project.
48
+ - All rights are reserved by Magnexis.
49
+
50
+ See [LICENSE](LICENSE) for the full terms.
51
+
52
+ ## What changed
53
+
54
+ This repo now has a deployable split:
55
+
56
+ - `frontend`: React + Vite admin console, ready for Vercel
57
+ - `backend`: Railway-ready FastAPI service entrypoint
58
+ - `api`, `core`, `models`, `realtime`, `utils`: shared database engine and HTTP surface
59
+ - `cli`: expanded operator CLI with local, remote, and release-oriented commands
60
+ - `rust`: workspace for the emerging Magnexis execution core
61
+
62
+ ## Highlights
63
+
64
+ - JSON document storage with nested fields and dynamic schemas
65
+ - Query engine with equality, comparison, inclusion, sorting, and pagination
66
+ - Field indexes backed by SQLite persistence and WAL durability
67
+ - FastAPI HTTP API plus WebSocket live collection streams
68
+ - React operator console for collections, queries, tracing, and insights
69
+ - Typer CLI for local administration, remote calls, streaming, and release metadata
70
+ - Query Replay and Smart Query Insights built in
71
+ - Snapshot export, snapshot import, operation-log recovery replay, and collection introspection
72
+ - Mongo-like `find`, `findOne`, `insertOne`, `updateOne`, `replaceOne`, `deleteOne`, `countDocuments`
73
+ - Mongo-like `insertMany`, `updateMany`, `deleteMany`, aggregation pipelines, `$lookup`, `$facet`, `$bucket`, and array filters
74
+ - Built-in execution tracing, natural query language, zero-setup sync import/deploy, and REST-style collection endpoints
75
+
76
+ ## Monorepo layout
77
+
78
+ ```text
79
+ MagnexisDB/
80
+ |-- backend/ # Railway entrypoint and env config
81
+ |-- frontend/ # Vercel deployable console
82
+ |-- api/ # FastAPI routes and app factory
83
+ |-- cli/ # Typer CLI
84
+ |-- core/ # storage, query engine, indexes, orchestration
85
+ |-- models/ # request/response models
86
+ |-- realtime/ # subscription hub
87
+ |-- rust/ # Rust core workspace and IPC entrypoint
88
+ |-- assets/ # shared Magnexis branding
89
+ |-- scripts/ # smoke and release helpers
90
+ `-- packaging/ # PyInstaller spec for CLI artifacts
91
+ ```
92
+
93
+ ## Local quick start
94
+
95
+ ```bash
96
+ python -m venv .venv
97
+ .venv\Scripts\activate
98
+ pip install -e .
99
+ magnexisdb serve --host 127.0.0.1 --port 8000
100
+ ```
101
+
102
+ Frontend:
103
+
104
+ ```bash
105
+ cd frontend
106
+ npm install
107
+ npm run dev
108
+ ```
109
+
110
+ Set `VITE_MAGNEXISDB_API_URL` if your backend is not on `http://127.0.0.1:8000`.
111
+
112
+ ## Runtime modes
113
+
114
+ - Default mode is `python`, which uses the current Python storage and query engine.
115
+ - Set `MAGNEXISDB_ENGINE=rust-ipc` to expose Rust-core-oriented runtime metadata as the sidecar execution path matures.
116
+ - In `rust-ipc` mode, read-only `query`, `explain`, and `trace` now execute through the Rust core over stdio JSON IPC, while writes, recovery, and mutation flows remain on the Python engine.
117
+ - Use `magnexisdb architecture` or `magnexisdb doctor` to inspect the active backend layout and Rust workspace status.
118
+
119
+ ## Deploy split
120
+
121
+ ### Backend on Railway
122
+
123
+ Use the repo on Railway and start the backend with:
124
+
125
+ ```bash
126
+ python -m backend.main
127
+ ```
128
+
129
+ Recommended environment:
130
+
131
+ ```env
132
+ MAGNEXISDB_DB_PATH=data/magnexis.db
133
+ MAGNEXISDB_ALLOWED_ORIGINS=https://your-vercel-frontend.vercel.app
134
+ MAGNEXISDB_LOG_LEVEL=info
135
+ MAGNEXISDB_VERSION=0.1.0
136
+ ```
137
+
138
+ Health endpoint:
139
+
140
+ ```text
141
+ GET /health
142
+ ```
143
+
144
+ ### Frontend on Vercel
145
+
146
+ Set the Vercel root directory to:
147
+
148
+ ```text
149
+ frontend
150
+ ```
151
+
152
+ Set:
153
+
154
+ ```env
155
+ VITE_MAGNEXISDB_API_URL=https://your-railway-backend.up.railway.app
156
+ ```
157
+
158
+ ## CLI surface
159
+
160
+ Local commands:
161
+
162
+ - `magnexisdb serve`
163
+ - `magnexisdb health`
164
+ - `magnexisdb doctor`
165
+ - `magnexisdb architecture`
166
+ - `magnexisdb create-collection users`
167
+ - `magnexisdb list-indexes users`
168
+ - `magnexisdb describe users`
169
+ - `magnexisdb insert users "{\"name\":\"John\"}"`
170
+ - `magnexisdb query users --filter "{\"age\":{\"$gt\":18}}"`
171
+ - `magnexisdb explain .\query.json`
172
+ - `magnexisdb trace .\query.json`
173
+ - `magnexisdb profile-query .\query.json`
174
+ - `magnexisdb watch users --filter "{\"status\":\"active\"}"`
175
+ - `magnexisdb shell`
176
+ - `magnexisdb release-manifest`
177
+
178
+ Remote commands:
179
+
180
+ - `magnexisdb remote health --url https://your-backend`
181
+ - `magnexisdb remote collections --url https://your-backend`
182
+ - `magnexisdb remote query .\query.json --url https://your-backend`
183
+ - `magnexisdb remote explain .\query.json --url https://your-backend`
184
+ - `magnexisdb remote trace .\query.json --url https://your-backend`
185
+ - `magnexisdb remote insert users "{\"name\":\"John\"}" --url https://your-backend`
186
+
187
+ ## Release artifacts
188
+
189
+ The repo now includes:
190
+
191
+ - `packaging/magnexisdb-cli.spec` for PyInstaller
192
+ - `scripts/build_release.py` for local wheel + binary builds
193
+ - `.github/workflows/release-cli.yml` for cross-platform CLI release artifacts
194
+
195
+ Local build:
196
+
197
+ ```bash
198
+ python -m pip install build pyinstaller
199
+ python scripts/build_release.py
200
+ ```
201
+
202
+ ## Developer scripts
203
+
204
+ PowerShell helpers are in [scripts/dev.ps1](scripts/dev.ps1):
205
+
206
+ ```powershell
207
+ powershell -ExecutionPolicy Bypass -File .\scripts\dev.ps1 install
208
+ powershell -ExecutionPolicy Bypass -File .\scripts\dev.ps1 start
209
+ powershell -ExecutionPolicy Bypass -File .\scripts\dev.ps1 smoke
210
+ ```
211
+
212
+ ## Validation
213
+
214
+ - `powershell -ExecutionPolicy Bypass -File .\scripts\dev.ps1 smoke`
215
+ - `python -m compileall api backend cli core models realtime utils scripts`
216
+ - `npm run build` from `frontend`
217
+
218
+ ## Mongo-like behavior
219
+
220
+ MagnexisDB supports a familiar subset of MongoDB-style operators:
221
+
222
+ - query: `$and`, `$or`, `$nor`, `$not`, `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`, `$in`, `$nin`, `$exists`, `$regex`, `$elemMatch`
223
+ - update: `$set`, `$unset`, `$inc`, `$push`
224
+ - bulk: `insertMany`, `updateMany`, `deleteMany`
225
+ - single-write parity: `replaceOne`, `deleteOne`, `countDocuments`, `upsert`
226
+ - array-filtered updates: `arrayFilters`
227
+ - aggregation stages: `$match`, `$sort`, `$sortByCount`, `$skip`, `$limit`, `$project`, `$group`, `$unwind`, `$addFields`, `$count`, `$lookup`, `$facet`, `$bucket`
228
+ - group accumulators: `$sum`, `$avg`, `$min`, `$max`, `$first`, `$last`
229
+ - expression helpers: `$concat`, `$add`, `$subtract`, `$setUnion`
230
+
231
+ API docs are available at `/docs`.
232
+
233
+ ## License
234
+
235
+ Copyright Magnexis. All rights reserved.
236
+
237
+ No license is granted for public use, redistribution, modification, or contribution without prior written permission from Magnexis.
@@ -0,0 +1 @@
1
+ """API package."""
@@ -0,0 +1 @@
1
+ """Route modules."""
@@ -0,0 +1,52 @@
1
+ from __future__ import annotations
2
+
3
+ from fastapi import APIRouter, HTTPException, Query
4
+
5
+ from models.document import CollectionRequest, IndexRequest
6
+
7
+
8
+ def get_router(engine) -> APIRouter:
9
+ router = APIRouter(prefix="/collections", tags=["collections"])
10
+
11
+ @router.post("")
12
+ async def create_collection(request: CollectionRequest) -> dict[str, str]:
13
+ try:
14
+ engine.create_collection(request.name)
15
+ except Exception as exc:
16
+ raise HTTPException(status_code=400, detail=str(exc)) from exc
17
+ return {"status": "created", "collection": request.name}
18
+
19
+ @router.get("")
20
+ async def list_collections() -> dict[str, list[str]]:
21
+ return {"collections": engine.list_collections()}
22
+
23
+ @router.delete("/{name}")
24
+ async def delete_collection(name: str) -> dict[str, str]:
25
+ engine.delete_collection(name)
26
+ return {"status": "deleted", "collection": name}
27
+
28
+ @router.post("/{name}/indexes")
29
+ async def create_index(name: str, request: IndexRequest) -> dict[str, str]:
30
+ field = request.field
31
+ engine.create_index(name, field)
32
+ return {"status": "created", "collection": name, "field": field}
33
+
34
+ @router.get("/{name}/indexes")
35
+ async def list_indexes(name: str) -> dict[str, list[str]]:
36
+ return {"collection": name, "indexes": engine.list_indexes(name)}
37
+
38
+ @router.get("/{name}/metrics")
39
+ async def collection_metrics(name: str):
40
+ try:
41
+ return engine.collection_metrics(name)
42
+ except KeyError as exc:
43
+ raise HTTPException(status_code=404, detail=str(exc)) from exc
44
+
45
+ @router.get("/{name}/schema")
46
+ async def schema_introspection(name: str, sample_limit: int = Query(500, ge=1, le=5000)):
47
+ try:
48
+ return engine.schema_introspection(name, sample_limit=sample_limit)
49
+ except KeyError as exc:
50
+ raise HTTPException(status_code=404, detail=str(exc)) from exc
51
+
52
+ return router