{"id":38991568,"url":"https://github.com/rbakulin/mortgage_api","last_synced_at":"2026-01-17T17:04:04.613Z","repository":{"id":38021397,"uuid":"283893705","full_name":"rbakulin/mortgage_api","owner":"rbakulin","description":"REST API for calculating mortgage parameters","archived":false,"fork":false,"pushed_at":"2024-04-06T12:01:47.000Z","size":286,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-06T13:23:10.362Z","etag":null,"topics":["django","django-rest-framework","docker","docker-compose","logging","mortgage","postgresql","python","rest-api","swagger"],"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/rbakulin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2020-07-30T23:02:16.000Z","updated_at":"2024-04-06T13:23:14.798Z","dependencies_parsed_at":"2024-04-06T13:23:14.000Z","dependency_job_id":"0b5a1fd8-7d27-4c06-93e5-b391b47603cf","html_url":"https://github.com/rbakulin/mortgage_api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rbakulin/mortgage_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbakulin%2Fmortgage_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbakulin%2Fmortgage_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbakulin%2Fmortgage_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbakulin%2Fmortgage_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rbakulin","download_url":"https://codeload.github.com/rbakulin/mortgage_api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbakulin%2Fmortgage_api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28511876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["django","django-rest-framework","docker","docker-compose","logging","mortgage","postgresql","python","rest-api","swagger"],"created_at":"2026-01-17T17:04:03.912Z","updated_at":"2026-01-17T17:04:04.599Z","avatar_url":"https://github.com/rbakulin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\" style=\"font-size: 3rem;\"\u003e\nMORTGAGE-API 🏠\n\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n \u003cem\u003eREST API that allows to calculate mortgage details, such as payment schedule and principal/interest breakdown. \nSupports addition of extra payments - they will be dynamically incorporated into the payment schedule.\u003c/em\u003e\u003c/p\u003e\n\n---\n## Basic info\nAn annuity repayment scheme is used for calculations. \nThe formula for calculating a monthly payment: \n```\nPAYMENT = LOAN AMOUNT * (INTEREST RATE / (1 + INTEREST RATE) - NUMBER OF MONTHS - 1)\n```\nThe final payment may be less than the standard monthly payment, so the amount of the final payment is equal to the \nremaining balance after the previous payment was made.\n## Run\nYou can run the app natively:\n```shell\npip install poetry\npoetry install\npython manage.py migrate\npython manage.py runserver\n```\nOr via docker-compose:\n```shell\ndocker-compose run app python manage.py migrate\ndocker-compose up\n```\n## Quickstart\n1. Create a user:\u003cbr\u003e\u003cb\u003ePOST\u003c/b\u003e `127.0.0.1:8000/auth/register/`\n```json\n{\n    \"username\": \"admin\",\n    \"password\": \"adminadmin\",\n    \"password2\": \"adminadmin\",\n    \"email\": \"admin@example.com\"\n}\n```\n2. Get a token:\u003cbr\u003e\u003cb\u003ePOST\u003c/b\u003e `127.0.0.1:8000/auth/token/`\n```json\n{\n    \"username\": \"admin\",\n    \"password\": \"adminadmin\"\n}\n```\n3. Create a mortgage:\u003cbr\u003e\u003cb\u003ePOST\u003c/b\u003e `127.0.0.1:8000/api/v1/mortgage/`\u003cbr\u003e\u003cem\u003eheaders: {Authorization: Bearer \u003cyour_token_value\u003e}\u003c/em\u003e\n```json\n{\n    \"percent\": \"8.20\",\n    \"period\": 25,\n    \"first_payment_amount\": 2500000,\n    \"credit_amount\": 11000000,\n    \"issue_date\": \"2021-09-04\"\n}\n```\n4. Calculate mortgage schedule: \u003cbr\u003e\u003cb\u003ePOST\u003c/b\u003e `127.0.0.1:8000/api/v1/mortgage/\u003cmortgage_id\u003e/calc-payment-schedule/`\u003cbr\u003e\u003cem\u003eheaders: {Authorization: Bearer \u003cyour_token_value\u003e}\u003c/em\u003e\n5. Add extra payment: \u003cbr\u003e\u003cb\u003ePOST\u003c/b\u003e `127.0.0.1:8000/api/v1/mortgage/\u003cmortgage_id\u003e/add-extra-payment/`\u003cbr\u003e\u003cem\u003eheaders: {Authorization: Bearer \u003cyour_token_value\u003e}\u003c/em\u003e\n```json\n{\n    \"amount\": 70000,\n    \"date\": \"2021-10-04\"\n}\n```\n6. Check calculated payments: \u003cbr\u003e\u003cb\u003eGET\u003c/b\u003e `127.0.0.1:8000/api/v1/mortgage/\u003cmortgage_id\u003e/payment/?page_size=100\u0026page=1`\u003cbr\u003e\u003cem\u003eheaders: {Authorization: Bearer \u003cyour_token_value\u003e}\u003c/em\u003e\n## API structure\nUse Swagger to see all endpoints description: [127.0.0.1:8000/swagger/](http://127.0.0.1:8000/swagger/)\n## ⚠️ Usage essentials\n* All `mortgage/` endpoints are available only for registered users.\n* User can only see mortgages that were created by himself.\n* You can't CRUD payments directly via API - use `calc-payment-schedule/` endpoint instead.\n* Be aware that reusing the `calc-payment-schedule/` endpoint will remove any extra payment that you've already added.\n* After updating a mortgage (PUT, PATCH), payment schedule will be recalculated automatically. Also, all extra payments for this mortgage will be removed.\n* There are a few rules for adding mortgage (POST) `mortgage/`:\n   - Mortgage's period should be between 1 and 30 years.\n* There are a few rules for adding extra payments `add-extra-payment/`:\n   - Extra payment's date should be bigger than first payment's date and lower than last payment's date.\n   - Extra payment's amount should be less than previous payment's debt rest.\n* Access token expires in 1 hour, refresh token - in 24 hours (both are 24 hours for dev env). Use `token/refresh/` to refresh the token.\n## Logging\nThe app writes logs to a console and to a file named `mortgage_api.log` in (if it's not `prod` env) the app's base directory.\nThis file contains events in json representation which is easy to be parsed.\nYou can go to the `settings.py` and remove `file` handler in `LOGGING` section if it feels redundant.\nBesides default Django events all payment calculations are logged. \n## Pre-commit hooks\nMake sure you did install requirements (`poetry install`) and then just set up the git hook scripts via `pre-commit`:\n```shell\npre-commit install\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frbakulin%2Fmortgage_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frbakulin%2Fmortgage_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frbakulin%2Fmortgage_api/lists"}