{"id":355164,"date":"2024-05-20T23:02:58","date_gmt":"2024-05-20T23:02:58","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=355164"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=355164","title":{"rendered":"<span>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0431\u044d\u043a\u044d\u043d\u0434-\u043f\u0440\u043e\u0435\u043a\u0442\u0430 Python (\u00a0\u043f\u0440\u0438\u043c\u0435\u0440 FastAPI\u00a0)<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>? \u041f\u0440\u0438\u0432\u0435\u0442!\u00a0\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0447\u0442\u043e-\u0442\u043e \u0437\u043d\u0430\u0435\u0442\u0435 \u043e Python, \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0434\u0435\u0441\u044c.\u00a0\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043e \u0432\u0435\u0431-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u0445 Python.\u00a0\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u0432\u0435\u0449\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u0435\u043d\u044f \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u0435\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Django: \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0432\u0435\u0440\u043d\u043e?\u00a0\u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0435 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443 \u0432\u0430\u0441 \u043f\u0440\u043e\u0441\u0442\u043e \u0435\u0441\u0442\u044c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439, \u043a\u0442\u043e \u0447\u0438\u0442\u0430\u0435\u0442 \u044d\u0442\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e.<\/p>\n<p>\u041d\u043e \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b \u043d\u0430\u0447\u043d\u0435\u0442\u0435 \u043f\u0438\u0441\u0430\u0442\u044c\u00a0<em>\u00ab\u043b\u0443\u0447\u0448\u0438\u0435\u00bb<\/em>\u00a0\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432\u044b \u043e\u0441\u0432\u043e\u0438\u0442\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0438\u0440\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a DDD \u0438 \u0435\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430, \u0438 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442\u0435 \u0441\u0432\u043e\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e CQRS.\u00a0\u041b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u0441\u0442\u0430\u043b\u043e \u0442\u0440\u0443\u0434\u043d\u0435\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u043a\u043e\u0434\u0430, \u0441\u043b\u0435\u0434\u0443\u044f \u0432\u0441\u0435\u043c \u044d\u0442\u0438\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043c, \u043a\u043e\u0433\u0434\u0430 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0426\u0415\u041d\u0422\u0420\u0410\u041b\u042c\u041d\u041e\u0419 \u0447\u0430\u0441\u0442\u044c\u044e \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.\u00a0\u0418\u0437 \u043d\u0435\u0433\u043e \u0434\u0430\u0436\u0435 \u0432\u044b\u0439\u0442\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0435\u0441\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0435\u0448\u0438\u0448\u044c \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u2026<\/p>\n<p>\u2705\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441, \u0430 \u0437\u0430\u0442\u0435\u043c \u0440\u0435\u0448\u0438\u0442\u044c \u0435\u0433\u043e.<\/p>\n<p><em>? \u041e\u0442\u043a\u0430\u0437 \u043e\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438: \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0433\u043e API \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0440\u044b\u043d\u043a\u043e\u043c.<\/em><\/p>\n<h2>? \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h2>\n<p><strong>\u0424\u0430\u0439\u043b\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b.<\/strong><\/p>\n<p>\u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 (\u00a0<em>\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 Django<\/em>\u00a0) \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u00ab\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u00bb \u0438\u043b\u0438, \u0441\u043a\u0430\u0436\u0435\u043c, \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u044f\u043c\u043e \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<pre><code>\u2514\u2500 backend\/   \u251c\u2500 .gitignore   \u251c\u2500 .env.default   \u251c\u2500 .env   \u251c\u2500 .alembic.ini   \u251c\u2500 Pipfile   \u251c\u2500 Pipfile.lock   \u251c\u2500 pyproject.toml   \u251c\u2500 README.md   \u251c\u2500 config\/   \u251c\u2500 users\/   \u251c\u2500 authentication\/   \u251c\u2500 products\/   \u251c\u2500 shipping\/   \u251c\u2500 http\/   \u251c\u2500 mock\/   \u251c\u2500 seed\/   \u2514\u2500 static\/<\/code><\/pre>\n<p>\u041d\u0443 \u0438 \u043b\u0430\u0434\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u043d\u0443\u0442\u0440\u0438 backend\/ \u043d\u0435 100 \u043f\u0430\u043f\u043e\u043a, \u043d\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.\u00a0\u041a\u043e\u0434 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0438\u0448\u0435\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u0438\u043c\u0435\u0442\u044c \u0447\u0430\u0441\u0442\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430.\u00a0\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>\u2514\u2500 backend\/   \u251c\u2500 .gitignore   \u251c\u2500 .env.default   \u251c\u2500 .env   \u251c\u2500 .alembic.ini   \u251c\u2500 Pipfile   \u251c\u2500 Pipfile.lock   \u251c\u2500 pyproject.toml   \u251c\u2500 README.md   \u251c\u2500 http\/   \u251c\u2500 mock\/   \u251c\u2500 seed\/   \u251c\u2500 static\/   \u2514\u2500 src\/     \u251c\u2500 config\/     \u251c\u2500 users\/     \u251c\u2500 authentication\/     \u251c\u2500 products\/     \u2514\u2500 shipping\/<\/code><\/pre>\n<p>? \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435!\u00a0\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u00a0<em>src\/<\/em>\u00a0folder.\u00a0\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043b\u0443\u0447\u0448\u0435.<\/p>\n<h4>?\u00a0\u041b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f<\/h4>\n<p>\u0427\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u043f\u043a\u0438 \u0432 \u043f\u0430\u043f\u043a\u0435\u00a0<em>src\/<\/em>\u00a0?\u00a0\u041e\u0431\u044b\u0447\u043d\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0442\u0438\u043f\u0430: \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b\u2026<\/p>\n<p>\u041d\u043e \u0432\u043e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u044d\u0442\u0438\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c.\u00a0\u041f\u0430\u043f\u043a\u0430 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438\u00a0<em>\/<\/em>\u00a0\u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445\u00a0<em>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/em>\u00a0\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442\u00a0<em>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439\/<\/em>\u00a0\u043f\u0430\u043f\u043a\u0438.\u00a0\u041f\u0430\u043f\u043a\u0430 Shipping\u00a0<em>\/<\/em>\u00a0\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435, \u044d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442\u00a0<em>\u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\/<\/em>\u00a0.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043b\u0438, \u043a\u0430\u043a\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043e\u0442 \u0447\u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/553\/b33\/289\/553b3328952d5ae3250081073b84d48c.png\" width=\"661\" height=\"440\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/553\/b33\/289\/553b3328952d5ae3250081073b84d48c.png\"\/><\/figure>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u2014 \u044d\u0442\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u044d\u0442\u043e\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b ?.\u00a0\u041a\u0430\u0436\u0434\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f \u043e\u0431 \u044d\u0442\u043e\u0439 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0435 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0435\u0435 \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u043d\u043e\u0432\u044b\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c.\u00a0\u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0437\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0439.\u00a0\u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u00a0\u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 JWT, \u0438 \u043e\u043d\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442\u00a0<em>\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u00a0\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/em><strong>\u00a0<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>?\u200d\u2642\ufe0f \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u2014 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u00a0<em>\u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438<\/em>\u00a0\u0441\u0430\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u044e \u044d\u0442\u0443 \u043b\u043e\u0433\u0438\u043a\u0443.\u00a0\u042d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0437\u0430\u043a\u0430\u0437\u0435, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435.\u00a0\u0421\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u043c.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443?\u00a0\u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043b\u0438\u0435\u043d\u0442 \u0445\u043e\u0447\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0443\u044e \u0441 2 \u0438 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438.\u00a0\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043c \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0443.\u00a0\u041f\u0435\u0440\u0432\u044b\u0439 \u2014 \u043f\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443 \u0442\u043e\u0432\u0430\u0440\u0430 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u0437\u0430\u043a\u0430\u0437\u043e\u0432, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u00ab\u0432 \u0440\u0430\u0431\u043e\u0442\u0435\u00bb \u043f\u043e\u0441\u0442\u0430\u0432\u043e\u043a.\u00a0\u0413\u0434\u0435 \u043d\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443?\u00a0\u0412 \u0437\u0430\u043a\u0430\u0437\u0430\u0445, \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0435 \u0438\u043b\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u0445?<\/p>\n<p>\u0427\u0442\u043e \u0436, \u0431\u044b\u043b\u043e \u0431\u044b \u043b\u0443\u0447\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043d\u0438\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u0435, \u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u0432\u044b\u0448\u0435.\u00a0\u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0443 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.\u00a0\u041e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<pre><code>\u2514\u2500 backend\/   \u251c\u2500 .gitignore   \u251c\u2500 ...   \u2514\u2500 src\/     \u251c\u2500 config\/     \u251c\u2500 orders\/     \u251c\u2500 products\/     \u251c\u2500 shipping\/     \u2514\u2500 analytics\/  # new component<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2c0\/8c2\/af8\/2c08c2af8dcdc9447ccebb0c41de4818.png\" width=\"520\" height=\"540\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2c0\/8c2\/af8\/2c08c2af8dcdc9447ccebb0c41de4818.png\"\/><\/figure>\n<p><strong>? \u0422\u043e\u0433\u0434\u0430 \u043d\u0430\u0448\u0438\u043c\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438 \u0431\u0443\u0434\u0443\u0442:<\/strong><\/p>\n<p>1. HTTP GET \/analytics\/products\/&lt;id>\/orders<\/p>\n<p>1. HTTP GET \/analytics\/products\/&lt;id>\/shipping?status=inProgress<\/p>\n<p>\u2705\u0418 \u0432\u043e\u043e\u0431\u0449\u0435, \u044d\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442 \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.\u00a0\u0422\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u2014 \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b.\u00a0\u041d\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043d\u0430\u043c \u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445.<\/p>\n<p>?\ufe0f \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u042d\u0440\u0438\u043a\u0430 \u042d\u0432\u0430\u043d\u0441\u0430 (DDD) \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0439 \u0438\u0434\u0435\u0435\u0439.\u00a0\u041e\u043d \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0435\u0432:<\/p>\n<ol>\n<li>\n<p>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u00ab\u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u0438\u00bb, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0448\u043b\u044e\u0437\u0443 API \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u00ab\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\/\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u00bb \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438.\u00a0\u041e\u043d \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043b\u043a\u0438\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u00ab\u0434\u043e\u043c\u0435\u043d\u00bb \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0435\u0434\u0438\u043d\u0438\u0446\u0435 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u00ab\u0418\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u00bb \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.\u00a0(\u00a0<em>\u0432\u0441\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u0443\u0440\u043e\u0432\u043d\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/em>\u00a0)<\/p>\n<\/li>\n<\/ol>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7d0\/d86\/2b4\/7d0d862b4365ad686ed0fd878fef5baf.png\" width=\"280\" height=\"400\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7d0\/d86\/2b4\/7d0d862b4365ad686ed0fd878fef5baf.png\"\/><\/figure>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438, \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u044b \u0438 \u0437\u0430\u043a\u0430\u0437\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.\u00a0\u042d\u0442\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u0432 \u0441\u043b\u043e\u0435 \u00ab\u0434\u043e\u043c\u0435\u043d\u00bb.<\/p>\n<p>?\u200d\u2642\ufe0f \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0437\u0430\u043a\u0430\u0437 \u2014 \u044d\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f (\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f), \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043d\u0430 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u00ab\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u00bb.<\/p>\n<p>?\ufe0f \u0422\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0438 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0437\u0430\u043a\u0430\u0437\u043e\u0432 \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.\u00a0\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b.<\/p>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e:<\/p>\n<pre><code>\u2514\u2500 backend\/   \u251c\u2500 .gitignore   \u251c\u2500 .env.default   \u251c\u2500 .env   \u251c\u2500 .alembic.ini   \u251c\u2500 Pipfile   \u251c\u2500 Pipfile.lock   \u251c\u2500 pyproject.toml   \u251c\u2500 README.md   \u251c\u2500 http\/   \u251c\u2500 mock\/   \u251c\u2500 seed\/   \u251c\u2500 static\/   \u2514\u2500 src\/     \u251c\u2500 main.py   # application entrypoint     \u251c\u2500 config\/   # application configuration     \u251c\u2500 presentation\/       \u251c\u2500 rest\/         \u251c\u2500 orders         \u251c\u2500 shipping\/         \u2514\u2500 analytics\/       \u2514\u2500 graphql\/     \u251c\u2500 application\/       \u251c\u2500 authentication\/       \u251c\u2500 orders\/       \u2514\u2500 analytics\/     \u251c\u2500 domain\/       \u251c\u2500 authentication\/       \u251c\u2500 users\/       \u251c\u2500 orders\/       \u251c\u2500 shipping\/       \u2514\u2500 products\/     \u251c\u2500 infrastructure\/       \u251c\u2500 database\/         \u2514\u2500 migrations\/       \u251c\u2500 errors\/       \u2514\u2500 application\/         \u2514\u2500 factory.py<\/code><\/pre>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438, \u0438\u0434\u0435\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f: \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 API \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f.\u00a0\u0417\u0430\u0442\u0435\u043c \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u043b\u043e\u0436\u043d\u0430, \u0438\u043b\u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442.\u00a0\u0414\u0430\u043b\u0435\u0435 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>? \u042d\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0443 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/p>\n<h4>\u0424\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u0438\u0441\u0430\u0442\u044c ?<\/h4>\n<p>\u0423 \u0432\u0441\u0435\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0435\u0441\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0438\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0438 \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u043d\u0438 \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u044b PoC, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438?\u00a0\u0414\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f: \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u0434\u0435\u0435\u0439 \u043a\u043e\u0434\u0430, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u043c \u043c\u043e\u0437\u0433\u043e\u043c \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f?<\/p>\n<h2>? \u0420\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h2>\n<blockquote>\n<p><em>? \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430\u00a0<\/em><strong><em>? <\/em><\/strong><a href=\"https:\/\/github.com\/Craxti\/fastapi_layered\" rel=\"noopener noreferrer nofollow\">GitHub<\/a><\/p>\n<p><em>\u041e\u0442\u043a\u0430\u0437 \u043e\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438: \u044f \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c MVP, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0441\u043c\u044b\u0441\u043b.\u00a0\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0430, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f.<\/em><\/p>\n<\/blockquote>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f\u043c\u0438:<\/p>\n<p><strong>\u042f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/strong><\/p>\n<ul>\n<li>\n<p>Python<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430:<\/strong><\/p>\n<ul>\n<li>\n<p>Gunicorn: WSGI server<\/p>\n<\/li>\n<li>\n<p>Uvicorn: ASGI server<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>FastAPI: web framework<\/p>\n<\/li>\n<li>\n<p>Pydantic: data models and validation<\/p>\n<\/li>\n<li>\n<p>SQLAlchemy: ORM<\/p>\n<\/li>\n<li>\n<p>Alembic: database migration tools<\/p>\n<\/li>\n<li>\n<p>Loguru: logging engine<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043e\u0434\u0430:<\/strong><\/p>\n<ul>\n<li>\n<p>pytest, hypothesis, coverage<\/p>\n<\/li>\n<li>\n<p>ruff, mypy<\/p>\n<\/li>\n<li>\n<p>black, isort<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.\u00a0\u041e\u0431\u044b\u0447\u043d\u043e \u043c\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b\u00a0<strong>main.py<\/strong>\u00a0\u0438\u043b\u0438\u00a0<strong>run.py<\/strong>\u00a0, \u0442\u043e\u0433\u0434\u0430 \u044f \u0431\u044b\u00a0\u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u043b \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0441\u00a0<strong>main.py.<\/strong><\/p>\n<pre><code>from fastapi import FastAPI from loguru import logger  from src.config import settings from src.infrastructure import application from src.presentation import rest  # Adjust the logging # ------------------------------- logger.add(     \"\".join(         [             str(settings.root_dir),             \"\/logs\/\",             settings.logging.file.lower(),             \".log\",         ]     ),     format=settings.logging.format,     rotation=settings.logging.rotation,     compression=settings.logging.compression,     level=\"INFO\", )   # Adjust the application # ------------------------------- app: FastAPI = application.create(     debug=settings.debug,     rest_routers=(rest.products.router, rest.orders.router),     startup_tasks=[],     shutdown_tasks=[], )<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432 \u0444\u0430\u0439\u043b \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.\u00a0\u042f \u043f\u043e\u043c\u043e\u0433\u0430\u044e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0438.<\/p>\n<p><strong>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0433\u043b\u0443\u0431\u0438\u043c\u0441\u044f \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439:<\/strong><\/p>\n<pre><code>import asyncio from functools import partial from typing import Callable, Coroutine, Iterable  from fastapi import APIRouter, FastAPI from fastapi.exceptions import RequestValidationError from pydantic import ValidationError  from src.infrastructure.errors import (     BaseError,     custom_base_errors_handler,     pydantic_validation_errors_handler,     python_base_error_handler, )  __all__ = (\"create\",)   def create(     *_,     rest_routers: Iterable[APIRouter],     startup_tasks: Iterable[Callable[[], Coroutine]] | None = None,     shutdown_tasks: Iterable[Callable[[], Coroutine]] | None = None,     **kwargs, ) -> FastAPI:     \"\"\"The application factory using FastAPI framework.     ? Only passing routes is mandatory to start.     \"\"\"      # Initialize the base FastAPI application     app = FastAPI(**kwargs)      # Include REST API routers     for router in rest_routers:         app.include_router(router)      # Extend FastAPI default error handlers     app.exception_handler(RequestValidationError)(         pydantic_validation_errors_handler     )     app.exception_handler(BaseError)(custom_base_errors_handler)     app.exception_handler(ValidationError)(pydantic_validation_errors_handler)     app.exception_handler(Exception)(python_base_error_handler)      # Define startup tasks that are running asynchronous using FastAPI hook     if startup_tasks:         for task in startup_tasks:             coro = partial(asyncio.create_task, task())             app.on_event(\"startup\")(coro)      # Define shutdown tasks using FastAPI hook     if shutdown_tasks:         for task in shutdown_tasks:             app.on_event(\"shutdown\")(task)      return app<\/code><\/pre>\n<p><strong>?\ufe0f \u041e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435:<\/strong><\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u043d\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a.\u00a0\u0412\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0438\u0434\u0438\u0442\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c: \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440\u044b, \u0437\u0430\u0434\u0430\u0447\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u0438 \u044d\u0442\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0439 \u0431\u0430\u0437\u044b \u043a\u043e\u0434\u0430.\u00a0\u0412\u044b \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u0435 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0442\u0430\u043a: \u00ab\u00a0<em>\u0425\u043e\u0440\u043e\u0448\u043e, \u044f \u0441\u043e\u0437\u0434\u0430\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0441 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438.\u00a0\u042f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u044f \u0443\u0434\u0430\u043b\u044e \u043e\u0442\u0441\u044e\u0434\u0430 \u043e\u0434\u0438\u043d \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0438\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0443, \u043e\u043d\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f\u2026<\/em>\u00a0&#8216; \u0438 \u0432\u044b \u043f\u0440\u0430\u0432\u044b!\u00a0\u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e\u00a0<strong>\u043a\u043e\u0434 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0447\u0430\u0449\u0435, \u0447\u0435\u043c \u043f\u0438\u0448\u0435\u0442\u0441\u044f<\/strong>\u00a0.<\/p>\n<h4>?\ufe0f \u0428\u0430\u0431\u043b\u043e\u043d \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/h4>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u0448\u0430\u0431\u043b\u043e\u043d \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f ORM, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 (\u00a0<em>\u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f SQLAlchemy<\/em>\u00a0).\u00a0\u041e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043e \u0432\u0441\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 ORM \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0438\u043b\u0438, \u0441\u043a\u0430\u0436\u0435\u043c, \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c ORM \u0441\u0432\u043e\u0438\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0441\u043b\u043e\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043c\u043e\u0447\u044c.\u00a0\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430\u00a0<strong>src\/infrastructure\/database\/repository.py.<\/strong><\/p>\n<pre><code>from typing import Any, AsyncGenerator, Generic, Type  from sqlalchemy import Result, asc, delete, desc, func, select, update  from src.infrastructure.database.session import Session from src.infrastructure.database.tables import ConcreteTable from src.infrastructure.errors import (     DatabaseError,     NotFoundError,     UnprocessableError, )  __all__ = (\"BaseRepository\",)   # Mypy error: https:\/\/github.com\/python\/mypy\/issues\/13755 class BaseRepository(Session, Generic[ConcreteTable]):  # type: ignore     \"\"\"This class implements the base interface for working with database     and makes it easier to work with type annotations.     \"\"\"      schema_class: Type[ConcreteTable]      def __init__(self) -> None:         super().__init__()          if not self.schema_class:             raise UnprocessableError(                 message=(                     \"Can not initiate the class without schema_class attribute\"                 )             )      async def _get(self, key: str, value: Any) -> ConcreteTable:         \"\"\"Return only one result by filters\"\"\"          query = select(self.schema_class).where(             getattr(self.schema_class, key) == value         )         result: Result = await self.execute(query)          if not (_result := result.scalars().one_or_none()):             raise NotFoundError          return _result      async def count(self) -> int:         result: Result = await self.execute(func.count(self.schema_class.id))         value = result.scalar()          if not isinstance(value, int):             raise UnprocessableError(                 message=(                     \"For some reason count function returned not an integer.\"                     f\"Value: {value}\"                 ),             )          return value      async def _save(self, payload: dict[str, Any]) -> ConcreteTable:         try:             schema = self.schema_class(**payload)             self._session.add(schema)             await self._session.flush()             await self._session.refresh(schema)             return schema         except self._ERRORS:             raise DatabaseError      async def _all(self) -> AsyncGenerator[ConcreteTable, None]:         result: Result = await self.execute(select(self.schema_class))         schemas = result.scalars().all()          for schema in schemas:             yield schema<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442\u00a0<strong>src\/infrastructure\/database\/session.py<\/strong> <\/p>\n<pre><code>class Session:     # All sqlalchemy errors that can be raised     _ERRORS = (IntegrityError, PendingRollbackError)      def __init__(self) -> None:         self._session: AsyncSession = CTX_SESSION.get()      async def execute(self, query) -> Result:         try:             result = await self._session.execute(query)             return result         except self._ERRORS:             raise DatabaseError<\/code><\/pre>\n<h4>?\ufe0f \u041e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e,\u00a0<strong>BaseRepository<\/strong>\u00a0\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c\u00a0<strong>BaseCRUD<\/strong>\u00a0(\u00a0<em>\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\/\u0447\u0442\u0435\u043d\u0438\u0435\/\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435<\/em>\u00a0) \u0438\u043b\u0438\u00a0<strong>BaseDAL<\/strong>\u00a0(\u00a0<em>\u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c<\/em>\u00a0).\u00a0\u042d\u0442\u043e \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>1. \u041e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0443\u0440\u043e\u0432\u043d\u044e \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p>2. \u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u00a0<em>\u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438<\/em>\u00a0\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<\/p>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430\u00a0<strong>src\/domain\/products\/repository.py.<\/strong><\/p>\n<pre><code>class ProductRepository(BaseRepository[ProductsTable]):     schema_class = ProductsTable      async def all(self) -> AsyncGenerator[Product, None]:         async for instance in self._all():             yield Product.from_orm(instance)      async def get(self, id_: int) -> Product:         instance = await self._get(key=\"id\", value=id_)         return Product.from_orm(instance)      async def create(self, schema: ProductUncommited) -> Product:         instance: ProductsTable = await self._save(schema.dict())         return Product.from_orm(instance)<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e\u00a0<strong>Schema_class<\/strong>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u0435\u043d\u0435\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435\u00a0<strong>BaseRepository<\/strong>\u00a0, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437\u00a0<strong>GenericType<\/strong>\u00a0.<\/p>\n<p>3. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f async for \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b (\u00a0<em>\u0441\u043f\u0438\u0441\u043a\u0438, \u043a\u043e\u0440\u0442\u0435\u0436\u0438 \u0438 \u0442. \u0434.<\/em>\u00a0), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043c\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432\u044b\u0431\u043e\u0440\u043a\u0438.<\/p>\n<p>4. \u0412\u0441\u0435 \u043e\u0431\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u043c\u0435\u044e\u0442 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438.\u00a0<strong>\u041e\u0431\u0449\u0430\u044f \u0446\u0435\u043b\u044c \u0442\u0430\u043a\u043e\u0432\u0430: ` get()`<\/strong>\u00a0\u0437\u0430\u043a\u0430\u0437\u0430 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 `\u00a0<strong>get()`<\/strong>\u00a0\u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u00a0.\u00a0\u041b\u0443\u0447\u0448\u0435 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.\u00a0\u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043c\u0435\u0442\u043e\u0434 count, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0431\u0449\u0438\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<blockquote>\n<p><em>\u26a0\ufe0f \u0415\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0435\u0433\u043a\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u00a0<\/em><strong><em>Session()<\/em><\/strong><em>\u00a0, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u00a0<\/em><strong><em>\u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439<\/em><\/strong><em>\u00a0\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/em><\/p>\n<\/blockquote>\n<h2>\u2728 \u041f\u043b\u0430\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043f\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u00ab\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u00bb<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u00ab\u00a0<strong><em>\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0437\u0430\u043a\u0430\u0437<\/em><\/strong>\u00a0\u00bb \u0438 \u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/80d\/f68\/d84\/80df68d848c1a49b80eeaf80e60e581c.png\" width=\"720\" height=\"293\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/80d\/f68\/d84\/80df68d848c1a49b80eeaf80e60e581c.png\"\/><\/figure>\n<p>\u0424\u0430\u0439\u043b <strong>presentation\/orders.py<\/strong>\u00a0: <\/p>\n<pre><code>from fastapi import APIRouter, Depends, Request, status  from src.application import orders from src.application.authentication import get_current_user from src.domain.orders import (     Order,     OrderCreateRequestBody,     OrderPublic, ) from src.domain.users import User from src.infrastructure.database.transaction import transaction from src.infrastructure.models import Response  router = APIRouter(prefix=\"\/orders\", tags=[\"Orders\"])  @router.post(\"\", status_code=status.HTTP_201_CREATED) async def order_create(     request: Request,     schema: OrderCreateRequestBody,     user: User = Depends(get_current_user), ) -> Response[OrderPublic]:     \"\"\"Create a new order.\"\"\"      # Save product to the database     order: Order = await orders.create(payload=schema.dict(), user=user)     order_public = OrderPublic.from_orm(order)      return Response[OrderPublic](result=order_public)<\/code><\/pre>\n<p>\u0424\u0430\u0439\u043b <strong>application\/orders.py<\/strong><\/p>\n<pre><code>from src.domain.orders import Order, OrdersRepository, OrderUncommited from src.domain.users import User from src.infrastructure.database.transaction import transaction   @transaction async def create(payload: dict, user: User) -> Order:     payload.update(user_id=user.id)      order = await OrdersRepository().create(OrderUncommited(**payload))      # Do som other stuff...      return order<\/code><\/pre>\n<p>\u0418\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u00a0<strong>@transaction<\/strong><\/p>\n<pre><code>from functools import wraps  from loguru import logger from sqlalchemy.exc import IntegrityError, PendingRollbackError from sqlalchemy.ext.asyncio import AsyncSession  from src.infrastructure.database.session import CTX_SESSION, get_session from src.infrastructure.errors import DatabaseError   def transaction(coro):     \"\"\"This decorator should be used with all coroutines     that want's access the database for saving a new data.     \"\"\"      @wraps(coro)     async def inner(*args, **kwargs):         session: AsyncSession = get_session()         CTX_SESSION.set(session)          try:             result = await coro(*args, **kwargs)             await session.commit()             return result         except DatabaseError as error:             # NOTE: If any sort of issues are occurred in the code             #       they are handled on the BaseCRUD level and raised             #       as a DatabseError.             #       If the DatabseError is handled within domain\/application             #       levels it is possible that `await session.commit()`             #       would raise an error.             logger.error(f\"Rolling back changes.\\n{error}\")             await session.rollback()             raise DatabaseError         except (IntegrityError, PendingRollbackError) as error:             # NOTE: Since there is a session commit on this level it should             #       be handled because it can raise some errors also             logger.error(f\"Rolling back changes.\\n{error}\")             await session.rollback()         finally:             await session.close()      return inner<\/code><\/pre>\n<h4>?\ufe0f \u041e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>1. \u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c ContextVar, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0439 \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442.\u00a0?\u00a0<a href=\"https:\/\/docs.python.org\/3.11\/library\/contextvars.html#contextvars.ContextVar\" rel=\"noopener noreferrer nofollow\"><em><u>\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Python<\/u><\/em><\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/761712\/\"> https:\/\/habr.com\/ru\/articles\/761712\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>? \u041f\u0440\u0438\u0432\u0435\u0442!\u00a0\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0447\u0442\u043e-\u0442\u043e \u0437\u043d\u0430\u0435\u0442\u0435 \u043e Python, \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0434\u0435\u0441\u044c.\u00a0\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043e \u0432\u0435\u0431-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u0445 Python.\u00a0\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u0432\u0435\u0449\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u0435\u043d\u044f \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u0435\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Django: \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0432\u0435\u0440\u043d\u043e?\u00a0\u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0435 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443 \u0432\u0430\u0441 \u043f\u0440\u043e\u0441\u0442\u043e \u0435\u0441\u0442\u044c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439, \u043a\u0442\u043e \u0447\u0438\u0442\u0430\u0435\u0442 \u044d\u0442\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e.<\/p>\n<p>\u041d\u043e \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b \u043d\u0430\u0447\u043d\u0435\u0442\u0435 \u043f\u0438\u0441\u0430\u0442\u044c\u00a0<em>\u00ab\u043b\u0443\u0447\u0448\u0438\u0435\u00bb<\/em>\u00a0\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432\u044b \u043e\u0441\u0432\u043e\u0438\u0442\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0438\u0440\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a DDD \u0438 \u0435\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430, \u0438 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442\u0435 \u0441\u0432\u043e\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e CQRS.\u00a0\u041b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u0441\u0442\u0430\u043b\u043e \u0442\u0440\u0443\u0434\u043d\u0435\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u043a\u043e\u0434\u0430, \u0441\u043b\u0435\u0434\u0443\u044f \u0432\u0441\u0435\u043c \u044d\u0442\u0438\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043c, \u043a\u043e\u0433\u0434\u0430 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0426\u0415\u041d\u0422\u0420\u0410\u041b\u042c\u041d\u041e\u0419 \u0447\u0430\u0441\u0442\u044c\u044e \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.\u00a0\u0418\u0437 \u043d\u0435\u0433\u043e \u0434\u0430\u0436\u0435 \u0432\u044b\u0439\u0442\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0435\u0441\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0435\u0448\u0438\u0448\u044c \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u2026<\/p>\n<p>\u2705\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441, \u0430 \u0437\u0430\u0442\u0435\u043c \u0440\u0435\u0448\u0438\u0442\u044c \u0435\u0433\u043e.<\/p>\n<p><em>? \u041e\u0442\u043a\u0430\u0437 \u043e\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438: \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0433\u043e API \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0440\u044b\u043d\u043a\u043e\u043c.<\/em><\/p>\n<h2>? \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h2>\n<p><strong>\u0424\u0430\u0439\u043b\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b.<\/strong><\/p>\n<p>\u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 (\u00a0<em>\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 Django<\/em>\u00a0) \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u00ab\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u00bb \u0438\u043b\u0438, \u0441\u043a\u0430\u0436\u0435\u043c, \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u044f\u043c\u043e \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<pre><code>\u2514\u2500 backend\/   \u251c\u2500 .gitignore   \u251c\u2500 .env.default   \u251c\u2500 .env   \u251c\u2500 .alembic.ini   \u251c\u2500 Pipfile   \u251c\u2500 Pipfile.lock   \u251c\u2500 pyproject.toml   \u251c\u2500 README.md   \u251c\u2500 config\/   \u251c\u2500 users\/   \u251c\u2500 authentication\/   \u251c\u2500 products\/   \u251c\u2500 shipping\/   \u251c\u2500 http\/   \u251c\u2500 mock\/   \u251c\u2500 seed\/   \u2514\u2500 static\/<\/code><\/pre>\n<p>\u041d\u0443 \u0438 \u043b\u0430\u0434\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u043d\u0443\u0442\u0440\u0438 backend\/ \u043d\u0435 100 \u043f\u0430\u043f\u043e\u043a, \u043d\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.\u00a0\u041a\u043e\u0434 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0438\u0448\u0435\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u0438\u043c\u0435\u0442\u044c \u0447\u0430\u0441\u0442\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430.\u00a0\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>\u2514\u2500 backend\/   \u251c\u2500 .gitignore   \u251c\u2500 .env.default   \u251c\u2500 .env   \u251c\u2500 .alembic.ini   \u251c\u2500 Pipfile   \u251c\u2500 Pipfile.lock   \u251c\u2500 pyproject.toml   \u251c\u2500 README.md   \u251c\u2500 http\/   \u251c\u2500 mock\/   \u251c\u2500 seed\/   \u251c\u2500 static\/   \u2514\u2500 src\/     \u251c\u2500 config\/     \u251c\u2500 users\/     \u251c\u2500 authentication\/     \u251c\u2500 products\/     \u2514\u2500 shipping\/<\/code><\/pre>\n<p>? \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435!\u00a0\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u00a0<em>src\/<\/em>\u00a0folder.\u00a0\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043b\u0443\u0447\u0448\u0435.<\/p>\n<h4>?\u00a0\u041b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f<\/h4>\n<p>\u0427\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u043f\u043a\u0438 \u0432 \u043f\u0430\u043f\u043a\u0435\u00a0<em>src\/<\/em>\u00a0?\u00a0\u041e\u0431\u044b\u0447\u043d\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0442\u0438\u043f\u0430: \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b\u2026<\/p>\n<p>\u041d\u043e \u0432\u043e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u044d\u0442\u0438\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c.\u00a0\u041f\u0430\u043f\u043a\u0430 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438\u00a0<em>\/<\/em>\u00a0\u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445\u00a0<em>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/em>\u00a0\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442\u00a0<em>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439\/<\/em>\u00a0\u043f\u0430\u043f\u043a\u0438.\u00a0\u041f\u0430\u043f\u043a\u0430 Shipping\u00a0<em>\/<\/em>\u00a0\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435, \u044d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442\u00a0<em>\u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\/<\/em>\u00a0.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043b\u0438, \u043a\u0430\u043a\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043e\u0442 \u0447\u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u2014 \u044d\u0442\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u044d\u0442\u043e\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b ?.\u00a0\u041a\u0430\u0436\u0434\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f \u043e\u0431 \u044d\u0442\u043e\u0439 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0435 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0435\u0435 \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u043d\u043e\u0432\u044b\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c.\u00a0\u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0437\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0439.\u00a0\u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u00a0\u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 JWT, \u0438 \u043e\u043d\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442\u00a0<em>\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u00a0\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/em><strong>\u00a0<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>?\u200d\u2642\ufe0f \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u2014 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u00a0<em>\u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438<\/em>\u00a0\u0441\u0430\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u044e \u044d\u0442\u0443 \u043b\u043e\u0433\u0438\u043a\u0443.\u00a0\u042d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0437\u0430\u043a\u0430\u0437\u0435, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435.\u00a0\u0421\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u043c.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443?\u00a0\u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043b\u0438\u0435\u043d\u0442 \u0445\u043e\u0447\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0443\u044e \u0441 2 \u0438 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438.\u00a0\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043c \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0443.\u00a0\u041f\u0435\u0440\u0432\u044b\u0439 \u2014 \u043f\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443 \u0442\u043e\u0432\u0430\u0440\u0430 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u0437\u0430\u043a\u0430\u0437\u043e\u0432, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u00ab\u0432 \u0440\u0430\u0431\u043e\u0442\u0435\u00bb \u043f\u043e\u0441\u0442\u0430\u0432\u043e\u043a.\u00a0\u0413\u0434\u0435 \u043d\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443?\u00a0\u0412 \u0437\u0430\u043a\u0430\u0437\u0430\u0445, \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0435 \u0438\u043b\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u0445?<\/p>\n<p>\u0427\u0442\u043e \u0436, \u0431\u044b\u043b\u043e \u0431\u044b \u043b\u0443\u0447\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043d\u0438\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u0435, \u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0445\u0435\u043c\u0443 \u0432\u044b\u0448\u0435.\u00a0\u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0443 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.\u00a0\u041e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<pre><code>\u2514\u2500 backend\/   \u251c\u2500 .gitignore   \u251c\u2500 ...   \u2514\u2500 src\/     \u251c\u2500 config\/     \u251c\u2500 orders\/     \u251c\u2500 products\/     \u251c\u2500 shipping\/     \u2514\u2500 analytics\/  # new component<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p><strong>? \u0422\u043e\u0433\u0434\u0430 \u043d\u0430\u0448\u0438\u043c\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438 \u0431\u0443\u0434\u0443\u0442:<\/strong><\/p>\n<p>1. HTTP GET \/analytics\/products\/&lt;id>\/orders<\/p>\n<p>1. HTTP GET \/analytics\/products\/&lt;id>\/shipping?status=inProgress<\/p>\n<p>\u2705\u0418 \u0432\u043e\u043e\u0431\u0449\u0435, \u044d\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442 \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.\u00a0\u0422\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u2014 \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b.\u00a0\u041d\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043d\u0430\u043c \u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445.<\/p>\n<p>?\ufe0f \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u042d\u0440\u0438\u043a\u0430 \u042d\u0432\u0430\u043d\u0441\u0430 (DDD) \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0439 \u0438\u0434\u0435\u0435\u0439.\u00a0\u041e\u043d \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0435\u0432:<\/p>\n<ol>\n<li>\n<p>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u00ab\u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u0438\u00bb, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0448\u043b\u044e\u0437\u0443 API \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u00ab\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\/\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u00bb \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438.\u00a0\u041e\u043d \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043b\u043a\u0438\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u00ab\u0434\u043e\u043c\u0435\u043d\u00bb \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0435\u0434\u0438\u043d\u0438\u0446\u0435 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u00ab\u0418\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u00bb \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.\u00a0(\u00a0<em>\u0432\u0441\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u0443\u0440\u043e\u0432\u043d\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/em>\u00a0)<\/p>\n<\/li>\n<\/ol>\n<figure class=\"\"><\/figure>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438, \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u044b \u0438 \u0437\u0430\u043a\u0430\u0437\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.\u00a0\u042d\u0442\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u0432 \u0441\u043b\u043e\u0435 \u00ab\u0434\u043e\u043c\u0435\u043d\u00bb.<\/p>\n<p>?\u200d\u2642\ufe0f \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0437\u0430\u043a\u0430\u0437 \u2014 \u044d\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f (\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f), \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043d\u0430 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u00ab\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u00bb.<\/p>\n<p>?\ufe0f \u0422\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0438 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0437\u0430\u043a\u0430\u0437\u043e\u0432 \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.\u00a0\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b.<\/p>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e:<\/p>\n<pre><code>\u2514\u2500 backend\/   \u251c\u2500 .gitignore   \u251c\u2500 .env.default   \u251c\u2500 .env   \u251c\u2500 .alembic.ini   \u251c\u2500 Pipfile   \u251c\u2500 Pipfile.lock   \u251c\u2500 pyproject.toml   \u251c\u2500 README.md   \u251c\u2500 http\/   \u251c\u2500 mock\/   \u251c\u2500 seed\/   \u251c\u2500 static\/   \u2514\u2500 src\/     \u251c\u2500 main.py   # application entrypoint     \u251c\u2500 config\/   # application configuration     \u251c\u2500 presentation\/       \u251c\u2500 rest\/         \u251c\u2500 orders         \u251c\u2500 shipping\/         \u2514\u2500 analytics\/       \u2514\u2500 graphql\/     \u251c\u2500 application\/       \u251c\u2500 authentication\/       \u251c\u2500 orders\/       \u2514\u2500 analytics\/     \u251c\u2500 domain\/       \u251c\u2500 authentication\/       \u251c\u2500 users\/       \u251c\u2500 orders\/       \u251c\u2500 shipping\/       \u2514\u2500 products\/     \u251c\u2500 infrastructure\/       \u251c\u2500 database\/         \u2514\u2500 migrations\/       \u251c\u2500 errors\/       \u2514\u2500 application\/         \u2514\u2500 factory.py<\/code><\/pre>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438, \u0438\u0434\u0435\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f: \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 API \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f.\u00a0\u0417\u0430\u0442\u0435\u043c \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u043b\u043e\u0436\u043d\u0430, \u0438\u043b\u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442.\u00a0\u0414\u0430\u043b\u0435\u0435 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>? \u042d\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0443 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/p>\n<h4>\u0424\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043f\u0438\u0441\u0430\u0442\u044c ?<\/h4>\n<p>\u0423 \u0432\u0441\u0435\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0435\u0441\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0438\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0438 \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u043d\u0438 \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u044b PoC, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438?\u00a0\u0414\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f: \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u0434\u0435\u0435\u0439 \u043a\u043e\u0434\u0430, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u043c \u043c\u043e\u0437\u0433\u043e\u043c \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f?<\/p>\n<h2>? \u0420\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h2>\n<blockquote>\n<p><em>? \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430\u00a0<\/em><strong><em>? <\/em><\/strong><a href=\"https:\/\/github.com\/Craxti\/fastapi_layered\" rel=\"noopener noreferrer nofollow\">GitHub<\/a><\/p>\n<p><em>\u041e\u0442\u043a\u0430\u0437 \u043e\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438: \u044f \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c MVP, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0441\u043c\u044b\u0441\u043b.\u00a0\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0430, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f.<\/em><\/p>\n<\/blockquote>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f\u043c\u0438:<\/p>\n<p><strong>\u042f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/strong><\/p>\n<ul>\n<li>\n<p>Python<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430:<\/strong><\/p>\n<ul>\n<li>\n<p>Gunicorn: WSGI server<\/p>\n<\/li>\n<li>\n<p>Uvicorn: ASGI server<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>FastAPI: web framework<\/p>\n<\/li>\n<li>\n<p>Pydantic: data models and validation<\/p>\n<\/li>\n<li>\n<p>SQLAlchemy: ORM<\/p>\n<\/li>\n<li>\n<p>Alembic: database migration tools<\/p>\n<\/li>\n<li>\n<p>Loguru: logging engine<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043e\u0434\u0430:<\/strong><\/p>\n<ul>\n<li>\n<p>pytest, hypothesis, coverage<\/p>\n<\/li>\n<li>\n<p>ruff, mypy<\/p>\n<\/li>\n<li>\n<p>black, isort<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.\u00a0\u041e\u0431\u044b\u0447\u043d\u043e \u043c\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b\u00a0<strong>main.py<\/strong>\u00a0\u0438\u043b\u0438\u00a0<strong>run.py<\/strong>\u00a0, \u0442\u043e\u0433\u0434\u0430 \u044f \u0431\u044b\u00a0\u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u043b \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0441\u00a0<strong>main.py.<\/strong><\/p>\n<pre><code>from fastapi import FastAPI from loguru import logger  from src.config import settings from src.infrastructure import application from src.presentation import rest  # Adjust the logging # ------------------------------- logger.add(     \"\".join(         [             str(settings.root_dir),             \"\/logs\/\",             settings.logging.file.lower(),             \".log\",         ]     ),     format=settings.logging.format,     rotation=settings.logging.rotation,     compression=settings.logging.compression,     level=\"INFO\", )   # Adjust the application # ------------------------------- app: FastAPI = application.create(     debug=settings.debug,     rest_routers=(rest.products.router, rest.orders.router),     startup_tasks=[],     shutdown_tasks=[], )<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432 \u0444\u0430\u0439\u043b \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.\u00a0\u042f \u043f\u043e\u043c\u043e\u0433\u0430\u044e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0438.<\/p>\n<p><strong>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0433\u043b\u0443\u0431\u0438\u043c\u0441\u044f \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439:<\/strong><\/p>\n<pre><code>import asyncio from functools import partial from typing import Callable, Coroutine, Iterable  from fastapi import APIRouter, FastAPI from fastapi.exceptions import RequestValidationError from pydantic import ValidationError  from src.infrastructure.errors import (     BaseError,     custom_base_errors_handler,     pydantic_validation_errors_handler,     python_base_error_handler, )  __all__ = (\"create\",)   def create(     *_,     rest_routers: Iterable[APIRouter],     startup_tasks: Iterable[Callable[[], Coroutine]] | None = None,     shutdown_tasks: Iterable[Callable[[], Coroutine]] | None = None,     **kwargs, ) -> FastAPI:     \"\"\"The application factory using FastAPI framework.     ? Only passing routes is mandatory to start.     \"\"\"      # Initialize the base FastAPI application     app = FastAPI(**kwargs)      # Include REST API routers     for router in rest_routers:  <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-355164","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/355164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=355164"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/355164\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=355164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=355164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=355164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}