guaro 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 (61) hide show
  1. guaro-0.1.0/LICENSE +21 -0
  2. guaro-0.1.0/PKG-INFO +386 -0
  3. guaro-0.1.0/README.md +333 -0
  4. guaro-0.1.0/guaro/__init__.py +30 -0
  5. guaro-0.1.0/guaro/app.py +146 -0
  6. guaro-0.1.0/guaro/batching/__init__.py +3 -0
  7. guaro-0.1.0/guaro/batching/loader.py +28 -0
  8. guaro-0.1.0/guaro/config/__init__.py +10 -0
  9. guaro-0.1.0/guaro/config/normalizer.py +178 -0
  10. guaro-0.1.0/guaro/config/schema.py +61 -0
  11. guaro-0.1.0/guaro/core/__init__.py +4 -0
  12. guaro-0.1.0/guaro/core/execution_engine.py +135 -0
  13. guaro-0.1.0/guaro/core/query_ir.py +40 -0
  14. guaro-0.1.0/guaro/core/query_planner.py +3 -0
  15. guaro-0.1.0/guaro/core/registry.py +89 -0
  16. guaro-0.1.0/guaro/core/schema.py +67 -0
  17. guaro-0.1.0/guaro/core/serializers.py +3 -0
  18. guaro-0.1.0/guaro/db/adapters/base.py +21 -0
  19. guaro-0.1.0/guaro/db/adapters/memory_adapter.py +132 -0
  20. guaro-0.1.0/guaro/db/adapters/migrations.py +167 -0
  21. guaro-0.1.0/guaro/db/adapters/mongo_adapter.py +92 -0
  22. guaro-0.1.0/guaro/db/adapters/sql_adapter.py +178 -0
  23. guaro-0.1.0/guaro/db/repository.py +25 -0
  24. guaro-0.1.0/guaro/db/router.py +40 -0
  25. guaro-0.1.0/guaro/dependency/__init__.py +3 -0
  26. guaro-0.1.0/guaro/dependency/injector.py +59 -0
  27. guaro-0.1.0/guaro/execution/__init__.py +5 -0
  28. guaro-0.1.0/guaro/execution/context.py +22 -0
  29. guaro-0.1.0/guaro/execution/pipeline.py +45 -0
  30. guaro-0.1.0/guaro/execution/planner.py +40 -0
  31. guaro-0.1.0/guaro/graphql/__init__.py +3 -0
  32. guaro-0.1.0/guaro/graphql/adapter.py +23 -0
  33. guaro-0.1.0/guaro/graphql/dataloaders.py +16 -0
  34. guaro-0.1.0/guaro/graphql/schema_builder.py +166 -0
  35. guaro-0.1.0/guaro/graphql/selection.py +31 -0
  36. guaro-0.1.0/guaro/loaders/__init__.py +3 -0
  37. guaro-0.1.0/guaro/loaders/relation_loader.py +45 -0
  38. guaro-0.1.0/guaro/middleware/auth.py +23 -0
  39. guaro-0.1.0/guaro/middleware/permissions.py +19 -0
  40. guaro-0.1.0/guaro/models/__init__.py +3 -0
  41. guaro-0.1.0/guaro/models/base.py +187 -0
  42. guaro-0.1.0/guaro/openapi/generator.py +122 -0
  43. guaro-0.1.0/guaro/repositories/__init__.py +3 -0
  44. guaro-0.1.0/guaro/repositories/base.py +39 -0
  45. guaro-0.1.0/guaro/rest/__init__.py +3 -0
  46. guaro-0.1.0/guaro/rest/adapter.py +93 -0
  47. guaro-0.1.0/guaro/routing/__init__.py +3 -0
  48. guaro-0.1.0/guaro/routing/route.py +76 -0
  49. guaro-0.1.0/guaro/routing/router.py +47 -0
  50. guaro-0.1.0/guaro/serialization/__init__.py +4 -0
  51. guaro-0.1.0/guaro/serialization/compiler.py +119 -0
  52. guaro-0.1.0/guaro/serialization/runtime.py +33 -0
  53. guaro-0.1.0/guaro/validation/__init__.py +3 -0
  54. guaro-0.1.0/guaro/validation/coerce.py +15 -0
  55. guaro-0.1.0/guaro.egg-info/PKG-INFO +386 -0
  56. guaro-0.1.0/guaro.egg-info/SOURCES.txt +59 -0
  57. guaro-0.1.0/guaro.egg-info/dependency_links.txt +1 -0
  58. guaro-0.1.0/guaro.egg-info/requires.txt +29 -0
  59. guaro-0.1.0/guaro.egg-info/top_level.txt +1 -0
  60. guaro-0.1.0/pyproject.toml +95 -0
  61. guaro-0.1.0/setup.cfg +4 -0
guaro-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mickyas Tesfaye
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.
guaro-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,386 @@
1
+ Metadata-Version: 2.4
2
+ Name: guaro
3
+ Version: 0.1.0
4
+ Summary: Guaro: Unified REST + GraphQL framework with auto-migration and multi-database support
5
+ Author-email: Mickyas Tesfaye <alazar42@github.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Alazar42/Guaro
8
+ Project-URL: Repository, https://github.com/Alazar42/Guaro.git
9
+ Project-URL: Documentation, https://github.com/Alazar42/Guaro/blob/main/docs/README.md
10
+ Project-URL: Changelog, https://github.com/Alazar42/Guaro/blob/main/CHANGELOG.md
11
+ Project-URL: Bug Tracker, https://github.com/Alazar42/Guaro/issues
12
+ Keywords: framework,rest,graphql,api,starlette,strawberry,database,orm
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Web Environment
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Natural Language :: English
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Internet :: WWW/HTTP
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Requires-Python: >=3.11
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: starlette>=0.37
30
+ Requires-Dist: strawberry-graphql>=0.245
31
+ Requires-Dist: sqlalchemy>=2.0
32
+ Requires-Dist: uvicorn>=0.30
33
+ Provides-Extra: sqlite
34
+ Requires-Dist: aiosqlite>=0.17; extra == "sqlite"
35
+ Provides-Extra: postgres
36
+ Requires-Dist: asyncpg>=0.29; extra == "postgres"
37
+ Provides-Extra: mysql
38
+ Requires-Dist: aiomysql>=0.2; extra == "mysql"
39
+ Provides-Extra: mongodb
40
+ Requires-Dist: motor>=3.3; extra == "mongodb"
41
+ Provides-Extra: all-databases
42
+ Requires-Dist: aiosqlite>=0.17; extra == "all-databases"
43
+ Requires-Dist: asyncpg>=0.29; extra == "all-databases"
44
+ Requires-Dist: aiomysql>=0.2; extra == "all-databases"
45
+ Requires-Dist: motor>=3.3; extra == "all-databases"
46
+ Provides-Extra: dev
47
+ Requires-Dist: pytest>=8.0; extra == "dev"
48
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
49
+ Requires-Dist: black>=24.0; extra == "dev"
50
+ Requires-Dist: pylint>=3.0; extra == "dev"
51
+ Requires-Dist: mypy>=1.0; extra == "dev"
52
+ Dynamic: license-file
53
+
54
+ # Guaro - Modern Python Backend Framework
55
+
56
+ ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
57
+ ![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue)
58
+
59
+ A powerful, async-first Python framework for building REST & GraphQL APIs with automatic schema management, dependency injection, and type-safe data validation.
60
+
61
+ ## ✨ Features
62
+
63
+ - **🚀 Async-First**: Built on Starlette for high-performance async request handling
64
+ - **🔄 Multi-Protocol**: REST and GraphQL support out of the box
65
+ - **📊 Database Agnostic**: SQLite, PostgreSQL, MySQL, MongoDB support with intelligent schema management
66
+ - **✅ Auto-Migrate**: Smart schema updates that preserve data (never loses existing data)
67
+ - **🔗 Relations**: Built-in support for complex relationships and nested queries
68
+ - **💉 Dependency Injection**: Clean dependency resolution for handlers and middleware
69
+ - **🛡️ Type Safe**: Full type hints for better IDE support and developer experience
70
+ - **📝 Auto Documentation**: Automatic OpenAPI/Swagger generation
71
+ - **🔐 Middleware & Auth**: Built-in middleware support for authentication & permissions
72
+
73
+ ## 🚀 Quick Start
74
+
75
+ ### Installation
76
+
77
+ Install the latest version from PyPI:
78
+
79
+ ```bash
80
+ # Basic installation with SQLite support
81
+ pip install guaro
82
+
83
+ # With specific database support
84
+ pip install "guaro[postgres]" # PostgreSQL
85
+ pip install "guaro[mysql]" # MySQL
86
+ pip install "guaro[mongodb]" # MongoDB
87
+ pip install "guaro[all-databases]" # All databases
88
+
89
+ # Development version from source
90
+ git clone https://github.com/Alazar42/Guaro.git
91
+ cd Guaro
92
+ pip install -e ".[all-databases,dev]"
93
+ ```
94
+
95
+ **See [Installation & Setup Guide](docs/INSTALLATION.md) for detailed setup instructions and environment configuration.**
96
+
97
+ ### Basic Example
98
+
99
+ ```python
100
+ from guaro import API, Model, Router, DatabaseEngine
101
+
102
+ # Define your models
103
+ class User(Model):
104
+ id: int
105
+ name: str
106
+ email: str
107
+
108
+ class Post(Model):
109
+ id: int
110
+ title: str
111
+ body: str
112
+ author: "User"
113
+
114
+ # Configure API
115
+ api = API(database={
116
+ "engine": DatabaseEngine.POSTGRESQL,
117
+ "url": "postgresql+asyncpg://user:pass@localhost/dbname",
118
+ "auto_migrate": True, # Automatic schema creation
119
+ })
120
+
121
+ # Register models
122
+ api.register_model(User)
123
+ api.register_model(Post)
124
+
125
+ # Create routes
126
+ router = Router(prefix="/users")
127
+
128
+ @router.get("/")
129
+ async def list_users() -> list[User]:
130
+ return await User.all()
131
+
132
+ @router.get("/{id}")
133
+ async def get_user(id: int) -> User | None:
134
+ return await User.find(id)
135
+
136
+ api.register_router(router)
137
+
138
+ # Run
139
+ if __name__ == "__main__":
140
+ api.run(mode="hybrid") # REST + GraphQL
141
+ ```
142
+
143
+ ## 📚 Documentation
144
+
145
+ Full documentation available at [docs/README.md](docs/README.md) with learning paths and guides:
146
+
147
+ ### Getting Started
148
+ - **[Installation & Setup](docs/INSTALLATION.md)** - Installation methods (pip, clone, Poetry)
149
+ - **[Quick Start Tutorial](docs/INSTALLATION.md#quick-setup-walkthrough)** - Build your first API in 5 minutes
150
+
151
+ ### Core Concepts
152
+ - **[Models & Data](docs/MODELS.md)** - Define models with relationships
153
+ - **[REST Routing](docs/ROUTING.md)** - Create REST endpoints
154
+ - **[Database Configuration](docs/DATABASE.md)** - All supported databases
155
+ - **[GraphQL](docs/GRAPHQL.md)** - GraphQL schema and queries
156
+
157
+ ### Advanced Topics
158
+ - **[Middleware & Authentication](docs/MIDDLEWARE.md)** - Security and authorization
159
+ - **[Dependency Injection](docs/DEPENDENCY_INJECTION.md)** - Service management
160
+ - **[Developer Guide](docs/DEVELOPMENT.md)** - Architecture and testing
161
+
162
+ ### Contributing & Deployment
163
+ - **[Contributing Guide](CONTRIBUTING.md)** - How to contribute to Guaro
164
+ - **[Development Setup](DEVELOPMENT_SETUP.md)** - Local development environment
165
+ - **[Publishing Guide](PUBLISH.md)** - Deploying to PyPI
166
+ - **[Changelog](CHANGELOG.md)** - Version history and roadmap
167
+
168
+ ## 🛠️ To Get Started
169
+
170
+ 1. **Users**: Follow the [Installation & Setup](docs/INSTALLATION.md) guide
171
+ 2. **Developers**: See [Development Setup](DEVELOPMENT_SETUP.md) for cloning and local setup
172
+ 3. **Contributors**: Read [Contributing Guide](CONTRIBUTING.md) and [Developer Guide](docs/DEVELOPMENT.md)/
173
+ ├── middleware/
174
+ └── guaro/
175
+ ```
176
+
177
+ ## Quick start
178
+
179
+ ```bash
180
+ python -m pip install -e .
181
+ python app.py
182
+ ```
183
+
184
+ ## Example usage
185
+
186
+ ```python
187
+ from guaro import API, Model, Router, permission, require_auth
188
+
189
+
190
+ class User(Model):
191
+ id: int
192
+ name: str
193
+ email: str
194
+
195
+
196
+ router = Router(prefix="/users")
197
+
198
+
199
+ @router.get("/")
200
+ @require_auth
201
+ def get_users():
202
+ return User.all()
203
+
204
+
205
+ api = API()
206
+ api.register_model(User)
207
+ api.register_router(router)
208
+ api.run(mode="hybrid")
209
+ ```
210
+
211
+ ## Database Configuration
212
+
213
+ Guaro supports fully externalized, environment-driven database configuration. Configuration is decoupled from application code and can be environment-specific (dev/staging/prod).
214
+
215
+ ### Configuration Patterns
216
+
217
+ #### Pattern 1: Default Configuration (Automatic SQLite)
218
+
219
+ Works out of the box with zero configuration:
220
+
221
+ ```python
222
+ from guaro import API
223
+
224
+ api = API() # Automatically uses sqlite+aiosqlite:///guaro.db
225
+ api.run()
226
+ ```
227
+
228
+ #### Pattern 2: Inline Configuration
229
+
230
+ Convenient for quick prototypes and testing:
231
+
232
+ ```python
233
+ from guaro import API, DatabaseEngine
234
+
235
+ api = API(
236
+ database={
237
+ "url": "sqlite+aiosqlite:///local.db",
238
+ "engine": DatabaseEngine.SQLITE,
239
+ "auto_migrate": True,
240
+ "pool_size": 2,
241
+ "echo": True,
242
+ }
243
+ )
244
+ api.run()
245
+ ```
246
+
247
+ #### Pattern 3: External Configuration (Recommended)
248
+
249
+ Production-grade pattern — configuration is isolated from application code:
250
+
251
+ **config.py:**
252
+ ```python
253
+ from guaro import DatabaseEngine
254
+
255
+ # Development
256
+ dev_config = {
257
+ "url": "sqlite+aiosqlite:///guaro_dev.db",
258
+ "engine": DatabaseEngine.SQLITE,
259
+ "auto_migrate": True,
260
+ }
261
+
262
+ # Staging
263
+ staging_config = {
264
+ "url": "postgresql+asyncpg://user:pass@db-staging.internal/guaro_staging",
265
+ "engine": DatabaseEngine.POSTGRESQL,
266
+ "auto_migrate": True,
267
+ "pool_size": 10,
268
+ }
269
+
270
+ # Production
271
+ prod_config = {
272
+ "url": "postgresql+asyncpg://user:pass@db-prod.internal/guaro_prod",
273
+ "engine": DatabaseEngine.POSTGRESQL,
274
+ "auto_migrate": False, # Migrations run separately
275
+ "pool_size": 20,
276
+ }
277
+
278
+ # Load based on environment
279
+ import os
280
+ environment = os.getenv("ENVIRONMENT", "dev")
281
+ database_config = locals()[f"{environment}_config"]
282
+ ```
283
+
284
+ **app.py:**
285
+ ```python
286
+ from guaro import API
287
+ from config import database_config
288
+
289
+ api = API(database=database_config)
290
+ api.run()
291
+ ```
292
+
293
+ ### Configuration Options
294
+
295
+ | Option | Type | Default | Description |
296
+ |--------|------|---------|-------------|
297
+ | `url` | str | `"sqlite+aiosqlite:///guaro.db"` | Database connection URL |
298
+ | `engine` | DatabaseEngine | inferred from URL or SQLITE | Database engine type |
299
+ | `auto_migrate` | bool | `True` | Run migrations automatically on startup |
300
+ | `pool_size` | int | `5` | Connection pool size |
301
+ | `pool_pre_ping` | bool | `True` | Test connections before use |
302
+ | `echo` | bool | `False` | Log all SQL statements |
303
+ | `timeout` | int | `30` | Connection timeout in seconds |
304
+ | `extra` | dict | `{}` | Engine-specific options |
305
+
306
+ ### Supported Engines
307
+
308
+ ```python
309
+ from guaro import DatabaseEngine
310
+
311
+ DatabaseEngine.SQLITE # SQLite (default)
312
+ DatabaseEngine.POSTGRESQL # PostgreSQL
313
+ DatabaseEngine.MYSQL # MySQL
314
+ DatabaseEngine.MONGODB # MongoDB
315
+ DatabaseEngine.MEMORY # In-memory cache
316
+ ```
317
+
318
+ ### URL Format
319
+
320
+ Guaro normalizes URLs into transport strings that are passed to adapters. The engine determines how the URL is interpreted:
321
+
322
+ - **SQLite**: `sqlite+aiosqlite:///path/to/db.db`
323
+ - **PostgreSQL**: `postgresql+asyncpg://user:pass@host:port/dbname`
324
+ - **MySQL**: `mysql+aiomysql://user:pass@host:port/dbname`
325
+ - **MongoDB**: `mongodb://user:pass@host:port/dbname`
326
+ - **Custom**: `https://db.api.company.com/api` (engine must be specified)
327
+
328
+ ### Environment-Based Configuration
329
+
330
+ For multi-environment deployments:
331
+
332
+ ```bash
333
+ # Development (automatic SQLite)
334
+ python app.py
335
+
336
+ # Staging environment
337
+ export ENVIRONMENT=staging
338
+ python app.py
339
+
340
+ # Production environment
341
+ export ENVIRONMENT=prod
342
+ python app.py
343
+ ```
344
+
345
+ In `config.py`:
346
+ ```python
347
+ import os
348
+
349
+ environment = os.getenv("ENVIRONMENT", "dev")
350
+ database_config = locals()[f"{environment}_config"]
351
+ ```
352
+
353
+ ### Advanced Configuration
354
+
355
+ With extra options for engine-specific settings:
356
+
357
+ ```python
358
+ database_config = {
359
+ "url": "postgresql+asyncpg://user@localhost/guaro",
360
+ "engine": DatabaseEngine.POSTGRESQL,
361
+ "pool_size": 15,
362
+ "pool_pre_ping": True,
363
+ "echo": False,
364
+ "timeout": 45,
365
+ "extra": {
366
+ "ssl": "require",
367
+ "application_name": "guaro_api",
368
+ "statement_cache_size": 100,
369
+ },
370
+ }
371
+ ```
372
+
373
+
374
+
375
+ This repository contains a production-oriented MVP architecture, not a finished distributed system. The implementation focuses on:
376
+
377
+ - unified metadata registration
378
+ - shared execution and planning
379
+ - automatic REST and GraphQL generation
380
+ - request-scoped batching and caching hooks
381
+
382
+ ## Startup modes
383
+
384
+ - `rest` serves only REST routes
385
+ - `graphql` serves only GraphQL
386
+ - `hybrid` serves both simultaneously