# 🎬 NextWatch Backend
<div align="center">
[](https://www.djangoproject.com/)
[](https://python.org)
[](https://postgresql.org)
[](https://jwt.io)
*Django backend for the NextWatch project that serves as a proxy to the TMDB API while handling user authentication and features like watchlists and ratings.*
</div>
---
## ✨ Features
- 🔐 **User Authentication** - Secure JWT token-based authentication
- 🎭 **TMDB API Proxy** - Cached proxy for The Movie Database API
- 📺 **User Watchlists** - Personal content tracking and management
- ⭐ **Ratings & Reviews** - User-generated content ratings and reviews
- 🔍 **Content Discovery** - Advanced search and discovery features
---
## 🚀 Quick Start
### 📋 Prerequisites
- Python 3.8+
- pip package manager
### 🛠️ Installation
**1. Create and activate virtual environment:**
```bash
# Create virtual environment
python -m venv venv
# Activate (Linux/Mac)
source venv/bin/activate
# Activate (Windows)
venv\Scripts\activate
2. Install dependencies:
pip install -r requirements.txt
3. Environment setup:
cp .env.sample .env
4. Run database migrations:
python manage.py migrate
5. Start the development server:
python manage.py runserver
Copy the sample environment file and configure your settings:
cp .env.sample .env
# 🔑 Django Core Settings
SECRET_KEY=your-secret-key-here
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1,0.0.0.0
# 🗄️ Database Configuration
DB_ENGINE=django.db.backends.sqlite3
DB_NAME=db.sqlite3
# For PostgreSQL Production:
# DB_ENGINE=django.db.backends.postgresql
# DB_NAME=nextwatch
# DB_USER=your-db-user
# DB_PASSWORD=your-db-password
# DB_HOST=your-db-host
# DB_PORT=5432
# 🎬 TMDB API Configuration
TMDB_API_KEY=your-tmdb-api-key
TMDB_READ_ACCESS_TOKEN=your-tmdb-read-access-token
# 🌐 CORS Settings
CORS_ALLOW_ALL_ORIGINS=True
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
📌 Production Note: For Render deployment, configure these variables in the
render.yaml
file or Render dashboard.
Method | Endpoint | Description |
---|---|---|
POST |
/api/auth/register/ |
👤 Register new user |
POST |
/api/auth/login/ |
🔑 User login |
POST |
/api/auth/refresh/ |
🔄 Refresh JWT token |
Method | Endpoint | Description |
---|---|---|
GET |
/api/discover/ |
🔍 Discover movies and TV shows |
GET |
/api/search/ |
🔎 Search content |
GET |
/api/trending/ |
📈 Get trending content |
GET |
/api/movies/{id}/ |
🎬 Get movie details |
GET |
/api/tv/{id}/ |
📺 Get TV show details |
Method | Endpoint | Description |
---|---|---|
GET |
/api/watchlist/ |
📋 List user's watchlist |
POST |
/api/watchlist/ |
➕ Add to watchlist |
DELETE |
/api/watchlist/{id}/ |
❌ Remove from watchlist |
GET |
/api/ratings/ |
⭐ List user's ratings |
POST |
/api/ratings/ |
➕ Add rating |
PUT |
/api/ratings/{id}/ |
✏️ Update rating |
DELETE |
/api/ratings/{id}/ |
🗑️ Delete rating |
Step-by-step deployment guide:
-
📂 Repository Setup
- Fork or clone this repository to your GitHub account
-
🔗 Connect to Render
- Sign up for a Render account
- Connect your GitHub account to Render
-
⚡ Create Web Service
- Create a new Web Service and select your repository
- Render will automatically detect the
render.yaml
configuration
-
🔧 Configure Environment Variables Update these variables in the Render dashboard:
TMDB_API_KEY=your-tmdb-api-key TMDB_READ_ACCESS_TOKEN=your-tmdb-read-access-token CORS_ALLOWED_ORIGINS=https://your-frontend-domain.com CSRF_TRUSTED_ORIGINS=https://your-frontend-domain.com
-
🚀 Deploy
- Click deploy and let Render handle the rest!
The render.yaml
configuration automatically handles:
- ✅ PostgreSQL database setup
- ✅ Build and start commands
- ✅ Environment variable configuration
For custom deployment environments:
- Set
DEBUG=False
in production - Configure proper
ALLOWED_HOSTS
- Set up PostgreSQL database
- Configure Redis for caching (optional)
- Set up HTTPS/SSL certificates
- Configure CORS settings for your frontend domain
- Set up proper logging and monitoring
We welcome contributions! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
Built with ❤️ using Django and the TMDB API