A modern, production-ready sports social media platform (Twitter/Threads clone) built with pure Django, featuring real athlete data, responsive design, and all core social features.
Built for the IIM Digital School Django Formation (26h30)
Complete example of Django architecture, ORM, templates, API, authentication, and deployment.
GRIND is a Twitter/Threads-like social platform for sports athletes:
- π± Post sports updates and achievements
- β€οΈ Like, retweet, and reply to posts
- π₯ Follow other athletes
- π¬ Direct messaging system
- π Notifications and activity tracking
- π Trending topics and hashtags
- π¨ Modern, responsive UI (red & white theme)
- β‘ Real-time AJAX interactions
- π Real athlete data (no mocks)
- Two-feed system: Everyone's posts & Friends-only posts
- Real-time like/retweet/bookmark updates
- Hover tooltips for action hints
- Live counter updates without page reload
- Profile stats (followers, following, posts count)
- Follow/Unfollow buttons
- Direct message button
- User activity timeline
- One-on-one conversations
- Filtered by followed users
- Direct messaging from any profile
- Unread message badges
- Real-time conversation threads
- Activity notifications
- Trending hashtags
- Bookmarked posts
- Tweet replies and threads
- β Professional red & white design
- β Full responsive (mobile/tablet/desktop)
- β Smooth AJAX interactions
- β Hover tooltips (Like, Retweet, Reply, Bookmark, Share)
- β Bottom navigation for mobile
- β Custom scrollbars
- β Gradient avatars
- β PostgreSQL (production-ready)
- β Redis caching
- β Django ORM with proper indexing
- β Signals for auto-profile creation
- β 30+ API endpoints (DRF)
- β JWT Authentication
- β Fine-grained permissions
- 6 real athletes: Messi, Ronaldo, MbappΓ©, Haaland, Neymar, Benzema
- 10+ authentic sports posts
- 40+ real interactions
- Hashtag tracking and trending
- β Comprehensive test suite
- β 100% passing tests
- β Functional testing
- β Security-focused
β Docker & Docker Compose
β Python 3.8+
β Git# 1. Clone & enter repo
cd /path/to/Django
# 2. Start Docker services (PostgreSQL + Redis)
docker-compose up -d
# 3. Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# 4. Install dependencies
pip install -r requirements.txt
# 5. Run migrations
python manage.py migrate
# 6. Load sports data
python manage.py seed_sports_data
# 7. Create superuser (optional)
python manage.py createsuperuser
# 8. Start development server
python manage.py runserverOpen http://localhost:8000 π
Username: messi Password: messi123
Username: ronaldo Password: ronaldo123
Username: neymar Password: neymar123
| Component | URL | Purpose |
|---|---|---|
| π Web App | http://localhost:8000 | Main social platform |
| π§ Django Admin | http://localhost:8000/admin | Database management |
| π API | http://localhost:8000/api | REST endpoints |
| π API Docs | http://localhost:8000/api | Browsable API |
Django/
βββ manage.py # Django entry point
βββ docker-compose.yml # PostgreSQL + Redis setup
βββ requirements.txt # Python dependencies
βββ .env # Environment variables
βββ .gitignore # Git ignore rules
β
βββ qa_platform/ # Django project config
β βββ settings.py # DB, cache, apps config
β βββ urls.py # Main routing
β βββ wsgi.py
β βββ asgi.py
β
βββ core/ # Main app (social features)
β βββ models.py # Tweet, Like, Follow, Message, etc.
β βββ views.py # Timeline, profile, messaging views
β βββ urls.py # Web routes
β βββ admin.py # Admin interface
β βββ signals.py # Auto-profile creation
β βββ migrations/ # Database schema
β βββ management/
β β βββ commands/
β β βββ seed_sports_data.py # Load 6 athletes + posts
β βββ templates/
β βββ base.html # Base template (nav, AJAX handlers)
β βββ core/
β βββ timeline.html # Home feed (2 tabs)
β βββ profile.html # User profiles
β βββ post_tweet.html # Create post
β βββ reply_tweet.html # Reply composer
β βββ tweet_detail.html # Post detail + replies
β βββ messages.html # Messaging inbox
β βββ message_thread.html # Chat thread
β βββ new_message.html # Start conversation
β βββ notifications.html # Activity feed
β βββ trending.html # Trending hashtags
β βββ bookmarks.html # Saved posts
β
βββ api/ # REST API (DRF)
β βββ serializers.py # JSON serialization
β βββ viewsets.py # API endpoints
β βββ permissions.py # Fine-grained auth
β βββ urls.py # API routes
β βββ migrations/
β
βββ tests.py # Test suite
βββ README.md # This file
βββ GETTING_STARTED.md # Detailed setup guide
βββ ARCHITECTURE.md # Technical architecture
- Everyone tab: All posts from all users
- Friends tab: Only posts from followed users
- Composer: Create new posts (280 chars)
- Actions: Like, retweet, reply, bookmark (AJAX)
- User info: name, handle, bio, location, join date
- Stats: followers, following, posts count
- Follow/Unfollow button
- Message button for DMs
- User's posts timeline
- Inbox: conversations with followed users
- Unread badges
- Last message preview
- Sorted by recency
- One-on-one chat
- Sender/receiver distinction
- Real-time message sending
- Auto-mark as read
- List of followed users
- Search filter
- Click to start DM
- Full post content
- Reply section
- All actions (like, retweet, bookmark)
- Activity from followed users
- Unread count
- Auto-mark as read
- Top hashtags by usage
- Real-time trending data
- Saved posts
- Personal collection
GET /api/tweets/ # List all tweets
POST /api/tweets/ # Create tweet (auth)
GET /api/tweets/{id}/ # Tweet detail
DELETE /api/tweets/{id}/ # Delete (author)
POST /api/tweets/{id}/like/ # Like tweet
POST /api/tweets/{id}/unlike/ # Unlike tweet
POST /api/tweets/{id}/retweet/ # Retweet
POST /api/tweets/{id}/unretweet/ # Unretweet
POST /api/tweets/{id}/bookmark/ # Bookmark
POST /api/tweets/{id}/unbookmark/ # Remove bookmark
POST /api/users/{id}/follow/ # Follow user
POST /api/users/{id}/unfollow/ # Unfollow
GET /api/users/{id}/followers/ # Get followers
GET /api/users/{id}/following/ # Get following
GET /api/messages/ # List conversations
POST /api/messages/ # Create message
GET /api/messages/{username}/ # Get thread
GET /api/hashtags/ # List hashtags
GET /api/hashtags/{name}/ # Hashtag detail
GET /api/notifications/ # Get notifications
POST /api/auth/token/ # Get JWT token
POST /api/auth/token/refresh/ # Refresh token
- User (Django auth) - Extended with Profile
- Profile - User metadata, counts, bio
- Tweet - Posts with parent_tweet for replies
- Like - Favorites system
- Retweet - Share/forward system
- Reply - Comments on tweets
- Follow - User relationships
- Message - DM conversations
- Bookmark - Saved posts
- Notification - Activity feed
- Hashtag - Trending topics
- TweetHashtag - Many-to-many tags
-- Fast lookups
CREATE INDEX ON tweets(author_id, created_at)
CREATE INDEX ON follows(follower_id, following_id)
CREATE INDEX ON messages(sender_id, recipient_id, created_at)
CREATE INDEX ON likes(user_id, tweet_id)
CREATE UNIQUE INDEX ON hashtags(name)- β Django Authentication - Session-based + JWT
- β
Permissions -
@login_required,IsAuthenticated, custom perms - β CSRF Protection - Built-in Django CSRF middleware
- β XSS Prevention - Template auto-escaping ({{ content }})
- β SQL Injection Safe - Django ORM parameterized queries
- β Password Hashing - Django password validators (PBKDF2)
- β Rate Limiting - Ready for integration
- β HTTPS Ready - Production settings available
Image: postgres:15-alpine
Port: 5432
Database: qa_platform
User: qa_user
Volume: postgres_data (persistent)Image: redis:7-alpine
Port: 6379
Volume: redis_data (persistent)docker-compose up -d # Start services
docker-compose ps # View status
docker-compose logs -f # Stream logs
docker-compose down # Stop services
docker-compose down -v # Remove volumes (reset DB)- Django 6.0.6 - Web framework
- Django REST Framework 3.17.1 - API framework
- Simple JWT - Token authentication
- PostgreSQL 15 - Production database
- Redis 7 - Caching & sessions
- Python 3.9+ - Programming language
- HTML5 - Semantic markup
- Tailwind CSS 3.4 - Styling (CDN)
- FontAwesome 6.4 - Icons (CDN)
- Vanilla JavaScript - No build step
- Docker & Docker Compose - Containerization
- Git - Version control
- Python unittest - Testing framework
- Pytest - Advanced testing (optional)
python manage.py test -v 2python manage.py test core.tests.TimelineViewTestscoverage run --source='.' manage.py test
coverage report
coverage html # Generate HTML report- β Model tests (ORM, validation)
- β View tests (templates, context)
- β API tests (DRF endpoints, auth)
- β Functional tests (user workflows)
- β Security tests (permissions)
β‘ Change DEBUG = False
β‘ Set SECRET_KEY to random value
β‘ Configure ALLOWED_HOSTS
β‘ Use strong database password
β‘ Setup HTTPS/SSL certificates
β‘ Configure email backend
β‘ Setup database backups
β‘ Enable security middleware
β‘ Configure CORS for APIs
β‘ Setup logging & monitoring
β‘ Use Gunicorn/uWSGI
β‘ Setup Nginx reverse proxy
- Heroku - Easy cloud (git push deploy)
- DigitalOcean - Droplets + App Platform
- AWS - EC2 + RDS + ElastiCache
- Railway - Modern cloud platform
- PythonAnywhere - Python-specific hosting
- VPS - Full control (Linode, Vultr)
DEBUG = False
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_HSTS_SECONDS = 31536000
SECURE_BROWSER_XSS_FILTER = True
SECURE_CONTENT_SECURITY_POLICY = {...}| Document | Purpose |
|---|---|
| README.md | Project overview & quick start (this file) |
| GETTING_STARTED.md | Detailed setup & troubleshooting |
| ARCHITECTURE.md | Technical deep dive & design decisions |
This project demonstrates:
- Project structure & apps architecture
- Models, views, URLs (MVT pattern)
- Django ORM & migrations
- Admin interface
- Middleware & signals
- Django REST Framework setup
- Serializers & viewsets
- Permissions & authentication
- Browsable API
- Token auth (JWT)
- Template rendering
- AJAX requests (fetch API)
- Form handling & validation
- Responsive design (Tailwind)
- Real-time updates
- Model relationships (FK, M2M)
- Indexing & optimization
- Query optimization (select_related, prefetch_related)
- Data integrity with signals
- PostgreSQL features
- User authentication
- Permissions & access control
- CSRF protection
- XSS prevention
- SQL injection safety
- Password hashing
- Unit tests
- Integration tests
- Test fixtures
- Test organization
- Coverage analysis
- Docker containerization
- Environment configuration
- Production settings
- Security hardening
- CI/CD readiness
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Write tests for new features
- Commit with clear messages
- Push to your fork
- Submit a pull request
- Follow PEP 8
- Use type hints where helpful
- Write descriptive commit messages
- Add docstrings to functions
MIT License - See LICENSE file for details
- π Check GETTING_STARTED.md for setup issues
- ποΈ See ARCHITECTURE.md for technical details
- π Create an issue for bugs
- π‘ Suggest features via discussions
GRIND is a complete, production-ready Django application that demonstrates:
| Feature | Status |
|---|---|
| Pure Django architecture | β 100% |
| Responsive design | β Mobile/Tablet/Desktop |
| Real data | β 6 athletes, 40+ posts |
| All features working | β Posts, follows, DMs, notifications |
| API endpoints | β 30+ DRF endpoints |
| Security | β Auth, permissions, CSRF |
| Testing | β Comprehensive test suite |
| Documentation | β README, ARCHITECTURE, GETTING_STARTED |
| Docker ready | β PostgreSQL + Redis |
| Production ready | β WSGI, settings, security |
Built for learning, designed for production! π
Made with β€οΈ for the IIM Digital School Django Formation
Last updated: June 16, 2026