Getting Started
Relevant source files
The following files were used as context for generating this wiki page:
This guide provides instructions for setting up, running, and understanding the architecture of the "Analisis Sentiment Data Mining" project. The project is an advanced, real-time AI sentiment analysis dashboard for YouTube comments, specifically tailored for analyzing sentiment related to Indonesian football. It features a dual-model architecture to provide both historical and live analysis capabilities.
The system is composed of a Python FastAPI backend that serves the AI/ML models and a Next.js frontend for the interactive dashboard. This document will walk you through the necessary steps to get both components running in a local development environment.
Sources: README.md, dashboard-next/README.md
Architecture Overview
The project utilizes a decoupled frontend and backend architecture. The backend is built with FastAPI and handles all AI/ML processing, while the frontend is a modern Next.js 14 application that provides the user interface and data visualizations. A key feature is the dual-model system which uses a pre-trained SVM model for static, historical data and the Google Gemini AI for live, contextual analysis.
Sources: README.md, dashboard-next/README.md, CHANGELOG.md
System Components
The following diagram illustrates the main components of the system and their interaction.
This diagram shows the flow from the user's browser to the Next.js frontend, which then communicates with the FastAPI backend. The backend selects the appropriate model (SVM or Gemini) based on the request type.
Sources: README.md, dashboard-next/README.md, dashboard-next/DASHBOARD_STRUCTURE.md
Prerequisites
Before you begin, ensure you have the following software installed on your system:
- Python 3.12+
- Node.js 18+
- Git
Sources: CONTRIBUTING.md:105-107
Setup and Installation
The setup process involves configuring both the backend and frontend services.
1. Clone the Repository
First, clone the project repository from GitHub to your local machine.
git clone https://github.com/Fahri-Hilm/Analisis-Sentiment-Data_Mining.git
cd Analisis-Sentiment-Data_Mining
Sources: README.md:50-52, CONTRIBUTING.md:11-14
2. Backend Setup (FastAPI)
The backend is a Python application that serves the sentiment analysis models.
-
Create a Virtual Environment: It is recommended to use a virtual environment to manage Python dependencies.
python -m venv .venv source .venv/bin/activate # On Windows, use: .venv\Scripts\activateSources: CONTRIBUTING.md:115-116
-
Install Dependencies: Install the required Python packages using
pip.pip install -r requirements.txtSources: README.md:56-57, CONTRIBUTING.md:119-120
-
Configure Environment Variables: The backend requires API keys for YouTube and Gemini. Create a
.envfile in the root directory and add your keys.# .env YOUTUBE_API_KEY=your_youtube_api_key GEMINI_API_KEY=your_gemini_api_keySources: README.md:131-134, dashboard-next/app/api/live-comments/route.ts:3
-
Run the Backend Server: Start the FastAPI server.
python run_gemini_api.pyThe API server will be available at
http://localhost:8000.
Sources: README.md:60-61, DEPLOYMENT_SUMMARY.md:63-64
3. Frontend Setup (Next.js)
The frontend is a Next.js application located in the dashboard-next directory.
-
Navigate to the Frontend Directory:
cd dashboard-nextSources: README.md:64
-
Install Dependencies: Install the required Node.js packages using
npm.npm installSources: dashboard-next/README.md:27-28, CONTRIBUTING.md:122-123
-
Configure Environment Variables: Create a
.env.localfile in thedashboard-nextdirectory to specify the backend API URL.# dashboard-next/.env.local NEXT_PUBLIC_API_URL=http://localhost:8000Sources: dashboard-next/DEPLOYMENT_CHECKLIST.md:63-67, dashboard-next/README.md:183-184
-
Run the Frontend Server: Start the Next.js development server.
npm run devThe dashboard will be accessible at
http://localhost:3000.
Sources: dashboard-next/README.md:31-32, CONTRIBUTING.md:129-130
Running the Application
Once both the backend and frontend servers are running, you can access the different parts of the application:
| Service | URL | Description |
|---|---|---|
| Main Dashboard | http://localhost:3000 | Main entry point with overview statistics. |
| Live Comments | http://localhost:3000/live-comments | Real-time YouTube comment analysis. |
| Live Analysis | http://localhost:3000/realtime | Stream monitoring with AI. |
| Backend API Docs | http://localhost:8000/docs | Interactive FastAPI documentation (Swagger UI). |
Sources: README.md:68-73, DEPLOYMENT_SUMMARY.md:68-72
Data Flow for Live Analysis
The following sequence diagram illustrates the process of fetching and analyzing live comments.
This diagram shows the user initiating a request from the frontend, which calls the backend. The backend fetches comments from YouTube, filters them, analyzes sentiment using Gemini AI, and returns the processed data to the frontend for display.
Sources: README.md:138-147, dashboard-next/app/api/live-comments/route.ts, dashboard-next/README.md:88-103
Project Structure
The repository is organized into a backend (root directory) and a frontend (dashboard-next).
/
├── data/ # CSV datasets
├── src/ # Python source code for backend
├── tests/ # Python tests
├── dashboard-next/ # Next.js frontend application
│ ├── app/ # Next.js App Router pages and APIs
│ │ ├── api/ # Frontend API routes
│ │ ├── (pages)/ # UI Pages (Dashboard, Comments, etc.)
│ │ └── layout.tsx
│ ├── components/ # Reusable React components
│ ├── hooks/ # Custom React hooks
│ ├── public/ # Static assets
│ ├── next.config.js # Next.js configuration
│ └── package.json # Frontend dependencies
├── run_gemini_api.py # Script to run the backend server
├── requirements.txt # Python dependencies
└── README.md # Project overview
Sources: dashboard-next/DASHBOARD_STRUCTURE.md:144-165, CONTRIBUTING.md
Deployment
Several options are available for deploying the application to a production environment.
| Method | Description |
|---|---|
| Vercel | Recommended for the Next.js frontend. Provides seamless, Git-integrated deployments. |
| Docker | Containerize the frontend and backend applications for consistent environments and easy scaling. A sample Dockerfile is provided. |
| Traditional Server | Deploy on a virtual or dedicated server. Use a process manager like pm2 to keep the Node.js application running. |
For detailed steps on each method, refer to the deployment checklist.