{"id":25016473,"url":"https://github.com/dev-owdenmag/customer-management-api","last_synced_at":"2025-03-30T07:27:04.087Z","repository":{"id":269934477,"uuid":"908880104","full_name":"dev-owdenmag/Customer-Management-API","owner":"dev-owdenmag","description":"The Customer Management API is a robust and secure application built with Flask, designed for managing customer data and providing user authentication. Featuring JWT-based security, this API allows seamless registration, login, customer retrieval, and balance updates.","archived":false,"fork":false,"pushed_at":"2024-12-28T17:20:22.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T09:46:19.434Z","etag":null,"topics":["flask","jwt","jwt-auth","jwt-authentication","python"],"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/dev-owdenmag.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,"publiccode":null,"codemeta":null}},"created_at":"2024-12-27T07:34:10.000Z","updated_at":"2025-01-06T01:53:28.000Z","dependencies_parsed_at":"2024-12-27T09:29:11.550Z","dependency_job_id":"3945b488-d6dd-4def-b1f6-b201231e2845","html_url":"https://github.com/dev-owdenmag/Customer-Management-API","commit_stats":null,"previous_names":["dev-owdenmag/customer-management-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-owdenmag%2FCustomer-Management-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-owdenmag%2FCustomer-Management-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-owdenmag%2FCustomer-Management-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-owdenmag%2FCustomer-Management-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dev-owdenmag","download_url":"https://codeload.github.com/dev-owdenmag/Customer-Management-API/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246289240,"owners_count":20753560,"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":["flask","jwt","jwt-auth","jwt-authentication","python"],"created_at":"2025-02-05T09:42:20.178Z","updated_at":"2025-03-30T07:27:04.066Z","avatar_url":"https://github.com/dev-owdenmag.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Customer Management API\n\nProject Overview\n\nThe Customer Management API is a professional-grade application developed using Flask. It provides secure endpoints for user authentication and customer management, including balance updates and customer data retrieval. Designed for scalability and ease of integration, this API is equipped with robust JWT-based authentication and adheres to best practices in modern API development.\n\nFeatures\n\nUser Authentication: Secure registration and login using hashed passwords and JWT tokens.\n\nCustomer Management: Add, update, and retrieve customer data.\n\nData Security: All sensitive endpoints are protected using JWT-based authentication.\n\nExtensibility: Built with modularity in mind to allow for future feature additions.\n\nSetup Instructions\n\nPrerequisites\n\nPython: Ensure Python 3.8+ is installed.\n\nSQLite: No additional setup required (SQLite is included with Python).\n\nInstallation Steps\n\n1. Clone the Repository:\n\ngit clone https://github.com/your-repo/CustomerManagementAPI.git\ncd CustomerManagementAPI\n\n2. Set Up a Virtual Environment:\n\npython -m venv venv\n# On Windows:\nvenv\\Scripts\\activate\n# On macOS/Linux:\nsource venv/bin/activate\n\n3. Install Dependencies:\n\npip install -r requirements.txt\n\n4. Initialize the Database:\nThe database is automatically initialized using db.create_all() when the application starts for the first time. Alternatively, if you want to manually initialize the database, use the following SQL script:\n\n-- Initialize users table\nCREATE TABLE users (\n    id INTEGER PRIMARY KEY AUTOINCREMENT,\n    username TEXT UNIQUE NOT NULL,\n    password TEXT NOT NULL\n);\n\n-- Initialize customers table\nCREATE TABLE customers (\n    id INTEGER PRIMARY KEY AUTOINCREMENT,\n    name TEXT NOT NULL,\n    balance REAL DEFAULT 0.0\n);\n\n5. Run the Application:\n\npython app.py\nThe application will be available at http://127.0.0.1:5000.\n\nAPI Endpoints\n\nUser Authentication\n\nRegister a New User\n\nEndpoint: POST /register\n\nPayload: \n{\n  \"username\": \"test_user\",\n  \"password\": \"test_pass\"\n}\nResponse:\n\n{\"message\": \"User registered successfully\"}\n\nUser Login\n\nEndpoint: POST /login\n\nPayload:\n{\n  \"username\": \"test_user\",\n  \"password\": \"test_pass\"\n}\n\nResponse:\n{\"token\": \"YOUR_JWT_TOKEN\"}\n\nCustomer Management\n\nRetrieve All Customers\n\nEndpoint: GET /customers\n\nHeaders:\nAuthorization: Bearer YOUR_JWT_TOKEN\n\nResponse:\n[\n  {\"id\": 1, \"name\": \"Customer 1\", \"balance\": 100.0},\n  {\"id\": 2, \"name\": \"Customer 2\", \"balance\": 200.0}\n]\n\nTop Up Customer Balance\n\nEndpoint: POST /customers/\u003cid\u003e/topup\n\nHeaders:\nAuthorization: Bearer YOUR_JWT_TOKEN\n\nPayload:\n{\n  \"amount\": 50.0\n}\n\nResponse:\n{\n  \"message\": \"Balance updated successfully\",\n  \"new_balance\": 150.0\n}\n\nTesting the API\n\nYou can test the API using PowerShell, cURL, or a Python script:\n\nExample Using PowerShell\n\nTest /register:\nInvoke-RestMethod -Method POST -Uri \"http://127.0.0.1:5000/register\" `\n  -Headers @{ \"Content-Type\" = \"application/json\" } `\n  -Body '{\"username\": \"test_user\", \"password\": \"test_pass\"}'\n\n  Test /login:\n  $response = Invoke-RestMethod -Method POST -Uri \"http://127.0.0.1:5000/login\" `\n  -Headers @{ \"Content-Type\" = \"application/json\" } `\n  -Body '{\"username\": \"test_user\", \"password\": \"test_pass\"}'\n\n  $token = $response.token\n\n  Test/customers/1/topup:\n  Invoke-RestMethod -Method POST -Uri \"http://127.0.0.1:5000/customers/1/topup\" `\n  -Headers @{ \"Authorization\" = \"Bearer $token\"; \"Content-Type\" = \"application/json\" } `\n  -Body '{\"amount\": 50.0}'\n\nDependencies\n\nThe project requires the following dependencies:\n\nFlask\n\nFlask-SQLAlchemy\n\nFlask-Migrate\n\nFlask-Bcrypt\n\nFlask-JWT-Extended\n\nInstall them using the requirements.txt file:\n\npip install -r requirements.txt","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-owdenmag%2Fcustomer-management-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdev-owdenmag%2Fcustomer-management-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-owdenmag%2Fcustomer-management-api/lists"}