Git Product home page Git Product logo

directory's Introduction

Contact Management System

This is a simple Django application for managing contacts. It provides APIs for creating, reading, updating, and deleting contacts. Additionally, it supports searching contacts by name and phone number and exporting the contact list via email.

API Endpoints

List Contacts: GET api/v1/directory

Create Contact: POST api/v1/directory

Retrieve Contact: GET api/v1/directory/id

Update Contact: PUT api/v1/directory/id/ or PATCH api/v1/directory/id

Delete Contact: DELETE api/v1/directory/id

Search Contacts: GET api/v1/directory/search/?name=&phone_number=<phone_number>

Export Contacts: GET api/v1/directory/export

Build the project by docker image

version: '3.9'
services:
  dev-db:
    image: postgres:13
    ports:
      - 5434:5432
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: 1234
      POSTGRES_DB: Django

  web:
    image: zakilu/directory-web:latest
    command: sh -c "python3 manage.py migrate & celery -A directory worker -l info & gunicorn directory.wsgi:application --bind 0.0.0.0:8000"
    ports:
      - "8000:8000"
    depends_on:
      - redis
      - dev-db
    restart: always

  redis:
    image: redis:latest
    ports:
      - "6379:6379"
docker compose up -d

example:

curl -X POST \
  http://35.72.177.254/api/v1/directory/ \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "John Doe",
    "email": "[email protected]",
    "phone_number": "1234567890"
}'

Celery Configuration

# Celery
BROKER_URL = 'redis://redis:6379'
CELERY_RESULT_BACKEND = 'redis://redis:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = 'Asia/Taipei'
# Email
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD')

Deployment (CI/CD) Workflow

  1. Test Description: This job runs tests on the application code. Runs on: Ubuntu latest Steps: Checkout code Set up Python environment Set up Docker Buildx Install dependencies Build docker container for testing Run tests

  2. Build and Upload Docker Image to Docker Hub Description: This job builds the Docker image for the application and uploads it to Docker Hub. Runs on: Ubuntu latest Needs: Test job Steps: Checkout repository Set up Docker Buildx Login to Docker Hub Build and push Docker image to Docker Hub

  3. Deploy on EC2 Description: This job deploys the application to an EC2 instance after merging changes into the develop branch. Runs on: Ubuntu latest Needs: Build and Upload Docker Image to Docker Hub job Steps: Deploy to EC2 using SSH Connects to the EC2 instance Pulls the latest Docker image from Docker Hub Starts the Docker containers on the EC2 instance

directory's People

Contributors

marvelshan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.