customer-orders-service

Dockerized Flask application for managing customer orders with authentication via Google OAuth and SMS notifications using Africa's Talking API

BSD-3-CLAUSE License

Stars
0
Committers
2

Customer-Orders Service

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.

Table of Contents

  1. Process Flow
  2. Setup
  3. Running the Application
  4. API Endpoints

Process Flow

Setup

  1. To run the application locally using Docker, ensure you have the following installed:

    • Python
    • Docker
  2. Clone the repository:

    git clone https://github.com/Sheila-nk/customer-orders-service.git
    cd customer-orders-service
    
  3. Create a .env file:

    touch .env
    
  4. 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
    
  5. Build and run the Docker container:

    docker-compose up --build
    

Running the Application

After setting up your environment and starting the Docker container, the application will be available at http://localhost:8000.

API Endpoints

Authentication Endpoints

  • 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.

Order Management Endpoints

  • 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 🚀