{"id":14449353,"url":"https://github.com/assemmarwan/model_generator","last_synced_at":"2025-08-28T03:31:57.559Z","repository":{"id":195410650,"uuid":"229332162","full_name":"assemmarwan/model_generator","owner":"assemmarwan","description":"A Frappé application to generate models based on Doctypes","archived":false,"fork":false,"pushed_at":"2020-12-28T06:45:41.000Z","size":3162,"stargazers_count":15,"open_issues_count":4,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-01T08:05:24.642Z","etag":null,"topics":["dart","doctype","frappe","javascript","model","typescript"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/assemmarwan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-12-20T20:32:29.000Z","updated_at":"2024-03-08T10:16:52.000Z","dependencies_parsed_at":"2023-09-17T20:52:15.076Z","dependency_job_id":null,"html_url":"https://github.com/assemmarwan/model_generator","commit_stats":null,"previous_names":["assemmarwan/model_generator"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemmarwan%2Fmodel_generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemmarwan%2Fmodel_generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemmarwan%2Fmodel_generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemmarwan%2Fmodel_generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/assemmarwan","download_url":"https://codeload.github.com/assemmarwan/model_generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231220666,"owners_count":18343318,"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","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":["dart","doctype","frappe","javascript","model","typescript"],"created_at":"2024-09-01T08:01:14.968Z","updated_at":"2024-12-25T09:51:00.652Z","avatar_url":"https://github.com/assemmarwan.png","language":"Python","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# Model Generator\n\nGenerate models to different languages based on Doctype.\n\n## Motive\n\nDuring development, the doctypes are defined usually by the backend team. Front-end development teams will require to write the models for these doctypes in the front-end as models which usually counts much as manual and repetitive task.\n\nSince it's repetitive and somewhat an annoying task, I saw an opportunity to some extent automate this task with some minor configurations in the doctype and refactoring in the frontend which will hopefully reduce the time wasted achieving this task.\n\n### Doctypes included\n\n- Model Generator\n- Language Model Configuration\n\n\n#### Model Generator Demo\n\n![Demo](demo.gif)\n\n#### Language Model Configuration\n\nA doctype to configure the templates and data types for each language. By default, there are two fixtures defined:\n- Dart/Flutter\n- TS/JS\n\nConfigurations include:\n\n- **Data Type Map**. For instance, `Data` fieldtype is a `String` in Dart/Flutter.\n- Variable and type template. For instance for *Dart*:\n  ```\n  {{fieldtype}} {{fieldname}};\n  ```\n  which results in:\n  ```dart\n  String fullName;\n  ```\n- **Signature Start** which indicates the beginning of the model like *class* or *interface*.\n- **Signature End** which indicates the end of the model of a *class* or *interface*.\n- **Child Doctype Template** which indicates the representation of a child doctype in a model. For instance in *Dart*:\n   ```\n   List\u003c{{child_doctype}}\u003e\n   ```\n   which results in:\n   ```dart\n   List\u003cRole\u003e roles;\n   ```\n- **To Camel Case** which converts the field names from the standard naming in Frappé, snake-case, to camel-case which is the convention, *Dart*, for instance.\n- **Decorator (Only used if To Camel Case is checked** where this is used for languages (Dart or C#, for instance), to convert the naming between backend and frontend.\n\n### API\nIn addition to utilizing this app through Frappé UI, it can also be utilized using an endpoint (`POST`). Example:\n```json\n{\n  \"cmd\": \"model_generator.api.generate_model\",\n  \"lang_config\": \"Dart\",\n  \"include_std_fields\": 0,\n  \"fields\": {\n    \"User\": [\n      {\n        \"fieldname\": \"enabled\",\n        \"fieldtype\": \"Check\"\n      },\n      {\n        \"fieldname\": \"email\",\n        \"fieldtype\": \"Data\"\n      },\n      {\n        \"fieldname\": \"first_name\",\n        \"fieldtype\": \"Data\"\n      },\n      {\n        \"fieldname\": \"middle_name\",\n        \"fieldtype\": \"Data\"\n      },\n      {\n        \"fieldname\": \"last_name\",\n        \"fieldtype\": \"Data\"\n      },\n      {\n        \"fieldname\": \"full_name\",\n        \"fieldtype\": \"Data\"\n      },\n      {\n        \"fieldname\": \"send_welcome_email\",\n        \"fieldtype\": \"Check\"\n      },\n      {\n        \"fieldname\": \"unsubscribed\",\n        \"fieldtype\": \"Check\"\n      },\n      {\n        \"fieldname\": \"username\",\n        \"fieldtype\": \"Data\"\n      },\n      {\n        \"fieldname\": \"language\",\n        \"fieldtype\": \"Link\"\n      },\n      {\n        \"fieldname\": \"time_zone\",\n        \"fieldtype\": \"Select\"\n      },\n      {\n        \"fieldname\": \"user_image\",\n        \"fieldtype\": \"Attach Image\"\n      },\n      {\n        \"fieldname\": \"role_profile_name\",\n        \"fieldtype\": \"Link\"\n      },\n      {\n        \"fieldname\": \"gender\",\n        \"fieldtype\": \"Link\"\n      },\n      {\n        \"fieldname\": \"phone\",\n        \"fieldtype\": \"Data\"\n      },\n      {\n        \"fieldname\": \"mobile_no\",\n        \"fieldtype\": \"Data\"\n      },\n      {\n        \"fieldname\": \"birth_date\",\n        \"fieldtype\": \"Date\"\n      },\n      {\n        \"fieldname\": \"location\",\n        \"fieldtype\": \"Data\"\n      },\n      {\n        \"fieldname\": \"banner_image\",\n        \"fieldtype\": \"Attach Image\"\n      },\n      {\n        \"fieldname\": \"interest\",\n        \"fieldtype\": \"Small Text\"\n      },\n      {\n        \"fieldname\": \"bio\",\n        \"fieldtype\": \"Small Text\"\n      },\n      {\n        \"fieldname\": \"mute_sounds\",\n        \"fieldtype\": \"Check\"\n      },\n      {\n        \"fieldname\": \"new_password\",\n        \"fieldtype\": \"Password\"\n      },\n      {\n        \"fieldname\": \"logout_all_sessions\",\n        \"fieldtype\": \"Check\"\n      },\n      {\n        \"fieldname\": \"reset_password_key\",\n        \"fieldtype\": \"Data\"\n      },\n      {\n        \"fieldname\": \"last_password_reset_date\",\n        \"fieldtype\": \"Date\"\n      },\n      {\n        \"fieldname\": \"redirect_url\",\n        \"fieldtype\": \"Small Text\"\n      },\n      {\n        \"fieldname\": \"document_follow_notify\",\n        \"fieldtype\": \"Check\"\n      },\n      {\n        \"fieldname\": \"document_follow_frequency\",\n        \"fieldtype\": \"Select\"\n      },\n      {\n        \"fieldname\": \"thread_notify\",\n        \"fieldtype\": \"Check\"\n      },\n      {\n        \"fieldname\": \"send_me_a_copy\",\n        \"fieldtype\": \"Check\"\n      },\n      {\n        \"fieldname\": \"allowed_in_mentions\",\n        \"fieldtype\": \"Check\"\n      },\n      {\n        \"fieldname\": \"email_signature\",\n        \"fieldtype\": \"Small Text\"\n      },\n      {\n        \"fieldname\": \"home_settings\",\n        \"fieldtype\": \"Code\"\n      },\n      {\n        \"fieldname\": \"simultaneous_sessions\",\n        \"fieldtype\": \"Int\"\n      },\n      {\n        \"fieldname\": \"user_type\",\n        \"fieldtype\": \"Select\"\n      },\n      {\n        \"fieldname\": \"login_after\",\n        \"fieldtype\": \"Int\"\n      },\n      {\n        \"fieldname\": \"login_before\",\n        \"fieldtype\": \"Int\"\n      },\n      {\n        \"fieldname\": \"restrict_ip\",\n        \"fieldtype\": \"Data\"\n      },\n      {\n        \"fieldname\": \"bypass_restrict_ip_check_if_2fa_enabled\",\n        \"fieldtype\": \"Check\"\n      },\n      {\n        \"fieldname\": \"last_login\",\n        \"fieldtype\": \"Read Only\"\n      },\n      {\n        \"fieldname\": \"last_ip\",\n        \"fieldtype\": \"Read Only\"\n      },\n      {\n        \"fieldname\": \"last_active\",\n        \"fieldtype\": \"Datetime\"\n      },\n      {\n        \"fieldname\": \"last_known_versions\",\n        \"fieldtype\": \"Text\"\n      },\n      {\n        \"fieldname\": \"api_key\",\n        \"fieldtype\": \"Data\"\n      },\n      {\n        \"fieldname\": \"api_secret\",\n        \"fieldtype\": \"Password\"\n      },\n      {\n        \"doctype\": \"Has Role\",\n        \"fieldname\": \"roles\",\n        \"fields\": [\n          {\n            \"fieldname\": \"role\",\n            \"fieldtype\": \"Link\"\n          }\n        ]\n      },\n      {\n        \"doctype\": \"User Email\",\n        \"fieldname\": \"user_emails\",\n        \"fields\": [\n          {\n            \"fieldname\": \"email_account\",\n            \"fieldtype\": \"Link\"\n          },\n          {\n            \"fieldname\": \"email_id\",\n            \"fieldtype\": \"Data\"\n          },\n          {\n            \"fieldname\": \"awaiting_password\",\n            \"fieldtype\": \"Check\"\n          },\n          {\n            \"fieldname\": \"enable_outgoing\",\n            \"fieldtype\": \"Check\"\n          }\n        ]\n      },\n      {\n        \"doctype\": \"Block Module\",\n        \"fieldname\": \"block_modules\",\n        \"fields\": [\n          {\n            \"fieldname\": \"module\",\n            \"fieldtype\": \"Data\"\n          }\n        ]\n      },\n      {\n        \"doctype\": \"DefaultValue\",\n        \"fieldname\": \"defaults\",\n        \"fields\": [\n          {\n            \"fieldname\": \"defkey\",\n            \"fieldtype\": \"Data\"\n          },\n          {\n            \"fieldname\": \"defvalue\",\n            \"fieldtype\": \"Text\"\n          }\n        ]\n      },\n      {\n        \"doctype\": \"User Social Login\",\n        \"fieldname\": \"social_logins\",\n        \"fields\": [\n          {\n            \"fieldname\": \"provider\",\n            \"fieldtype\": \"Data\"\n          },\n          {\n            \"fieldname\": \"username\",\n            \"fieldtype\": \"Data\"\n          },\n          {\n            \"fieldname\": \"userid\",\n            \"fieldtype\": \"Data\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n\n## Contribution\nContributions in all shapes, forms and sizes are welcome :)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassemmarwan%2Fmodel_generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fassemmarwan%2Fmodel_generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassemmarwan%2Fmodel_generator/lists"}