Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Community with Sentiment Analysis and Image Moderation – Backend

This repository contains the FastAPI backend for the project Community with Sentiment Analysis and Image Moderation. The backend provides APIs for text sentiment analysis and image moderation, stores results in MongoDB, and uploads moderated images to Cloudinary.


Features


Tech Stack

  • FastAPI
  • httpx (async HTTP client)
  • MongoDB (pymongo)
  • Cloudinary
  • python-dotenv

Project Structure

.
├── main.py
├── .env
├── requirements.txt
└── README.md

Installation

Clone the repository:

git clone <repository-url>
cd <repository-name>

Create a virtual environment:

python -m venv venv
source venv/bin/activate

Install dependencies:

pip install -r requirements.txt

Running the Server

uvicorn main:app --reload

Server will run at:

http://127.0.0.1:8000

API Endpoints

Sentiment Analysis

Endpoint

POST /sentiment

Request Body

{
  "text": "I love this community"
}

Response

{
  "predicted_emotion": "positive"
}

Data is stored in the texts collection with a timestamp.


Image Moderation

Endpoint

POST /image-moderate

Form Data

file: image

Response

{
  "cloudinary_url": "https://res.cloudinary.com/..."
}

The moderated image is uploaded to Cloudinary and the URL is stored in the images collection.


Database Collections

texts

  • text
  • sentiment
  • full API response
  • created_at

images

  • cloudinary_url
  • created_at

Notes

  • External APIs must be reachable and return valid responses.
  • Cloudinary uploads use the moderated image response.
  • Async HTTP client improves performance under load.

License

For educational and academic use.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages