This repository contains the source code for a RESTful API service built with Django for managing customers and their orders. The API is designed to handle CRUD operations for customers and orders, and it also integrates with OpenID Connect for authentication and SMS notifications via Africa's Talking.
The project follows a standard Django project structure:
customer_order_service/
├── .github
│ └── workflows
│ └── ci-cd.yml
├── orders
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── models.py
│ ├── permissions.py
│ ├── serializers.py
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── customer_order_service
│ ├── __init__.py
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── Customer Order.postman_collection.json
├── .env.example
├── .gitignore
├── Dockerfile
├── README.md
├── manage.py
└── requirements.txt
- Customer management (CRUD operations)
- Order management with real-time SMS notifications
- OpenID Connect Authentication
- REST API endpoints
- Automated testing with high coverage
- CI/CD pipeline integration
- Python 3.x
- Django & Django REST Framework
- DbSqlite
- Africa's Talking SMS Gateway
- OpenID Connect for authentication
- Docker
- GitHub Actions (CI/CD)
- Python 3.x
- DbSqlite
- Docker (optional)
- Africa's Talking Account
- OpenID Connect Provider credentials
- Clone the repository
git clone (Current Repo)[https://github.com/TangoIndiaMango/sa_customer_order]
cd sa_interview_order
- Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
- Install dependencies
pip install -r requirements.txt
- Set up environment variables
cp .env.example .env
- Run migrations
python manage.py migrate
- Start development server
python manage.py runserver
./start.sh
- POST /auth/registration/ - Create User
- POST /auth/login/ - Login User
- GET /api/customers/ - List all customers
- POST /api/customers/ - Create a new customer
- GET /api/customers/{id}/ - Retrieve a customer
- PUT /api/customers/{id}/ - Update a customer
- DELETE /api/customers/{id}/ - Delete a customer
- GET /api/orders/ - List all orders
- POST /api/orders/ - Create a new order
- GET /api/orders/{id}/ - Retrieve an order
- PUT /api/orders/{id}/ - Update an order
- DELETE /api/orders/{id}/ - Delete an order
This API uses OpenID Connect for authentication. To access protected endpoints:
Obtain an access token from the authentication endpoint Include the token in the Authorization header: plaintext
Authorization: Bearer SMS Notifications The system automatically sends SMS notifications to customers when new orders are created using Africa's Talking SMS gateway.
Testing Run the test suite:
python manage.py test
This project uses GitHub Actions for CI/CD. The pipeline:
Runs tests Checks code coverage Performs linting Deploys to production on successful merge to main branch
docker build -t customer-order-service .
- Docker
docker build -t your-registry/customer-order-service:latest .
docker push your-registry/customer-order-service:latest