The Customer-Orders Service
is a Flask-based web application that handles user authentication and order management.
The application is containerized using Docker
and deployed on Heroku
. It interacts with a PostgreSQL
database for storing user and order information, authenticates users via Google OAuth, and uses the Africa's Talking API for sending SMS notifications.
-
To run the application locally using Docker, ensure you have the following installed:
- Python
- Docker
-
Clone the repository:
git clone https://github.com/Sheila-nk/customer-orders-service.git cd customer-orders-service
-
Create a .env file:
touch .env
-
Add your environment variables in the
.env
file. It should include the following:SECRET_KEY=your_secret_key SQLALCHEMY_DATABASE_URI=your_database_uri GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret AFRICASTALKING_USERNAME=your_africastalking_username AFRICASTALKING_API_KEY=your_africastalking_api_key
-
Build and run the Docker container:
docker-compose up --build
After setting up your environment and starting the Docker container, the application will be available at http://localhost:8000
.
-
GET /auth/login
: Redirects the user to Google OAuth login.Response: Redirect to Google login page.
-
GET /auth/authorize
: Handles the Google OAuth callback and logs the user in.Response: JSON message indicating login success or error.
-
GET /logout
: Logs the user out.Response: JSON message indicating logout success.
-
POST /add_order
: Add a new order.Request Body:
{ "item_name": "Product Name", "num_of_items": 1, "phonenumber": "+254456789012" }
Response: JSON message indicating order addition success or error.
-
PUT /update_order/<order_id>
: Update an existing order.Request Body:
{ "item_name": "Updated Product Name", "num_of_items": 2 }
Response: JSON message indicating order update success or error.
-
DELETE /delete_order/<order_id>
: Delete an existing order.Response: JSON message indicating order deletion success or error.
Enjoy 🚀