0
stars
31
commits
Python
primary language
Jul 3, 2026
updated
A comprehensive FastAPI backend for emotion analysis providing text, audio, and video emotion detection with global deployment capability.
β
Railway Deployment Ready - Optimized for global free deployment
β
Localhost Testing Ready - Flutter integration testing available
β
Clean Codebase - Unused files removed, focused structure
β
ML Models Ready - Real emotion models + lightweight alternatives
# Use the ready-to-deploy package
cd deploy_railway/
# Follow instructions in deploy_railway/README.md
# Start localhost server for Flutter testing
python localhost_test_server.py
# Server runs on http://localhost:8000
# Full development server
python production_server.py
emosense_backend/
βββ π deploy_railway/ # Production deployment (Railway)
β βββ Dockerfile # Optimized container
β βββ requirements_railway.txt
β βββ production_server_railway.py
β βββ api/emotion_models_railway.py
β βββ README.md # Deployment guide
βββ π§ api/ # Core emotion analysis
β βββ emotion_models.py # Full emotion models
β βββ emotion_models_lite.py # Lightweight models
β βββ index.py # API endpoints
βββ π± app/ # FastAPI application
β βββ main.py # Application entry
β βββ api/ # API routes
β βββ models/ # Database models
β βββ services/ # Business logic
βββ π§ͺ tests/ # Test suite
βββ π€ real_models/ # Trained ML models
βββ π localhost_test_server.py # Flutter testing server
βββ π production_server.py # Development server
βββ π requirements.txt # Dependencies
β βββ core/ # Core functionality β β βββ init.py β β βββ security.py # Security utilities β β βββ exceptions.py # Custom exceptions β βββ models/ # Database models β β βββ init.py β β βββ user.py # User model β β βββ emotion.py # Emotion analysis models β βββ schemas/ # Pydantic schemas β β βββ init.py β β βββ user.py # User schemas β β βββ emotion.py # Emotion analysis schemas β βββ services/ # Business logic β β βββ init.py β β βββ health.py # Health check service β β βββ emotion/ # Emotion analysis services β βββ utils/ # Utility functions βββ tests/ # Test files βββ .github/ # GitHub configuration β βββ copilot-instructions.md # Copilot instructions βββ requirements.txt # Python dependencies βββ docker-compose.yml # Docker setup βββ Dockerfile # Docker image βββ .env.example # Environment variables template βββ README.md # This file
## π Quick Start
### Prerequisites
- Python 3.9+
- PostgreSQL 12+
- Redis 6+
- FFmpeg (for audio/video processing)
### Installation
1. **Clone the repository and set up virtual environment:**
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install dependencies:
pip install -r requirements.txt
Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
Set up database:
# Create PostgreSQL database
createdb emosense_db
# Run migrations
alembic upgrade head
Run the application:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f app
# Stop services
docker-compose down
Once the server is running, visit:
POST /api/v1/auth/register - User registrationPOST /api/v1/auth/login - User loginPOST /api/v1/auth/refresh - Refresh access tokenPOST /api/v1/auth/logout - User logoutPOST /api/v1/emotion/text - Analyze text emotionsPOST /api/v1/emotion/video - Analyze video emotionsPOST /api/v1/emotion/audio - Analyze audio emotionsPOST /api/v1/emotion/batch - Batch analysisGET /api/v1/emotion/{analysis_id} - Get analysis resultsGET /api/v1/emotion/ - List user analysesGET /api/v1/analytics/dashboard - Analytics dashboard dataGET /api/v1/analytics/reports - Generate reportsGET /api/v1/analytics/stats - Usage statisticsGET /health - Health checkGET /metrics - System metricsGET /api/v1/system/info - System informationKey environment variables (see .env.example for complete list):
# Application
ENVIRONMENT=development
DEBUG=true
SECRET_KEY=your-super-secret-key
# Database
DATABASE_URL=postgresql+asyncpg://user:password@localhost:5432/emosense_db
# Redis
REDIS_URL=redis://localhost:6379/0
# Security
ACCESS_TOKEN_EXPIRE_MINUTES=30
REFRESH_TOKEN_EXPIRE_DAYS=7
# Install test dependencies
pip install pytest pytest-asyncio pytest-mock
# Run tests
pytest tests/
# Run with coverage
pytest --cov=app tests/
Environment Setup:
# Set production environment variables
export ENVIRONMENT=production
export DEBUG=false
export SECRET_KEY=your-secure-production-key
Database Migration:
alembic upgrade head
Start with Gunicorn:
gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker
# Build production image
docker build -t emosense-backend .
# Run with docker-compose (production profile)
docker-compose --profile production up -d
GET /healthGET /metrics (Prometheus format)This project is licensed under the MIT License - see the LICENSE file for details.
For support, please contact the development team or create an issue in the repository.
Built with β€οΈ using FastAPI and modern Python technologies.
31 commits
Python
99.5%
0
stars
31
commits
Python
primary language
Jul 3, 2026
updated
A comprehensive FastAPI backend for emotion analysis providing text, audio, and video emotion detection with global deployment capability.
β
Railway Deployment Ready - Optimized for global free deployment
β
Localhost Testing Ready - Flutter integration testing available
β
Clean Codebase - Unused files removed, focused structure
β
ML Models Ready - Real emotion models + lightweight alternatives
# Use the ready-to-deploy package
cd deploy_railway/
# Follow instructions in deploy_railway/README.md
# Start localhost server for Flutter testing
python localhost_test_server.py
# Server runs on http://localhost:8000
# Full development server
python production_server.py
emosense_backend/
βββ π deploy_railway/ # Production deployment (Railway)
β βββ Dockerfile # Optimized container
β βββ requirements_railway.txt
β βββ production_server_railway.py
β βββ api/emotion_models_railway.py
β βββ README.md # Deployment guide
βββ π§ api/ # Core emotion analysis
β βββ emotion_models.py # Full emotion models
β βββ emotion_models_lite.py # Lightweight models
β βββ index.py # API endpoints
βββ π± app/ # FastAPI application
β βββ main.py # Application entry
β βββ api/ # API routes
β βββ models/ # Database models
β βββ services/ # Business logic
βββ π§ͺ tests/ # Test suite
βββ π€ real_models/ # Trained ML models
βββ π localhost_test_server.py # Flutter testing server
βββ π production_server.py # Development server
βββ π requirements.txt # Dependencies
β βββ core/ # Core functionality β β βββ init.py β β βββ security.py # Security utilities β β βββ exceptions.py # Custom exceptions β βββ models/ # Database models β β βββ init.py β β βββ user.py # User model β β βββ emotion.py # Emotion analysis models β βββ schemas/ # Pydantic schemas β β βββ init.py β β βββ user.py # User schemas β β βββ emotion.py # Emotion analysis schemas β βββ services/ # Business logic β β βββ init.py β β βββ health.py # Health check service β β βββ emotion/ # Emotion analysis services β βββ utils/ # Utility functions βββ tests/ # Test files βββ .github/ # GitHub configuration β βββ copilot-instructions.md # Copilot instructions βββ requirements.txt # Python dependencies βββ docker-compose.yml # Docker setup βββ Dockerfile # Docker image βββ .env.example # Environment variables template βββ README.md # This file
## π Quick Start
### Prerequisites
- Python 3.9+
- PostgreSQL 12+
- Redis 6+
- FFmpeg (for audio/video processing)
### Installation
1. **Clone the repository and set up virtual environment:**
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install dependencies:
pip install -r requirements.txt
Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
Set up database:
# Create PostgreSQL database
createdb emosense_db
# Run migrations
alembic upgrade head
Run the application:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f app
# Stop services
docker-compose down
Once the server is running, visit:
POST /api/v1/auth/register - User registrationPOST /api/v1/auth/login - User loginPOST /api/v1/auth/refresh - Refresh access tokenPOST /api/v1/auth/logout - User logoutPOST /api/v1/emotion/text - Analyze text emotionsPOST /api/v1/emotion/video - Analyze video emotionsPOST /api/v1/emotion/audio - Analyze audio emotionsPOST /api/v1/emotion/batch - Batch analysisGET /api/v1/emotion/{analysis_id} - Get analysis resultsGET /api/v1/emotion/ - List user analysesGET /api/v1/analytics/dashboard - Analytics dashboard dataGET /api/v1/analytics/reports - Generate reportsGET /api/v1/analytics/stats - Usage statisticsGET /health - Health checkGET /metrics - System metricsGET /api/v1/system/info - System informationKey environment variables (see .env.example for complete list):
# Application
ENVIRONMENT=development
DEBUG=true
SECRET_KEY=your-super-secret-key
# Database
DATABASE_URL=postgresql+asyncpg://user:password@localhost:5432/emosense_db
# Redis
REDIS_URL=redis://localhost:6379/0
# Security
ACCESS_TOKEN_EXPIRE_MINUTES=30
REFRESH_TOKEN_EXPIRE_DAYS=7
# Install test dependencies
pip install pytest pytest-asyncio pytest-mock
# Run tests
pytest tests/
# Run with coverage
pytest --cov=app tests/
Environment Setup:
# Set production environment variables
export ENVIRONMENT=production
export DEBUG=false
export SECRET_KEY=your-secure-production-key
Database Migration:
alembic upgrade head
Start with Gunicorn:
gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker
# Build production image
docker build -t emosense-backend .
# Run with docker-compose (production profile)
docker-compose --profile production up -d
GET /healthGET /metrics (Prometheus format)This project is licensed under the MIT License - see the LICENSE file for details.
For support, please contact the development team or create an issue in the repository.
Built with β€οΈ using FastAPI and modern Python technologies.
31 commits
Python
99.5%