Skip to content

blandevv/contact-flow-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contact Flow API

Python FastAPI MySQL JWT Docker OAuth2

API for managing contacts, enabling users to authenticate and perform CRUD operations on their contact list.

Table of Contents

Features

  • User Authentication: Users can register, login and obtain a JWT token to authenticate themselves.
  • CRUD Operations: Users can create, read, update and delete contacts.
  • Security: The API uses JWT for authentication and OAuth2 for authorization.
  • Dockerized: The API is containerized using Docker.
  • API Documentation: The API is documented using Swagger UI.

Prerequisites

Setup

  1. Clone the repository:
git clone https://github.com/blandoncj/ContactFlow-API.git 
  1. Change directory:
cd ContactFlow-API
  1. Create a .env file in the root directory and add the following environment variables:
API_KEY=your_api_key
SECRET_KEY=your_secret_key
MYSQL_USER=your_mysql_user
MYSQL_PASSWORD=your_mysql_password
MYSQL_ROOT_PASSWORD=your_mysql_root_password
MYSQL_HOST=your_mysql_host # docker-compose service hostname (e.g contact_flow)
MYSQL_PORT=your_mysql_port # docker-compose service port (e.g 3306)
MYSQL_DATABASE=your_mysql_database
  1. Build and run the Docker containers:
docker-compose build
docker-compose up -d

Note

The API will be available at http://localhost:8000/docs and the database will be available at http://localhost:8080 (adminer).

  1. Create the database tables:
CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    fullname VARCHAR(50) NOT NULL,
    username VARCHAR(15) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    is_active BOOLEAN DEFAULT TRUE
);

CREATE TABLE contacts (
    id INT AUTO_INCREMENT PRIMARY KEY,
    firstname VARCHAR(50) NOT NULL,
    lastname VARCHAR(50),
    email VARCHAR(50),
    is_favorite BOOLEAN DEFAULT FALSE,
    user_id INT NOT NULL,
    FOREIGN KEY (user_id) REFERENCES users(id)
);

CREATE TABLE phones (
  id INT AUTO_INCREMENT PRIMARY KEY,
  number VARCHAR(20) NOT NULL,
  contact_id INT NOT NULL,
  FOREIGN KEY (contact_id) REFERENCES contacts(id)
)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Made with ❤️ by blandoncj

Contributing

Contributions are welcome. Please open a issue or create a pull request to contribute.

About

FastAPI-based contact management system with JWT/OAuth2 security, MySQL database, and Docker deployment. Implements user authentication and full CRUD functionality.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors