{"id":15154429,"url":"https://github.com/akmamun/flask-pymongo","last_synced_at":"2025-09-30T02:30:24.819Z","repository":{"id":106930692,"uuid":"168020772","full_name":"akmamun/flask-pymongo","owner":"akmamun","description":"Python (Flask) and Mongo DB Restful Micro Service Architecture","archived":true,"fork":false,"pushed_at":"2019-08-06T07:42:58.000Z","size":38,"stargazers_count":2,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-19T19:39:23.112Z","etag":null,"topics":["api-validator","custom-validation","field-validation","flask","flask-validator","form-validation","model","mongo-db","mongoengine","python","python-validator","rest-api","restful-flask","restful-webservices","validator"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akmamun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-28T19:15:47.000Z","updated_at":"2024-03-14T06:43:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"78620ece-4ffa-4556-924e-956f368127b8","html_url":"https://github.com/akmamun/flask-pymongo","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.0357142857142857,"last_synced_commit":"07b34d88047b3b53f5964d15616677f8bf5d63b7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/akmamun/flask-pymongo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akmamun%2Fflask-pymongo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akmamun%2Fflask-pymongo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akmamun%2Fflask-pymongo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akmamun%2Fflask-pymongo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akmamun","download_url":"https://codeload.github.com/akmamun/flask-pymongo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akmamun%2Fflask-pymongo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277618557,"owners_count":25848553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-30T02:00:09.208Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-validator","custom-validation","field-validation","flask","flask-validator","form-validation","model","mongo-db","mongoengine","python","python-validator","rest-api","restful-flask","restful-webservices","validator"],"created_at":"2024-09-26T17:23:29.035Z","updated_at":"2025-09-30T02:30:24.814Z","avatar_url":"https://github.com/akmamun.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Model Based Restful Flask and Mongo DB\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"280\" height=\"140\" src=\"https://cdn-images-1.medium.com/max/800/1*vB-cUmm1_dBBt-4JtL0u5g.jpeg\"\u003e\n\u003c/p\u003e\n\n### Note: Front-end React API Integration Here [react-api-integration](https://github.com/mrxmamun/react-api-integration.git)\n- Without restful package try this one [flask-mvc-pymongo](https://github.com/mrxmamun/flask-mvc-pymongo.git) \n#### Model based restful flask (python) and mongo db. Integrate with any API development.  \n\n### Create [virtual environment]('https://docs.python.org/3/library/venv.html) and install requirements \n```sh\npip install -r requirements.txt\n```\n### Configure Database\n#### From [db_config.json](src/db_config.json) configure datbase url, name, user and password \n```json\n {\n   \"db\": {\n            \"url\" : \"mongodb://localhost:27017/\",\n            \"name\" :\"db_name\",  \n            \"user\" :\"\",\n            \"password\" :\"\"\n    }\n }\n``` \n\n## In model update collection name and desire fields name and fields type. For example see todo [model](src/models/todo.py) file\n#### From [model](src/models) folder write your individual model and configure db collection name, fields name and fields type\n#### Example\n##### In todo [model](src/models/todo.py) update collection name, fields name and fields type\n```py\ncollection_name = 'todos'   # collection name\nfields = {   \n    \"title\"     : \"string\",\n    \"body\"      : \"string\",\n    \"created\"   : \"datatime\"\n} \n```\n\n##### Update required fields, optional fields from todo [model](src/models/todo.py)\n```py\ncreate_required_fields = []  # example create_required_fields = [\"title\", \"body\"]\ncreate_optional_fields = []  # example create_required_fields = [\"created\"]\nupdate_required_fields = []\nupdate_optional_fields = []\n```\n#### Example \n```py\ncreate_required_fields = [\"title\", \"body\"] \ncreate_optional_fields = []  \nupdate_required_fields = [\"title\", \"body\"]\nupdate_optional_fields = []\n```\n#### In [Database](src/factory/database.py) insert, find , find_by_id, update and delete methods are generalize methods.  \n#### Those methods are call from [model](src/models) \n- `insert` method store data to database after confirm validation from model \n- `find` method retries all data from mongo database \n- `find_by_id` method retries back a single search data\n- `update` method store updated data to database with corresponding id \n- and `delete` method delete data from database with corresponding id \n\n#### List of Todo Routes\n| Request | Endpoint |  Details |\n| --- | --- | --- |\n| `GET` | `http://127.0.0.1:5000/api/v1/todos`| Get All|\n| `GET` | `http://127.0.0.1:5000/api/v1/todos/todo_id`| Get Single Id|\n| `POST` | `http://127.0.0.1:5000/api/v1/todos`| Insert One|\n| `PUT` | `http://127.0.0.1:5000/api/v1/todos/todo_id`| Update One|\n| `DELETE` | `http://127.0.0.1:5000/api/v1/todos/todo_id`| Delete One|\n\n- To see route list type cli `flask routes`\n\n### Lets run the App\n```sh\npython app.py \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakmamun%2Fflask-pymongo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakmamun%2Fflask-pymongo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakmamun%2Fflask-pymongo/lists"}