API for managing contacts, enabling users to authenticate and perform CRUD operations on their contact list.
- 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.
- Clone the repository:
git clone https://github.com/blandoncj/ContactFlow-API.git - Change directory:
cd ContactFlow-API- Create a
.envfile 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- Build and run the Docker containers:
docker-compose build
docker-compose up -dNote
The API will be available at http://localhost:8000/docs and the database will be available at http://localhost:8080 (adminer).
- 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)
)This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by blandoncj
Contributions are welcome. Please open a issue or create a pull request to contribute.