{"id":21888594,"url":"https://github.com/felixojiambo/customer-order-system","last_synced_at":"2026-04-05T23:37:52.037Z","repository":{"id":262966679,"uuid":"859160821","full_name":"felixojiambo/customer-order-system","owner":"felixojiambo","description":"Customer Order Management API: A service with REST APIs for managing customers and orders, featuring authentication, SMS notifications, and CI/CD setup.","archived":false,"fork":false,"pushed_at":"2024-11-15T11:34:55.000Z","size":191,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T20:32:19.975Z","etag":null,"topics":["azure","cicd","database","django-rest-framework","docker","helm","jwt","kurbenetes","openid-connect","postgresql","python","sms-api","unit-testing"],"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/felixojiambo.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":"2024-09-18T07:34:40.000Z","updated_at":"2024-11-15T11:24:00.000Z","dependencies_parsed_at":"2024-11-15T10:25:17.691Z","dependency_job_id":"d8b9db07-373b-442e-9652-b60323f01884","html_url":"https://github.com/felixojiambo/customer-order-system","commit_stats":null,"previous_names":["felixojiambo/customer-order-system"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixojiambo%2Fcustomer-order-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixojiambo%2Fcustomer-order-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixojiambo%2Fcustomer-order-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixojiambo%2Fcustomer-order-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felixojiambo","download_url":"https://codeload.github.com/felixojiambo/customer-order-system/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244895537,"owners_count":20527903,"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":["azure","cicd","database","django-rest-framework","docker","helm","jwt","kurbenetes","openid-connect","postgresql","python","sms-api","unit-testing"],"created_at":"2024-11-28T11:15:59.965Z","updated_at":"2025-12-30T23:54:00.484Z","avatar_url":"https://github.com/felixojiambo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Customer Order Management System API\n\nThis is a Django-based REST API for managing customer orders, including Firebase Authentication for secure access and Africa's Talking integration for sending SMS notifications. It provides CRUD operations on orders, user authentication via Firebase tokens, and automatic SMS alerts for order placements.\n\n---\n\n## **Overview**\n\nThe **Customer Order Management System** allows users to:\n- Register and log in via Firebase Authentication.\n- Create, view, update, and delete their orders.\n- Receive SMS alerts via Africa's Talking API when new orders are placed.\n- View API documentation via Swagger and ReDoc.\n- Use JWT tokens for securing endpoints.\n\nThis API is designed for multi-user environments where authenticated users can manage their own orders while ensuring secure access and notifications.\n\n---\n\n## **Features**\n\n- **Firebase Authentication**: Secures user registration and login using OpenID Connect (OIDC) and Firebase tokens.\n- **Order Management**: Full CRUD support for managing customer orders.\n- **SMS Alerts**: Sends order confirmation SMS to customers using Africa's Talking API.\n- **Swagger API Documentation**: Interactive documentation and testing using Swagger UI and ReDoc.\n- **OAuth2 Support**: For OpenID Connect (OIDC) authentication.\n- **JWT Token Authentication**: For securing endpoints after login.\n\n---\n\n## **Setup and Installation**\n\n### **Prerequisites**\n\nTo run this project, you will need the following:\n\n- **Docker** \u0026 **Docker Compose** (For containerized setup)\n- **Python 3.12**\n- **Django 5.x**\n- **PostgreSQL** (If not using Docker)\n- **Africa's Talking API Credentials** (For sending SMS)\n- **Firebase Project** (For Authentication)\n\n---\n\n## **Clone the Repository**\n\n```bash\ngit clone https://github.com/felixojiambo/customer-order-system.git\ncd customer-order-system\n```\n\n---\n\n## **Environment Variables**\n\nCreate a `.env` file in the root of your project and populate it with the following environment variables:\n\n```bash\n# Django settings\nSECRET_KEY=your-django-secret-key\nDEBUG=True  # Set to False in production\nALLOWED_HOSTS=localhost,127.0.0.1\n\n# Firebase configuration\nFIREBASE_API_KEY=your-firebase-api-key\nFIREBASE_PROJECT_ID=your-firebase-project-id\nFIREBASE_AUTH_DOMAIN=your-firebase-auth-domain\nFIREBASE_DATABASE_URL=your-firebase-database-url\nFIREBASE_STORAGE_BUCKET=your-firebase-storage-bucket\nFIREBASE_MESSAGING_SENDER_ID=your-firebase-messaging-sender-id\nFIREBASE_APP_ID=your-firebase-app-id\nFIREBASE_PRIVATE_KEY=your-firebase-private-key\nFIREBASE_CLIENT_EMAIL=your-firebase-client-email\n\n# Africa's Talking API credentials\nAFRICASTALKING_USERNAME=sandbox\nAFRICASTALKING_API_KEY=your-africastalking-api-key\n```\n\n---\n\n## **Docker Setup**\n\nThe easiest way to get the application up and running is via Docker.\n\n### **Build and Start the Application**\n\n```bash\ndocker-compose up --build\n```\n\nThis command will:\n- Build and start the Django app on `http://localhost:8000`.\n- Set up a PostgreSQL database in a Docker container.\n\n### **Stopping the Application**\n\n```bash\ndocker-compose down\n```\n\n### **Optional Local Setup (Without Docker)**\n\nIf you prefer to run the application locally without Docker:\n\n1. **Create and activate a virtual environment**:\n    ```bash\n    python3 -m venv venv\n    source venv/bin/activate  # On Windows, use `venv\\Scripts\\activate`\n    ```\n\n2. **Install dependencies**:\n    ```bash\n    pip install -r requirements.txt\n    ```\n\n3. **Run Migrations**:\n    ```bash\n    python manage.py makemigrations\n    python manage.py migrate\n    ```\n\n4. **Start the development server**:\n    ```bash\n    python manage.py runserver\n    ```\n\nThe application will be available at `http://localhost:8000`.\n\n---\n\n## **API Endpoints Documentation**\n\n### **1. User Registration**\nPermissions: Open to all users. No authentication required.\n\n#### **Request**:\n- **POST** `/api/register/`\n```json\n{\n  \"username\": \"newuser\",\n  \"email\": \"user@example.com\",\n  \"password\": \"strongpassword123\",\n  \"phone_number\": \"+254700000000\"\n}\n```\n\n#### **Response**:\n- **201 Created**\n```json\n{\n  \"uid\": \"firebase_uid\",\n  \"email\": \"user@example.com\"\n}\n```\n- **400 Bad Request**: If the user already exists or if input validation fails.\n\n---\n\n### **2. User Login**\nPermissions: Open to all users. No authentication required.\n\n#### **Request**:\n- **POST** `/api/login/`\n```json\n{\n  \"email\": \"user@example.com\",\n  \"password\": \"strongpassword123\"\n}\n```\n\n#### **Response**:\n- **200 OK**\n```json\n{\n  \"token\": \"firebase_id_token\"\n}\n```\n- **401 Unauthorized**: If the email/password is incorrect.\n\n---\n\n### **3. Create an Order**\nPermissions: Requires JWT authentication.\n\n#### **Request**:\n- **POST** `/api/orders/create/`\n```json\n{\n  \"item\": \"Laptop\",\n  \"amount\": 1200.00\n}\n```\n\n#### **Response**:\n- **201 Created**\n```json\n{\n  \"id\": 1,\n  \"item\": \"Laptop\",\n  \"amount\": \"1200.00\",\n  \"order_number\": \"LA20240921123000\"\n}\n```\n- **400 Bad Request**: If the input data is invalid.\n- **401 Unauthorized**: If the user is not authenticated.\n\n---\n\n### **4. List Orders**\nPermissions: Requires JWT authentication.\n\n#### **Request**:\n- **GET** `/api/orders/`\n#### **Response**:\n- **200 OK**\n```json\n[\n  {\n    \"id\": 1,\n    \"item\": \"Laptop\",\n    \"amount\": \"1200.00\",\n    \"order_number\": \"LA20240921123000\",\n    \"status\": \"Pending\"\n  }\n]\n```\n- **401 Unauthorized**: If the user is not authenticated.\n\n---\n\n### **5. Retrieve Order Details**\nPermissions: Requires JWT authentication.\n\n#### **Request**:\n- **GET** `/api/orders/{id}/`\n\n#### **Response**:\n- **200 OK**\n```json\n{\n  \"id\": 1,\n  \"item\": \"Laptop\",\n  \"amount\": \"1200.00\",\n  \"order_number\": \"LA20240921123000\",\n  \"status\": \"Pending\"\n}\n```\n- **404 Not Found**: If the order is not found or does not belong to the authenticated user.\n- **401 Unauthorized**: If the user is not authenticated.\n\n---\n\n### **6. Update Order**\nPermissions: Requires JWT authentication.\n\n#### **Request**:\n- **PUT** `/api/orders/{id}/`\n```json\n{\n  \"item\": \"Gaming Laptop\",\n  \"amount\": 1500.00\n}\n```\n\n#### **Response**:\n- **200 OK**\n```json\n{\n  \"id\": 1,\n  \"item\": \"Gaming Laptop\",\n  \"amount\": \"1500.00\",\n  \"order_number\": \"LA20240921123000\",\n  \"status\": \"Pending\"\n}\n```\n- **401 Unauthorized**: If the user is not authenticated.\n- **404 Not Found**: If the order does not exist or does not belong to the authenticated user.\n\n---\n\n### **7. Delete Order**\nPermissions: Requires JWT authentication.\n\n#### **Request**:\n- **DELETE** `/api/orders/{id}/`\n\n#### **Response**:\n- **204 No Content**\n\n- **401 Unauthorized**: If the user is not authenticated.\n- **404 Not Found**: If the order does not exist or does not belong to the authenticated user.\n\n---\n\n## **Testing**\n\nThis project uses **Pytest** for unit and integration testing. Firebase authentication and Africa's Talking API calls are mocked for testing purposes.\n\n### **Running Tests**\n\n```bash\npytest\n```\n\n### **Mocked Test Scenarios**:\n- **User Registration**: Simulates Firebase user creation.\n- **Order Creation**: Tests if authenticated users can create orders and send SMS alerts.\n- **User Login**: Simulates Firebase login and JWT generation.\n\n---\n\n## **Folder Structure**\n\n```\ncustomer_order_service/\n│\n├── customerorder/                # Main application\n│   ├── migrations/               # Django migrations\n│   ├── models.py                 # Data models (User, Order)\n│   ├── serializers.py            # DRF serializers\n│   ├── views.py                  # API views (Register, Login, Order CRUD)\n│   ├── africastalking_utils.py   # Africa's Talking SMS integration\n│   └── authentication.py         # Firebase authentication\n│\n├── customer_order_service/\n│   ├── settings.py               # Project settings\n│   └── urls.py                   # URL routing\n│\n├── templates/                    # Django templates (optional)\n├── .env                          # Environment variables\n├── docker-compose.yml            # Docker setup\n├── Dockerfile                    # Docker image configuration\n├── requirements.txt              # Python dependencies\n└── manage.py                     # Django management commands\n```\n\n---\n\n## **License**\n\nThis project is licensed under the MIT License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixojiambo%2Fcustomer-order-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelixojiambo%2Fcustomer-order-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixojiambo%2Fcustomer-order-system/lists"}