{"id":20120283,"url":"https://github.com/kalelmartinho/carford-api","last_synced_at":"2026-04-11T13:35:18.578Z","repository":{"id":158339481,"uuid":"606778391","full_name":"kalelmartinho/carford-api","owner":"kalelmartinho","description":"RESTful API for managing car owners and their cars. The API had to be built using Python and Flask, and it needed to allow users to create, read, update, and delete owners and cars.","archived":false,"fork":false,"pushed_at":"2023-02-26T14:45:00.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-03T22:29:06.881Z","etag":null,"topics":["docker","docker-compose","flask","jwt-authentication","python","restful-api"],"latest_commit_sha":null,"homepage":"","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/kalelmartinho.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":"2023-02-26T14:43:25.000Z","updated_at":"2024-02-01T02:29:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"81006f5c-1176-44a9-9ac7-4ee52fe99abe","html_url":"https://github.com/kalelmartinho/carford-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kalelmartinho/carford-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalelmartinho%2Fcarford-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalelmartinho%2Fcarford-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalelmartinho%2Fcarford-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalelmartinho%2Fcarford-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kalelmartinho","download_url":"https://codeload.github.com/kalelmartinho/carford-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalelmartinho%2Fcarford-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31682953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T13:07:20.380Z","status":"ssl_error","status_checked_at":"2026-04-11T13:06:47.903Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["docker","docker-compose","flask","jwt-authentication","python","restful-api"],"created_at":"2024-11-13T19:19:27.806Z","updated_at":"2026-04-11T13:35:18.527Z","avatar_url":"https://github.com/kalelmartinho.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CARFORD SYSTEM API\n\nThis is a simple RESTful API for the following challenge:\n\n```\nNork-Town is a weird place. Crows cawk the misty morning while old men squint. It’s a small\ntown, so the mayor had a bright idea to limit the number of cars a person may possess. One\nperson may have up to 3 vehicles. The vehicle, registered to a person, may have one color,\n‘yellow’, ‘blue’ or ‘gray’. And one of three models, ‘hatch’, ‘sedan’ or ‘convertible’.\nCarford car shop want a system where they can add car owners and cars. Car owners may\nnot have cars yet, they need to be marked as a sale opportunity. Cars cannot exist in the\nsystem without owners.\n```\n\nThe challenge was to build a simple RESTful API for managing car owners and their cars. The API had to be built using Python and Flask, and it needed to allow users to create, read, update, and delete owners and cars.\n\n\n### The challenge had the following requirements:\n\n- Setup the dev environment with docker\n- Using docker-compose with as many volumes as it takes\n- Use Python’s Flask framework and any other library\n- Use any SQL database\n- Secure routes\n- Write tests\n\n### And the following rules:\n\n- The vehicle, registered to a person, may have one color,‘yellow’, ‘blue’ or ‘gray’\n- The vehicle, registered to a person may have one of three models, ‘hatch’, ‘sedan’ or ‘convertible’\n- Cars cannot exist in the system without owners.\n- One person may have up to 3 vehicles.\n\nOverall, the challenge aimed to assess the candidate's ability to design and implement a simple RESTful API that met a specific set of requirements, as well as their ability to write clean and well-documented code and their skill in writing effective unit tests.\n\n\n\n## Overview\n\nThis RESTful API allows you to manage car owners and their cars.  You can create, read, update, and delete owners and their cars.\nThe project is built using Python, Flask framework, SQLAlchemy and utilizes JWT for authentication. It also uses Docker for containerization and Flask-Migrate for database migrations.\n\n\n## Getting Started\n\n1. Clone this repository: \n\n```\ngit clone https://github.com/kalelmartinho/carford-api.git\n```\n\n2. Create a virtual environment:\n\n```\npython venv venv\n```\n\n3. Activate the virtual environment\n\nWindows:\n```\n./venv/Scripts/Activate.ps1\n```\nLinux or Unix:\n```\nsource venv/bin/activate\n```\n\n4. Install the required packages:\n\n```\npip install -r requirements.txt\n```\n\n5. Create the database tables using Flask-Migrate: \n\n```\nflask db init\nflask db migrate\nflask db upgrade\n``` \n\n6. Build the docker image:\n\n```\ndocker-compose build\n```\n\n7. Start the Docker container:\n\n```\ndocker-compose up\n```\n\n-The application should now be running at http://localhost:5000.\n\n\n## Tests\n\nYou can run the tests by\n\n1. Installing pytest:\n\n```\npip install pytest\n```\n\n2. run pytest in terminal\n\n```\npytest\n```\n\n## Authentication\n\nAll API endpoints require authentication using a JWT token.\n\n| Endpoint                            | HTTP Method | Result                                     |\n| ----------------------------------- | -----------| ------------------------------------------ |\n| /auth/register                      | POST       | Register a new user                 |\n| /auth/login                         | POST       | Get a Bearer token                  |\n\nTo obtain a token, send a POST request to /api/auth/login with a JSON body containing your username and password. For example:\n\n```\n{\n  \"username\": \"yourusername\",\n  \"password\": \"yourpassword\"\n}\n```\n\nIf the credentials are correct, the API will respond with a JSON object containing the token. For example:\n\n```\n{\n  \"access_token\": \"yourjwttoken\"\n}\n```\n\nInclude this token in the Authorization header of all subsequent requests. For example:\n\n\n```\n{\n  \"Authorization\": \"Bearer yourjwttoken\"\n}\n```\n\n## API Endpoints\n\n### Owners\n\n| Endpoint                            | HTTP Method | Result                                     |\n| ----------------------------------- | -----------| ------------------------------------------ |\n| /api/owners                         | GET        | Get all owners                             |\n| /api/owners/\u003cint:owner_id\u003e          | GET        | Get a single owner by ID                   |\n| /api/owners                         | POST       | Create a new owner                         |\n| /api/owners/\u003cint:owner_id\u003e          | PUT        | Update an existing owner by ID             |\n| /api/owners/\u003cint:owner_id\u003e          | DELETE     | Delete an existing owner by ID             |\n\n### Cars\n\n| Endpoint                            | HTTP Method | Result                                     |\n| ----------------------------------- | -----------| ------------------------------------------ |\n| /api/cars                           | GET        | Get all cars                                |\n| /api/cars/\u003cint:car_id\u003e              | GET        | Get a single car by ID                      |\n| /api/cars                           | POST       | Add a new car to an existing owner by ID    |\n| /api/cars/\u003cint:car_id\u003e              | PUT        | Update an existing car by ID                |\n| /api/cars/\u003cint:car_id\u003e              | DELETE     | Delete an existing car by ID                |\n\n\n\n## 🚀 Author\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\n      \u003ca href=\"#\"\u003e\n        \u003cimg src=\"https://avatars.githubusercontent.com/u/74933799\" width=\"100px;\" alt=\"Foto do Kalel Leonardo Martinho no GitHub\"/\u003e\u003cbr\u003e\n        \u003csub\u003e\n          \u003cb\u003eKalel L. Martinho\u003c/b\u003e\n        \u003c/sub\u003e\n      \u003c/a\u003e\n      \u003cp\u003e\n    Python Dev\n      \u003c/p\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## License\n\nThis project is licensed under the MIT License ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkalelmartinho%2Fcarford-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkalelmartinho%2Fcarford-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkalelmartinho%2Fcarford-api/lists"}