Skip to content

Kostiantyn78/ImageHub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImageHub

ImageHub


ImageHub is a REST API application implemented using the FastAPI framework. It allows users to upload, manage, and share photos, and interact through comments.


Table of Contents


Technologies

Module Description
FastAPI Framework
Pydantic Validation library
SQLAlchemy ORM
Alembic Migration tool
PostgreSQL Database
Cloudinary Image hosting
Passlib Password hashing
Qrcode QR code generator
Pillow Image processing

Basic functionality

Authentication

Endpoints:

POST /api/auth/signup
POST /api/auth/login
GET /api/auth/refresh_token
GET /api/auth/confirmed_email/{token}
POST /api/auth/request_email

The application uses JWT tokens for authentication. Users have three roles: regular user, moderator, and administrator.

To implement different access levels (regular user, moderator, and administrator), FastAPI decorators are used to check the token and user role.

Working with photos

Users can perform various operations related to photos:

  • Upload photos with descriptions.

    POST /api/images/upload_image
    
  • Delete photos.

    DELETE /api/images/{picture_id}
    
  • Edit photo descriptions.

    PATCH /api/images/{picture_id}
    
  • Retrieve a photo by a unique link.

    GET /api/images/{picture_id}
    
  • Add up to 5 tags per photo.

  • Apply basic photo transformations using Cloudinary services. POST /api/transform/create_transform/{natural_photo_id}

  • Generate links to transformed images for viewing as URL and QR-code. Links are stored on the server.

With the help of FastAPI decorators, described above, administrators can perform all CRUD operations with user photos.

Comments

Under each photo, there is a comment section. Users can:

  • Add and read comments to each other's photos.
    POST /api/comments/{image_id}
    
    GET /api/comments/all/{image_id}
    
  • Edit comment.
    PATCH /api/comments/{comment_id}
    
  • Administrators and moderators if you have the role can delete comments.
    DELETE /api/comments/{comment_id}
    

Profile

Endpoints for user profile:

  • See your profile.

    GET /api/users/me
    
  • Change your avatar.

    PATCH /api/users/avatar
    
  • See another user's profile.

    GET /api/users/{username}
    
  • Create a route for a user profile based on their unique username. It returns all user information, including name, registration date, and the number of uploaded photos.


Usage

Installation

  • Clone the repository.
  git clone https://github.com/Kostiantyn78/ImageHub.git
  • Install dependencies.

using poetry

  poetry install
  • Setup the ".env" file.
  cp .env.example .env

_and fill in the information you need, run the docker container and create the database if use Postgres _

  • Run the application.
  uvicorn main:app --reload
  • Enjoy using application via link in the terminal.

Additional information


License

This project is distributed under the MIT license.


Authors

The PyCrafters Team:


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages