Skip to content

kishanborad/sentiment-analysis

Repository files navigation

Sentiment Analysis System

A modern sentiment analysis system that combines Morphological Sentence Pattern (MSP) model with Convolutional Neural Networks (CNN) for improved accuracy and efficiency.

Features

  • Real-time sentiment analysis
  • MSP-based text preprocessing
  • CNN-based sentiment classification
  • Part-of-Speech (POS) tagging
  • Batch text processing
  • Modern web interface
  • API documentation with Swagger UI

Tech Stack

Backend

  • Python 3.11+
  • FastAPI
  • TensorFlow
  • NLTK
  • Pydantic v2
  • Uvicorn

Frontend

  • Next.js 14
  • React 19
  • TypeScript
  • Tailwind CSS
  • Shadcn UI
  • Radix UI

Project Structure

sentiment-analysis/
├── backend/
│   ├── api/
│   │   ├── routes/
│   │   │   └── sentiment.py
│   │   └── main.py
│   ├── models/
│   │   └── neural_networks/
│   │       ├── cnn_model.py
│   │       └── msp_model.py
│   ├── services/
│   │   └── sentiment_service.py
│   ├── tests/
│   │   └── conftest.py
│   └── requirements.txt
├── frontend/
│   ├── app/
│   │   ├── page.tsx
│   │   └── layout.tsx
│   ├── components/
│   │   ├── ui/
│   │   └── features/
│   ├── lib/
│   │   └── api/
│   │       └── client.ts
│   └── package.json
└── docs/
    └── api/
        └── README.md

Getting Started

Backend Setup

  1. Create and activate virtual environment:

    cd backend
    python3 -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  2. Install dependencies:

    pip install -r requirements.txt
  3. Start the server:

    uvicorn main:app --reload

The API will be available at http://localhost:8000 with Swagger documentation at http://localhost:8000/docs.

Frontend Setup

  1. Install dependencies:

    cd frontend
    pnpm install
  2. Start the development server:

    pnpm dev

The frontend will be available at http://localhost:3000.

Deployment

Vercel Deployment

This project is configured for deployment on Vercel with the following setup:

  1. Frontend Deployment:

    • The frontend will be automatically deployed as a Next.js application
    • API routes are proxied to the backend
  2. Backend Deployment:

    • The backend is deployed as serverless functions
    • Python 3.11 runtime is used
  3. Environment Variables:

    • Set NEXT_PUBLIC_API_URL to your backend URL in Vercel dashboard
    • Update the backend URL in frontend/next.config.mjs after deployment
  4. Deployment Steps:

    # Install Vercel CLI
    npm i -g vercel
    
    # Deploy to Vercel
    vercel
    
    # Follow the prompts and set up your project
  5. Post-Deployment:

    • Update the backend URL in frontend/next.config.mjs with your actual backend domain
    • Set environment variables in Vercel dashboard
    • Redeploy if necessary

API Endpoints

  • POST /api/analyze - Analyze single text
  • POST /api/batch - Analyze multiple texts
  • GET /health - Health check endpoint

Development

Backend Development

  • Use Python 3.11 or higher
  • Follow PEP 8 style guide
  • Write unit tests for new features
  • Update API documentation

Frontend Development

  • Use TypeScript for type safety
  • Follow component-based architecture
  • Implement responsive design
  • Add error handling

Testing

Backend Tests

cd backend
pytest

Frontend Tests

cd frontend
pnpm test

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

MIT License - see LICENSE file for details

Authors

  • K. Borad

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published