Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ‹οΈ GRIND - Sports Social Platform

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.


🎯 What is GRIND?

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)

✨ Key Features

🏠 Home Timeline

  • 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

πŸ‘€ User Profiles

  • Profile stats (followers, following, posts count)
  • Follow/Unfollow buttons
  • Direct message button
  • User activity timeline

πŸ’¬ Messaging System

  • One-on-one conversations
  • Filtered by followed users
  • Direct messaging from any profile
  • Unread message badges
  • Real-time conversation threads

πŸ”” Notifications & Discovery

  • Activity notifications
  • Trending hashtags
  • Bookmarked posts
  • Tweet replies and threads

🎨 UI/UX Excellence

  • βœ… 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

πŸ—„οΈ Database & Backend

  • βœ… PostgreSQL (production-ready)
  • βœ… Redis caching
  • βœ… Django ORM with proper indexing
  • βœ… Signals for auto-profile creation
  • βœ… 30+ API endpoints (DRF)
  • βœ… JWT Authentication
  • βœ… Fine-grained permissions

⚽ Real Sports Data

  • 6 real athletes: Messi, Ronaldo, MbappΓ©, Haaland, Neymar, Benzema
  • 10+ authentic sports posts
  • 40+ real interactions
  • Hashtag tracking and trending

πŸ§ͺ Quality Assurance

  • βœ… Comprehensive test suite
  • βœ… 100% passing tests
  • βœ… Functional testing
  • βœ… Security-focused

πŸš€ Quick Start (5 minutes)

Prerequisites

βœ“ Docker & Docker Compose
βœ“ Python 3.8+
βœ“ Git

Installation

# 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 runserver

Open http://localhost:8000 πŸŽ‰

Demo Credentials

Username: messi    Password: messi123
Username: ronaldo  Password: ronaldo123
Username: neymar   Password: neymar123

πŸ“ Accessing the Application

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

πŸ—‚οΈ Project Structure

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

🎯 Core Pages & Routes

Timeline (/)

  • 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)

Profile (/profile/<username>/)

  • User info: name, handle, bio, location, join date
  • Stats: followers, following, posts count
  • Follow/Unfollow button
  • Message button for DMs
  • User's posts timeline

Messaging (/messages/)

  • Inbox: conversations with followed users
  • Unread badges
  • Last message preview
  • Sorted by recency

Message Thread (/messages/<username>/)

  • One-on-one chat
  • Sender/receiver distinction
  • Real-time message sending
  • Auto-mark as read

New Conversation (/messages/new/)

  • List of followed users
  • Search filter
  • Click to start DM

Tweet Detail (/tweets/<id>/)

  • Full post content
  • Reply section
  • All actions (like, retweet, bookmark)

Notifications (/notifications/)

  • Activity from followed users
  • Unread count
  • Auto-mark as read

Trending (/trending/)

  • Top hashtags by usage
  • Real-time trending data

Bookmarks (/bookmarks/)

  • Saved posts
  • Personal collection

πŸ”Œ API Endpoints (30+)

Timeline & Posts

GET    /api/tweets/                    # List all tweets
POST   /api/tweets/                    # Create tweet (auth)
GET    /api/tweets/{id}/               # Tweet detail
DELETE /api/tweets/{id}/               # Delete (author)

Interactions

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

Follows & Relationships

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

Messaging

GET    /api/messages/                  # List conversations
POST   /api/messages/                  # Create message
GET    /api/messages/{username}/       # Get thread

Discovery

GET    /api/hashtags/                  # List hashtags
GET    /api/hashtags/{name}/           # Hashtag detail
GET    /api/notifications/             # Get notifications

Authentication

POST   /api/auth/token/                # Get JWT token
POST   /api/auth/token/refresh/        # Refresh token

πŸ—„οΈ Database Models

Core Models

  • 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

Key Indexes

-- 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)

πŸ” Security Features

  • βœ… 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

🐳 Docker Setup

PostgreSQL

Image: postgres:15-alpine
Port: 5432
Database: qa_platform
User: qa_user
Volume: postgres_data (persistent)

Redis

Image: redis:7-alpine
Port: 6379
Volume: redis_data (persistent)

Commands

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)

πŸ“Š Tech Stack

Backend

  • 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

Frontend

  • HTML5 - Semantic markup
  • Tailwind CSS 3.4 - Styling (CDN)
  • FontAwesome 6.4 - Icons (CDN)
  • Vanilla JavaScript - No build step

DevOps & Testing

  • Docker & Docker Compose - Containerization
  • Git - Version control
  • Python unittest - Testing framework
  • Pytest - Advanced testing (optional)

πŸ§ͺ Testing

Run All Tests

python manage.py test -v 2

Run Specific Test

python manage.py test core.tests.TimelineViewTests

Run with Coverage

coverage run --source='.' manage.py test
coverage report
coverage html  # Generate HTML report

Test Categories

  • βœ… Model tests (ORM, validation)
  • βœ… View tests (templates, context)
  • βœ… API tests (DRF endpoints, auth)
  • βœ… Functional tests (user workflows)
  • βœ… Security tests (permissions)

πŸš€ Deployment

Production Checklist

β–‘ 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

Deployment Options

  • 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)

Production Settings

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 = {...}

πŸ“š Documentation

Document Purpose
README.md Project overview & quick start (this file)
GETTING_STARTED.md Detailed setup & troubleshooting
ARCHITECTURE.md Technical deep dive & design decisions

External Resources


πŸŽ“ Learning Goals (IIM Formation)

This project demonstrates:

βœ… Django Fundamentals

  • Project structure & apps architecture
  • Models, views, URLs (MVT pattern)
  • Django ORM & migrations
  • Admin interface
  • Middleware & signals

βœ… API Development

  • Django REST Framework setup
  • Serializers & viewsets
  • Permissions & authentication
  • Browsable API
  • Token auth (JWT)

βœ… Frontend Integration

  • Template rendering
  • AJAX requests (fetch API)
  • Form handling & validation
  • Responsive design (Tailwind)
  • Real-time updates

βœ… Database Design

  • Model relationships (FK, M2M)
  • Indexing & optimization
  • Query optimization (select_related, prefetch_related)
  • Data integrity with signals
  • PostgreSQL features

βœ… Authentication & Security

  • User authentication
  • Permissions & access control
  • CSRF protection
  • XSS prevention
  • SQL injection safety
  • Password hashing

βœ… Testing & Quality

  • Unit tests
  • Integration tests
  • Test fixtures
  • Test organization
  • Coverage analysis

βœ… Deployment & DevOps

  • Docker containerization
  • Environment configuration
  • Production settings
  • Security hardening
  • CI/CD readiness

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Write tests for new features
  5. Commit with clear messages
  6. Push to your fork
  7. Submit a pull request

Code Style

  • Follow PEP 8
  • Use type hints where helpful
  • Write descriptive commit messages
  • Add docstrings to functions

πŸ“„ License

MIT License - See LICENSE file for details


πŸ“ž Support

  • πŸ“– Check GETTING_STARTED.md for setup issues
  • πŸ—οΈ See ARCHITECTURE.md for technical details
  • πŸ› Create an issue for bugs
  • πŸ’‘ Suggest features via discussions

πŸŽ‰ Summary

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages