mitsuki 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.
- mitsuki-0.1.0/LICENSE.md +202 -0
- mitsuki-0.1.0/MANIFEST.in +4 -0
- mitsuki-0.1.0/PKG-INFO +483 -0
- mitsuki-0.1.0/README.md +440 -0
- mitsuki-0.1.0/mitsuki/__init__.py +156 -0
- mitsuki-0.1.0/mitsuki/cli/__init__.py +3 -0
- mitsuki-0.1.0/mitsuki/cli/bootstrap.py +215 -0
- mitsuki-0.1.0/mitsuki/cli/templates/README.md.tpl +28 -0
- mitsuki-0.1.0/mitsuki/cli/templates/__init__.py.tpl +1 -0
- mitsuki-0.1.0/mitsuki/cli/templates/app.py.tpl +26 -0
- mitsuki-0.1.0/mitsuki/cli/templates/application-dev.yml.tpl +12 -0
- mitsuki-0.1.0/mitsuki/cli/templates/application-prod.yml.tpl +16 -0
- mitsuki-0.1.0/mitsuki/cli/templates/application-stg.yml.tpl +16 -0
- mitsuki-0.1.0/mitsuki/cli/templates/application.yml.tpl +35 -0
- mitsuki-0.1.0/mitsuki/cli/templates/controller.py.tpl +55 -0
- mitsuki-0.1.0/mitsuki/cli/templates/entity.py.tpl +16 -0
- mitsuki-0.1.0/mitsuki/cli/templates/gitignore.tpl +22 -0
- mitsuki-0.1.0/mitsuki/cli/templates/repository.py.tpl +46 -0
- mitsuki-0.1.0/mitsuki/cli/templates/service.py.tpl +37 -0
- mitsuki-0.1.0/mitsuki/config/__init__.py +18 -0
- mitsuki-0.1.0/mitsuki/config/decorators.py +157 -0
- mitsuki-0.1.0/mitsuki/config/defaults.yml +61 -0
- mitsuki-0.1.0/mitsuki/config/exceptions.py +16 -0
- mitsuki-0.1.0/mitsuki/config/properties.py +249 -0
- mitsuki-0.1.0/mitsuki/core/__init__.py +18 -0
- mitsuki-0.1.0/mitsuki/core/application.py +286 -0
- mitsuki-0.1.0/mitsuki/core/container.py +271 -0
- mitsuki-0.1.0/mitsuki/core/decorators.py +185 -0
- mitsuki-0.1.0/mitsuki/core/enums.py +137 -0
- mitsuki-0.1.0/mitsuki/core/logging.py +150 -0
- mitsuki-0.1.0/mitsuki/core/metrics.py +33 -0
- mitsuki-0.1.0/mitsuki/core/providers.py +61 -0
- mitsuki-0.1.0/mitsuki/core/scanner.py +116 -0
- mitsuki-0.1.0/mitsuki/core/scheduler.py +399 -0
- mitsuki-0.1.0/mitsuki/core/server.py +252 -0
- mitsuki-0.1.0/mitsuki/core/utils.py +96 -0
- mitsuki-0.1.0/mitsuki/data/__init__.py +115 -0
- mitsuki-0.1.0/mitsuki/data/adapters/__init__.py +0 -0
- mitsuki-0.1.0/mitsuki/data/adapters/base.py +153 -0
- mitsuki-0.1.0/mitsuki/data/adapters/sqlalchemy.py +621 -0
- mitsuki-0.1.0/mitsuki/data/entity.py +216 -0
- mitsuki-0.1.0/mitsuki/data/query.py +109 -0
- mitsuki-0.1.0/mitsuki/data/query_decorators.py +68 -0
- mitsuki-0.1.0/mitsuki/data/query_parser.py +203 -0
- mitsuki-0.1.0/mitsuki/data/repository.py +577 -0
- mitsuki-0.1.0/mitsuki/data/types.py +334 -0
- mitsuki-0.1.0/mitsuki/exceptions.py +116 -0
- mitsuki-0.1.0/mitsuki/openapi/__init__.py +109 -0
- mitsuki-0.1.0/mitsuki/openapi/decorators.py +112 -0
- mitsuki-0.1.0/mitsuki/openapi/generator.py +131 -0
- mitsuki-0.1.0/mitsuki/openapi/introspector.py +310 -0
- mitsuki-0.1.0/mitsuki/openapi/schemas.py +199 -0
- mitsuki-0.1.0/mitsuki/openapi/ui.py +182 -0
- mitsuki-0.1.0/mitsuki/version.py +21 -0
- mitsuki-0.1.0/mitsuki/web/__init__.py +56 -0
- mitsuki-0.1.0/mitsuki/web/controllers.py +81 -0
- mitsuki-0.1.0/mitsuki/web/mappings.py +315 -0
- mitsuki-0.1.0/mitsuki/web/multipart.py +188 -0
- mitsuki-0.1.0/mitsuki/web/parameter_binder.py +280 -0
- mitsuki-0.1.0/mitsuki/web/params.py +259 -0
- mitsuki-0.1.0/mitsuki/web/response.py +125 -0
- mitsuki-0.1.0/mitsuki/web/response_processor.py +104 -0
- mitsuki-0.1.0/mitsuki/web/route_builder.py +218 -0
- mitsuki-0.1.0/mitsuki/web/serialization.py +185 -0
- mitsuki-0.1.0/mitsuki/web/upload.py +96 -0
- mitsuki-0.1.0/mitsuki.egg-info/PKG-INFO +483 -0
- mitsuki-0.1.0/mitsuki.egg-info/SOURCES.txt +71 -0
- mitsuki-0.1.0/mitsuki.egg-info/dependency_links.txt +1 -0
- mitsuki-0.1.0/mitsuki.egg-info/entry_points.txt +2 -0
- mitsuki-0.1.0/mitsuki.egg-info/requires.txt +20 -0
- mitsuki-0.1.0/mitsuki.egg-info/top_level.txt +1 -0
- mitsuki-0.1.0/pyproject.toml +70 -0
- mitsuki-0.1.0/setup.cfg +4 -0
mitsuki-0.1.0/LICENSE.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2025 David Landup
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
mitsuki-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mitsuki
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python web development framework. Mixing Python's productivity and flexibility with battle-hardened enterprise patterns.
|
|
5
|
+
Author: David Landup
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/DavidLandup0/mitsuki
|
|
8
|
+
Project-URL: Documentation, https://github.com/DavidLandup0/mitsuki/blob/main/README.md
|
|
9
|
+
Project-URL: Repository, https://github.com/DavidLandup0/mitsuki
|
|
10
|
+
Project-URL: Issues, https://github.com/DavidLandup0/mitsuki/issues
|
|
11
|
+
Keywords: web,framework,python,asgi,dependency-injection
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE.md
|
|
24
|
+
Requires-Dist: uvicorn>=0.24.0
|
|
25
|
+
Requires-Dist: starlette>=0.32.0
|
|
26
|
+
Requires-Dist: sqlalchemy>=2.0.0
|
|
27
|
+
Requires-Dist: aiosqlite>=0.19.0
|
|
28
|
+
Requires-Dist: pyyaml>=6.0
|
|
29
|
+
Requires-Dist: click>=8.0.0
|
|
30
|
+
Requires-Dist: granian>=1.0.0
|
|
31
|
+
Requires-Dist: socketify>=0.0.27
|
|
32
|
+
Requires-Dist: python-multipart>=0.0.20
|
|
33
|
+
Requires-Dist: colorama>=0.4.6
|
|
34
|
+
Requires-Dist: croniter>=2.0.0
|
|
35
|
+
Requires-Dist: pytz>=2021.1
|
|
36
|
+
Requires-Dist: tomli>=2.0.0
|
|
37
|
+
Provides-Extra: postgresql
|
|
38
|
+
Requires-Dist: asyncpg>=0.29.0; extra == "postgresql"
|
|
39
|
+
Provides-Extra: dev
|
|
40
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
41
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
♡ 。 ₊°༺❤︎༻°₊ 。 ♡
|
|
46
|
+
_ __ __ _
|
|
47
|
+
____ ___ (_) /________ __/ /__(_)
|
|
48
|
+
/ __ `__ \/ / __/ ___/ / / / //_/ /
|
|
49
|
+
/ / / / / / / /_(__ ) /_/ / ,< / /
|
|
50
|
+
/_/ /_/ /_/_/\__/____/\__,_/_/|_/_/
|
|
51
|
+
°❀˖ ° °❀⋆.ೃ࿔*:・ ° ❀˖°
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
<div align="center">
|
|
56
|
+
<p><i>Come with me, take the journey. ❀</i></p>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<hr>
|
|
60
|
+
|
|
61
|
+
<div align="center">
|
|
62
|
+
<p><strong>Enterprise patterns of Spring Boot, development speed and flexibility of Python. </strong></p>
|
|
63
|
+
<p><strong>No compromises.</strong></p>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<div align="center">
|
|
67
|
+
<a href="/docs">Documentation</a> |
|
|
68
|
+
<a href="/benchmarks">Benchmarks</a>
|
|
69
|
+
</div>
|
|
70
|
+
<hr>
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
## Quickstart
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install mitsuki
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Create `app.py`:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from mitsuki import Application, RestController, GetMapping
|
|
83
|
+
|
|
84
|
+
@RestController("/") # Or @Router or @Controller
|
|
85
|
+
class HelloController:
|
|
86
|
+
@Get("/hello/{name}") # Or @GetMapping
|
|
87
|
+
async def hello(self, name: str) -> dict:
|
|
88
|
+
return {"message": f"Hello, {name}!"}
|
|
89
|
+
|
|
90
|
+
@Application
|
|
91
|
+
class App:
|
|
92
|
+
pass
|
|
93
|
+
|
|
94
|
+
if __name__ == "__main__":
|
|
95
|
+
App.run()
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Run it:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
python app.py
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Hit it:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
curl http://localhost:8000/hello/world
|
|
108
|
+
# {"message": "Hello, world!"}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### OpenAPI Generation
|
|
112
|
+
|
|
113
|
+
Mitsuki automatically generates an OpenAPI 3.0 specification for your API, and supports Swagger, Redocly and Scalar UIs.
|
|
114
|
+
|
|
115
|
+
All can run in parallel, and a preferred UI gets exposed at /docs:
|
|
116
|
+
|
|
117
|
+
- **Swagger UI:** `http://localhost:8000/swagger`
|
|
118
|
+
- **ReDoc:** `http://localhost:8000/redoc`
|
|
119
|
+
- **Scalar:** `http://localhost:8000/scalar`
|
|
120
|
+
- **Preferred:** `http://localhost:8000/docs` # Any one of the three above
|
|
121
|
+
- **OpenAPI JSON:** `http://localhost:8000/openapi.json`
|
|
122
|
+
|
|
123
|
+

|
|
124
|
+
|
|
125
|
+
No configuration needed.
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
## Why Mitsuki?
|
|
129
|
+
|
|
130
|
+
Mitsuki brings enterprise strength without enterprise complexity.
|
|
131
|
+
|
|
132
|
+
This is achieved through bringing dependency injection, declarative controllers, and auto-repositories to Python without the ceremony. It's highly inspired by Spring Boot in its early stages.
|
|
133
|
+
|
|
134
|
+
### High-Performance and Lightweight
|
|
135
|
+
|
|
136
|
+
Mitsuki is lightweight, and internally uses Granian for low-level server and Starlette for ASGI. As such - it's as fast as Starlette on Granian. Performance-wise - it ranks in the same category as as Spring Boot (Java) and Express (Node/JavaScript), and higher than FastAPI (Python), Flask (Python) or Django (Python).
|
|
137
|
+
|
|
138
|
+

|
|
139
|
+
|
|
140
|
+
For more, read the README.md in `/benchmarks`.
|
|
141
|
+
|
|
142
|
+
### Productivity
|
|
143
|
+
|
|
144
|
+
Convention over configuration allows you to focus on business code, not glue. Mitsuki provides sensible default conventions, while allowing you to customize any level whenever you'd like.
|
|
145
|
+
|
|
146
|
+
### Enterprise Patterns at Low Cognitive Cost
|
|
147
|
+
|
|
148
|
+
Services tend to evolve into certain time-tested patterns. Mitsuki supports them architecturally. Just write code - and it all fits into place.
|
|
149
|
+
|
|
150
|
+
### Server-Agnostic
|
|
151
|
+
|
|
152
|
+
Mitsuki isn't tied to a single server library. We currently support `uvicorn` and `granian`, with experimental support for `socketify`.
|
|
153
|
+
|
|
154
|
+
In the future - we want to maintain the key components in a plug-and-play fashion, staying up to date with the landscape of tooling.
|
|
155
|
+
|
|
156
|
+
## Core Design Principles
|
|
157
|
+
|
|
158
|
+
- Declarative over imperative. Express intent, not implementation.
|
|
159
|
+
- Enterprise patterns, no ceremony.
|
|
160
|
+
- Type hints are contracts.
|
|
161
|
+
- Fast by design, minimal overhead.
|
|
162
|
+
|
|
163
|
+
## Core Concepts
|
|
164
|
+
|
|
165
|
+
Mituski architecturally encourages a logical separation of code into three main categories:
|
|
166
|
+
|
|
167
|
+
- Controllers (representation layer)
|
|
168
|
+
- Services (business layer)
|
|
169
|
+
- Repositories (data layer)
|
|
170
|
+
|
|
171
|
+
And uses those assumptions to enhance developer experience, reducing boilerplate, and provides reasonable defaults for most implementation.
|
|
172
|
+
|
|
173
|
+
To maximize this - you only need to understand a few core concepts.
|
|
174
|
+
|
|
175
|
+
### Dependency Injection
|
|
176
|
+
|
|
177
|
+
Formally, Mitsuki performs Inversion of Control (IoC), which is achieved through Dependency Injection (DI). It does this automatically, so you don't have to resolve dependencies yourself.
|
|
178
|
+
|
|
179
|
+
In other words - you define dependencies semantically, and Mitsuki handles how they're created, injected, and resolved.
|
|
180
|
+
|
|
181
|
+
In yet other words - you define *a thing*, and a `@Provider` puts it into a global container that enables you to use *the thing* in any part of your application, without having to instantiate it or injecting it manually:
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
@Service()
|
|
185
|
+
class EmailService:
|
|
186
|
+
async def send(self, to: str, message: str):
|
|
187
|
+
print(f"Sending to {to}: {message}")
|
|
188
|
+
|
|
189
|
+
@Service()
|
|
190
|
+
class UserService:
|
|
191
|
+
def __init__(self, email_service: EmailService):
|
|
192
|
+
# Mitsuki sees EmailService in __init__, wires it automatically
|
|
193
|
+
self.email = email_service
|
|
194
|
+
|
|
195
|
+
async def notify_user(self, email: str):
|
|
196
|
+
await self.email.send(email, "You've got mail!")
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Type hints are enough. Mitsuki handles the rest.
|
|
200
|
+
|
|
201
|
+
^ This also makes it super simple to define *configurations* for how you want objects to be built, and simply put them into the mix for them to be used. Want to change Mitsuki's formatter? Inject it into the container and it'll override the formatter in it. Want to change Mitsuki's serializer? Inject it into the container and it'll override the serializer in it.
|
|
202
|
+
|
|
203
|
+
Mitsuki then distributes your objects across the entire codebase.
|
|
204
|
+
|
|
205
|
+
### Auto-Repositories - Write Interfaces, Get Implementations
|
|
206
|
+
|
|
207
|
+
Repositories (data layer) support three levels of methods. CRUD with pagination is auto-supported, just by defining a type:
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
@Entity()
|
|
211
|
+
@dataclass
|
|
212
|
+
class Post:
|
|
213
|
+
id: int = Id()
|
|
214
|
+
title: str = ""
|
|
215
|
+
author: str = ""
|
|
216
|
+
views: int = 0
|
|
217
|
+
|
|
218
|
+
@CrudRepository(entity=Post)
|
|
219
|
+
class PostRepository:
|
|
220
|
+
# Built-in methods (auto-implemented):
|
|
221
|
+
# - find_by_id(id) -> Post | None
|
|
222
|
+
# - find_all(page=0, size=10) -> List[Post]
|
|
223
|
+
# - save(entity: Post) -> Post
|
|
224
|
+
# - delete(entity: Post) -> None
|
|
225
|
+
# - count() -> int
|
|
226
|
+
# - exists_by_id(id) -> bool
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
But it also allows you to simply define method names, and auto-generates SQL for you:
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
@CrudRepository(entity=Post)
|
|
233
|
+
class PostRepository:
|
|
234
|
+
# Mitsuki turns these into SQL queries
|
|
235
|
+
async def find_by_email(self, email: str): ...
|
|
236
|
+
async def find_by_username(self, username: str): ...
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Or write queries yourself:
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
@CrudRepository(entity=Post)
|
|
243
|
+
class PostRepository:
|
|
244
|
+
|
|
245
|
+
@Query("""
|
|
246
|
+
SELECT u FROM User u
|
|
247
|
+
WHERE u.active = :active
|
|
248
|
+
ORDER BY u.created_at DESC
|
|
249
|
+
""")
|
|
250
|
+
async def find_active_users(self, active: bool, limit: int, offset: int): ...
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Or just write your own ORM-backed implementations:
|
|
254
|
+
|
|
255
|
+
```python
|
|
256
|
+
from mitsuki import CrudRepository, Entity, Id, Column
|
|
257
|
+
from dataclasses import dataclass
|
|
258
|
+
|
|
259
|
+
@Entity()
|
|
260
|
+
@dataclass
|
|
261
|
+
class Post:
|
|
262
|
+
id: int = Id()
|
|
263
|
+
title: str = ""
|
|
264
|
+
author: str = ""
|
|
265
|
+
views: int = 0
|
|
266
|
+
|
|
267
|
+
@CrudRepository(entity=Post)
|
|
268
|
+
class PostRepository:
|
|
269
|
+
# Or write custom SQLAlchemy
|
|
270
|
+
async def find_popular_posts(self):
|
|
271
|
+
async with self.get_connection() as conn:
|
|
272
|
+
query = select(Post).where(Post.views > 1000)
|
|
273
|
+
result = await conn.execute(query)
|
|
274
|
+
return [dict(row._mapping) for row in result.fetchall()]
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Query DSL Parsing** - Method names become queries:
|
|
278
|
+
- `find_by_email(email)` → `SELECT * WHERE email = ?`
|
|
279
|
+
- `find_by_age_greater_than(age)` → `SELECT * WHERE age > ?`
|
|
280
|
+
- `count_by_status(status)` → `SELECT COUNT(*) WHERE status = ?`
|
|
281
|
+
|
|
282
|
+
### Scheduled Tasks
|
|
283
|
+
|
|
284
|
+
Run background jobs with the `@Scheduled` decorator.
|
|
285
|
+
|
|
286
|
+
```python
|
|
287
|
+
from mitsuki import Service, Scheduled
|
|
288
|
+
|
|
289
|
+
@Service()
|
|
290
|
+
class ReportService:
|
|
291
|
+
@Scheduled(cron="0 0 * * *") # Every hour
|
|
292
|
+
async def generate_hourly_report(self):
|
|
293
|
+
print("Generating hourly report...")
|
|
294
|
+
|
|
295
|
+
@Scheduled(fixed_rate=60000) # Every minute
|
|
296
|
+
async def check_system_health(self):
|
|
297
|
+
print("Checking system health...")
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Or use syntactic sugar:
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
from mitsuki import Service, Scheduled
|
|
304
|
+
|
|
305
|
+
@Service()
|
|
306
|
+
class ReportService:
|
|
307
|
+
@Scheduled(cron="@daily") # Equivalent to "0 0 0 * * *"
|
|
308
|
+
async def check_system_health(self):
|
|
309
|
+
print("Checking system health...")
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### File Uploads
|
|
313
|
+
|
|
314
|
+
Handle `multipart/form-data` file uploads easily.
|
|
315
|
+
|
|
316
|
+
```python
|
|
317
|
+
from mitsuki import RestController, PostMapping, FormFile, UploadFile
|
|
318
|
+
|
|
319
|
+
@RestController("/api/uploads")
|
|
320
|
+
class UploadController:
|
|
321
|
+
@PostMapping("/")
|
|
322
|
+
async def upload_file(self, file: UploadFile = FormFile()):
|
|
323
|
+
await file.save(f"uploads/{file.filename}")
|
|
324
|
+
return {"filename": file.filename, "size": file.size}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Profiles - One Codebase, All Environments
|
|
328
|
+
|
|
329
|
+
```python
|
|
330
|
+
from mitsuki import Configuration, Profile, Provider
|
|
331
|
+
|
|
332
|
+
@Configuration
|
|
333
|
+
@Profile("development")
|
|
334
|
+
class DevConfig:
|
|
335
|
+
@Provider
|
|
336
|
+
def database_url(self) -> str:
|
|
337
|
+
return "sqlite:///dev.db"
|
|
338
|
+
|
|
339
|
+
@Configuration
|
|
340
|
+
@Profile("production")
|
|
341
|
+
class ProdConfig:
|
|
342
|
+
@Provider
|
|
343
|
+
def database_url(self) -> str:
|
|
344
|
+
return "postgresql://prod-server/db"
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
Run in dev:
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
MITSUKI_PROFILE=development python app.py
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
Run in production:
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
MITSUKI_PROFILE=production python app.py
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
Same code, different environments. Keeps everything across environments explicit and readable.
|
|
360
|
+
|
|
361
|
+
## CLI Tool
|
|
362
|
+
|
|
363
|
+
Bootstrap new projects with the `mitsuki` CLI.
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
mitsuki init
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
This will guide you through creating a new project with a clean structure, including controllers, services, repositories, and configuration for different environments.
|
|
370
|
+
|
|
371
|
+
## Configuration
|
|
372
|
+
|
|
373
|
+
Create `application.yml` (optional):
|
|
374
|
+
|
|
375
|
+
```yaml
|
|
376
|
+
server:
|
|
377
|
+
port: 8000
|
|
378
|
+
host: 0.0.0.0
|
|
379
|
+
|
|
380
|
+
database:
|
|
381
|
+
url: sqlite:///app.db
|
|
382
|
+
|
|
383
|
+
logging:
|
|
384
|
+
level: INFO
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
Inject config into code:
|
|
389
|
+
```python
|
|
390
|
+
from mitsuki import Configuration, Value
|
|
391
|
+
|
|
392
|
+
@Configuration
|
|
393
|
+
class AppConfig:
|
|
394
|
+
port: int = Value("${server.port:8000}")
|
|
395
|
+
db_url: str = Value("${database.url}")
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
Supports `application-profile.yml`, enabling you to centrally define configurations for different environments easily.
|
|
399
|
+
|
|
400
|
+
## Documentation
|
|
401
|
+
|
|
402
|
+
| Guide | What's Inside |
|
|
403
|
+
|-------|---------------|
|
|
404
|
+
| [Overview](docs/01_overview.md) | Architecture, DI, how everything fits together |
|
|
405
|
+
| [Decorators Reference](docs/02_decorators.md) | Complete decorator guide (@Service, @RestController, etc.) |
|
|
406
|
+
| [Repositories & Entities](docs/03_repositories.md) | Data layer, auto-repositories, query DSL |
|
|
407
|
+
| [Controllers](docs/04_controllers.md) | REST endpoints, request mapping, parameters |
|
|
408
|
+
| [Profiles](docs/05_profiles.md) | Environment-specific configuration |
|
|
409
|
+
| [Configuration](docs/06_configuration.md) | application.yml, @Value, environment vars |
|
|
410
|
+
| [CLI](docs/07_cli.md) | Command-line interface for project scaffolding |
|
|
411
|
+
| [Database Queries](docs/08_database_queries.md) | Custom queries, SQLAlchemy integration |
|
|
412
|
+
| [Response Entities](docs/09_response_entity.md) | HTTP responses, status codes, headers |
|
|
413
|
+
| [Validation](docs/10_request_response_validation.md) | Request/response validation |
|
|
414
|
+
| [JSON Serialization](docs/11_json_serialization.md) | Automatic serialization of complex types |
|
|
415
|
+
| [Logging](docs/12_logging.md) | Configuring and using logging |
|
|
416
|
+
| [File Uploads](docs/13_file_uploads.md) | Handling multipart file uploads |
|
|
417
|
+
| [Scheduled Tasks](docs/14_scheduled_tasks.md) | Background jobs with @Scheduled |
|
|
418
|
+
| [Metrics](docs/15_metrics.md) | Application monitoring and metrics |
|
|
419
|
+
| [OpenAPI](docs/16_openapi.md) | Auto-generated API documentation with Swagger/ReDoc/Scalar |
|
|
420
|
+
|
|
421
|
+
## Basic Example
|
|
422
|
+
|
|
423
|
+
A basic example with a domain object, CRUD repository and REST controller/router:
|
|
424
|
+
|
|
425
|
+
```python
|
|
426
|
+
from mitsuki import Application, RestController, Service, CrudRepository, Entity, GetMapping, Id, Column
|
|
427
|
+
from dataclasses import dataclass
|
|
428
|
+
|
|
429
|
+
@Entity()
|
|
430
|
+
@dataclass
|
|
431
|
+
class User:
|
|
432
|
+
id: int = Id()
|
|
433
|
+
name: str = ""
|
|
434
|
+
email: str = Column(unique=True, default="")
|
|
435
|
+
|
|
436
|
+
@CrudRepository(entity=User)
|
|
437
|
+
class UserRepository:
|
|
438
|
+
pass # find_by_id, find_all, save, delete - all auto-implemented
|
|
439
|
+
|
|
440
|
+
@Service()
|
|
441
|
+
class UserService:
|
|
442
|
+
def __init__(self, repo: UserRepository):
|
|
443
|
+
self.repo = repo
|
|
444
|
+
|
|
445
|
+
async def get_user(self, user_id: int) -> User:
|
|
446
|
+
return await self.repo.find_by_id(user_id)
|
|
447
|
+
|
|
448
|
+
@RestController("/api/users")
|
|
449
|
+
class UserController:
|
|
450
|
+
def __init__(self, service: UserService):
|
|
451
|
+
self.service = service
|
|
452
|
+
|
|
453
|
+
@GetMapping("/{id}")
|
|
454
|
+
async def get(self, id: str) -> dict:
|
|
455
|
+
user = await self.service.get_user(int(id))
|
|
456
|
+
return {"id": user.id, "name": user.name, "email": user.email}
|
|
457
|
+
|
|
458
|
+
@Application
|
|
459
|
+
class MyApp:
|
|
460
|
+
pass
|
|
461
|
+
|
|
462
|
+
if __name__ == "__main__":
|
|
463
|
+
MyApp.run()
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
**What just happened?**
|
|
467
|
+
- `UserRepository` got `find_by_id()`, `find_all()`, `save()`, `delete()` for free
|
|
468
|
+
- Dependencies wired automatically (no factories, no setup)
|
|
469
|
+
- Database created on startup (SQLite by default)
|
|
470
|
+
- JSON API running on port 8000
|
|
471
|
+
- Type-safe, async, production-ready
|
|
472
|
+
|
|
473
|
+
## Contributing
|
|
474
|
+
|
|
475
|
+
Found a bug? Have an idea? PRs welcome.
|
|
476
|
+
|
|
477
|
+
1. Fork it
|
|
478
|
+
2. Create your feature branch
|
|
479
|
+
3. Write tests
|
|
480
|
+
4. Submit a PR
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
Built with ❀ for developers who want enterprise patterns without enterprise pain.
|