{"id":25763315,"url":"https://github.com/nexustech101/sentiment-analysis-api","last_synced_at":"2026-05-19T07:32:07.664Z","repository":{"id":279131958,"uuid":"937809551","full_name":"nexustech101/sentiment-analysis-api","owner":"nexustech101","description":"📈 A lightweight FastAPI project for sentiment analysis. It exposes a REST API to analyze text input and categorize sentiments like positive, negative, neutral, and more — with confidence scores. Built with scalability and modularity in mind, this project follows best practices and includes error logging, tests, and clean structure. 🚀","archived":false,"fork":false,"pushed_at":"2025-02-26T17:33:07.000Z","size":67,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-08T10:43:36.516Z","etag":null,"topics":["api","data-pipeline","fastapi","machine-learning","production","sentiment-analysis","sentiment-classification"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nexustech101.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-23T23:38:39.000Z","updated_at":"2025-02-26T17:33:10.000Z","dependencies_parsed_at":"2025-02-24T00:37:14.371Z","dependency_job_id":null,"html_url":"https://github.com/nexustech101/sentiment-analysis-api","commit_stats":null,"previous_names":["nexustech101/sentiment-analysis-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nexustech101/sentiment-analysis-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexustech101%2Fsentiment-analysis-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexustech101%2Fsentiment-analysis-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexustech101%2Fsentiment-analysis-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexustech101%2Fsentiment-analysis-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nexustech101","download_url":"https://codeload.github.com/nexustech101/sentiment-analysis-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexustech101%2Fsentiment-analysis-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33206320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-19T07:16:55.748Z","status":"ssl_error","status_checked_at":"2026-05-19T07:16:54.366Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","data-pipeline","fastapi","machine-learning","production","sentiment-analysis","sentiment-classification"],"created_at":"2025-02-26T20:16:17.957Z","updated_at":"2026-05-19T07:32:07.645Z","avatar_url":"https://github.com/nexustech101.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sentiment Analysis API\n\n## Project Overview\nThis project is a FastAPI-based sentiment analysis API. It provides endpoints for analyzing the sentiment of text inputs and is structured for scalability, modularity, and performance. The API leverages pre-labeled sentiment data and includes efficient caching, error logging, and a well-organized directory structure.\n\n## Features\n- FastAPI framework for high-performance API development\n- Modular architecture for models, routes, and utilities\n- Sentiment analysis using pre-labeled data\n- Efficient caching with `@lru_cache`\n- Structured error handling and logging\n- Pydantic models for request validation and response consistency\n\n## Project Structure\n```\nC:.\n│   .gitignore\n│   error.log                   # Error logging file\n│   main.py                     # Entry point for the FastAPI application\n│   README.md                   # Project documentation\n│   requirements.txt            # Python dependencies\n│   run.sh                      # Shell script to run the API\n│   sentiment_labels.json       # Sentiment data\n│\n├───docs\n│       docs.md                 # Additional project documentation\n│\n├───models\n│       models.py               # Pydantic models for API data validation\n│       __init__.py             # Package initializer\n│\n├───routers\n│       sentiment_route.py      # API route for sentiment analysis\n│       __init__.py             # Package initializer\n│\n├───test\n│       output.json             # Sample test output\n│       sentiment.test.py       # Test cases for sentiment analysis\n│\n└───utils\n        sentiment_utils.py      # Utility functions for sentiment analysis\n        __init__.py             # Package initializer\n```\n\n## API Architectural Diagram\n\n\n```mermaid\nflowchart TB\n    subgraph Client\n        Browser\n        API_Consumer\n    end\n\n    subgraph Backend\n        API_Gateway --\u003e|Rate Limiting \u0026 Logging| Route_Handler\n        Route_Handler --\u003e|Caching Layer| Redis_Cache\n        Route_Handler --\u003e|Session Management| Session_Service\n        Route_Handler --\u003e|Database Access| Database_Service\n        Database_Service --\u003e SQLite3_DB\n    end\n\n    subgraph AI_Pipelines\n        Route_Handler --\u003e|Pipeline Selection| Pipeline_Manager\n        Pipeline_Manager --\u003e Audio_Classification\n        Pipeline_Manager --\u003e Speech_Recognition\n        Pipeline_Manager --\u003e Depth_Estimation\n        Pipeline_Manager --\u003e Text_Classification\n        Pipeline_Manager --\u003e Translation\n        Pipeline_Manager --\u003e Image_Classification\n        Pipeline_Manager --\u003e Object_Detection\n    end\n\n    subgraph Cloud_Infrastructure\n        EC2_Instance\n        S3_Bucket\n    end\n\n    Client --\u003e|API Requests| API_Gateway\n    Backend --\u003e|Deployed on| EC2_Instance\n    SQLite3_DB --\u003e|Backups| S3_Bucket\n```\n\n## Installation\n1. Clone the repository:\n```bash\ngit clone https://github.com/your-repo/sentiment-analysis-api.git\n```\n\n2. Navigate to the project directory:\n```bash\ncd sentiment-analysis\n```\n\n3. Create a virtual environment and activate it:\n```bash\npython -m venv venv\nsource venv/bin/activate  # For Linux/Mac\nvenv\\Scripts\\activate     # For Windows\n```\n\n4. Install dependencies:\n```bash\npip install -r requirements.txt\n```\n\n## Running the API\nFor Windows:\n```bash\nrun.cmd\n```\n\nFor Linux/Mac:\n```bash\nbash run.sh\n```\n\nOr run directly with Python:\n```bash\nuvicorn main:app --reload\n```\n\nAPI will be accessible at: [http://127.0.0.1:8000](http://127.0.0.1:8000)\n\n## API Endpoints\n### `POST /sentiment`\nAnalyzes the sentiment of the provided text.\n\n**Request:**\n\n```json\n{\n  \"prompts\": [\n    \"I'm going to teach a lesson on python best practices.\"\n  ]\n}\n```\n\n**Response example:**\n\n```json\n{\n  \"sentiment\": \"positive\",\n  \"confidence\": 0.98\n}\n```\n##### or\n\n```json\n[\n  {\n    \"sequence\": \"The new AI model has been making waves in the tech industry.\",\n    \"sentiments\": [\n      { \"label\": \"technology\", \"confidence\": 0.831 },\n      { \"label\": \"surprise\", \"confidence\": 0.048 },\n      { \"label\": \"statement\", \"confidence\": 0.034 },\n      { \"label\": \"question\", \"confidence\": 0.029 },\n      { \"label\": \"positive\", \"confidence\": 0.014 },\n      { \"label\": \"command\", \"confidence\": 0.011 },\n      { \"label\": \"business\", \"confidence\": 0.009 },\n      { \"label\": \"joy\", \"confidence\": 0.007 },\n      { \"label\": \"neutral\", \"confidence\": 0.004 },\n      { \"label\": \"negative\", \"confidence\": 0.003 },\n      { \"label\": \"fear\", \"confidence\": 0.002 },\n      { \"label\": \"sports\", \"confidence\": 0.002 },\n      { \"label\": \"anger\", \"confidence\": 0.002 },\n      { \"label\": \"education\", \"confidence\": 0.002 },\n      { \"label\": \"politics\", \"confidence\": 0.001 },\n      { \"label\": \"sadness\", \"confidence\": 0.001 }\n    ]\n  },\n]\n```\n\n## Testing\nRun tests with:\n```bash\npytest test/sentiment.test.py\n```\n\n## Logging\nErrors are logged to `error.log`.\n\n## Contributing\n1. Fork the repo.\n2. Create a new branch.\n3. Commit your changes.\n4. Submit a pull request.\n\n## License\nThis project is licensed under the MIT License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexustech101%2Fsentiment-analysis-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnexustech101%2Fsentiment-analysis-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexustech101%2Fsentiment-analysis-api/lists"}