{"id":20612317,"url":"https://github.com/plugarut/land_registry_api","last_synced_at":"2026-06-09T14:31:09.364Z","repository":{"id":90106960,"uuid":"259375030","full_name":"PlugaruT/land_registry_api","owner":"PlugaruT","description":null,"archived":false,"fork":false,"pushed_at":"2020-05-07T09:17:16.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T18:17:30.572Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PlugaruT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-04-27T15:35:41.000Z","updated_at":"2020-05-07T09:17:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"04c04535-1e39-4d57-ba15-31c861c2649e","html_url":"https://github.com/PlugaruT/land_registry_api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PlugaruT/land_registry_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlugaruT%2Fland_registry_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlugaruT%2Fland_registry_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlugaruT%2Fland_registry_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlugaruT%2Fland_registry_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PlugaruT","download_url":"https://codeload.github.com/PlugaruT/land_registry_api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlugaruT%2Fland_registry_api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34112225,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"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":[],"created_at":"2024-11-16T10:23:59.845Z","updated_at":"2026-06-09T14:31:09.344Z","avatar_url":"https://github.com/PlugaruT.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Backend Code Challenge\n\nThis project represents a web application written in Django. The application is able to seed it's database with CSV files from [here](https://data.gov.uk/dataset/4c9b7641-cf73-4fd9-869a-4bfeed6d440e/hm-land-registry-price-paid-data).\n\n### Project Setup\n\nMake sure you have Python `3.8+` installed on your machine.\nI recommend to also create a virtual environment in order to isolate project dependencies.\n\nTo install project dependencies just run\n```\nmake install\n```\n\nAfter that, check if all the tests are green\n```\nmake test\n```\nThe project uses `black` for code formatting, and to format the code, just run\n```\nmake lint\n```\nTo start the development server on your machine, run\n```\nmake run\n```\n\nAs I mentioned, the project database needs to be seeded with data. For this, we have a download a CSV file from [here](https://data.gov.uk/dataset/4c9b7641-cf73-4fd9-869a-4bfeed6d440e/hm-land-registry-price-paid-data). Any CSV file will do.\n\nAfter that, just run\n```\npython manage.py seed_db --file_path=your_path_to_downloaded_file \n```\nThis command will read the file and will insert all it's contents into the database. All of this is done with the power of SQL 💪.\n\n### Endpoints\n\nAt the moment, there are only two endpoints available.\n\n - `/api/v1/house-prices` is the endpoint where data is grouped by month for each property type.\n    \n    For filtering of the data, there are a few query params available:\n    - `from_date`, a string of the format `YYYY-MM-DD` representing from which date the data should be filtered.\n    - `to_date`, a string of the format `YYYY-MM-DD` representing to which date the data should be filtered.\n    - `postcode`, a string representing the postcode of the region where the land is located.\n - `/api/v1/transactions` is the endpoint where transactions are grouped by price range types.\n \n    For filtering of the data, there are a few query params available:\n    - `from_date`, a string of the format `YYYY-MM-DD` representing from which date the data should be filtered.\n    - `to_date`, a string of the format `YYYY-MM-DD` representing to which date the data should be filtered.\n    - `postcode`, a string representing the postcode of the region where the land is located.\n    \n    \n### DB Tweaks\n\nThe SQL queries that are aggregating the data are relatively simple, but because of tha amount of data to aggregate, they are slow.\nBecause of this, I've added to `registry_api_landtransaction` two indexes, for `postcode` and `price` columns. After I've added these two indexes, I've seen a quite big jump in terms of speed, especially when filtering by postcode. \nThere is one more issue, filtering by date range is quite slow in my opinion, and I wasn't able to find a decent solution 😞.\n\n### Decisions\n\nAs you might have noticed, I haven't used Django ORM at all. Now, there are a few reasons why:\n - First, I could use the ORM when reading the file and storing data into DB, but, it would be very slow and doing the same action using SQL adds a big performance benefit.\n - When aggregating data, I decided to go with SQL because SQL is very good at aggregating big amount of data and the ORM would just be an intermediate layer I decided to skip.\n\nI know this may be a controversy decision, when to use and when to now use the ORM, but, if the task would be to build a CRUD API, I would definitely choose to use the ORM, but in this particular case, I decided to go with SQL because it's just better for this kind of job.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplugarut%2Fland_registry_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplugarut%2Fland_registry_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplugarut%2Fland_registry_api/lists"}