Skip to content

(Backend) E-Mail Project In REST API using GMAIL API, Flask, SQLAlchemy, SQLite, Docker

Notifications You must be signed in to change notification settings

shakil1819/E-Mail-Register---REST-API-Implementation

Repository files navigation

E-Mail Project In REST API using GMAIL API, Flask, SQLAlchemy, SQLite, Docker

Tree of Directory

.
├── app.py
├── blocklist.py
├── client_secret.json
├── db.py
├── docker-compose.yml
├── Dockerfile
├── Google.py
├── instance
│   └── data.db
├── migrations
├── models
│   ├── __init__.py
│   └── user.py
├── README.md
├── requirements.txt
├── resources
│   └── user.py
├── schemas.py
├── settings.py
├── tasks.py
├── templates
│   └── email
│       ├── action.html
│       └── action.original.html
└── token_gmail_v1.pickle

Description

This project demonstrates a simple REST API for user registration with email verification using the Gmail API. The application is built with Flask, SQLAlchemy, SQLite, and Docker.

Endpoints

  • POST /register: Register a new user and send a welcome email.
  • GET /user: Get a list of all users.
  • DELETE /deleteall: Delete all users from the database.

Prerequisites

  • Docker
  • Docker Compose

Installation & Run

  1. Clone the repository:

    https://github.com/shakil1819/E-Mail-Register---REST-API-Implementation.git
  2. Navigate to the project directory:

  3. Build and run the Docker containers:

    docker-compose up --build

    Screencast from 2024-03-25 09-42-51

Configuration

Create a .env file in the project root and add the following:

REDIS_URL=redis://redis:6379/0

Usage

Register a User

To register a user, make a POST request to /register with the following JSON payload:

{
    "username": "john_doe",
    "email": "john.doe@example.com",
    "password": "password123"
}

Get All Users

To get a list of all users, make a GET request to /user.

Delete All Users

To delete all users from the database, make a DELETE request to /deleteall. Screencast from 2024-03-25 10-03-47

Gmail API Setup

  1. Enable the Gmail API and download the client_secret.json.
  2. Place the client_secret.json in the project root directory.

Additional Notes

  • The email templates can be found in the templates/email directory.
  • The Gmail token is stored in token_gmail_v1.pickle.

To Do's:

---After Meeting on Apr 1, 2024, 10:30 ~ 11:00---

  • Run from Locally installed redis => commit
  • Production server (alternative of flask,use gunicorn) => commit
  • run rq locally, update task management accordingly => commit
  • invalid email error endpoint solve (write endpoint by yourself, if user send invalid mail address, or it is not found, then how it should be identified?) => commit

About

(Backend) E-Mail Project In REST API using GMAIL API, Flask, SQLAlchemy, SQLite, Docker

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published