Network - Social Media Platform
A modern, feature-rich social media platform built with Django. I've created Network to provide users with a seamless experience for connecting, sharing, and engaging with their community.
Overview
Network is a production-ready social media platform that enables users to connect, share, and engage with a vibrant community. Built with Django and modern web technologies, it delivers a seamless user experience with real-time interactions, secure authentication, and scalable architecture.
The platform is designed with best practices in mind, featuring clean code architecture, responsive design, and comprehensive user interaction capabilities that rival mainstream social media platforms.
Key Features
π Authentication & Security
- Secure User Registration - Robust validation with password encryption and strength requirements
- Session Management - Secure authentication with Djangoβs battle-tested session framework
- Custom User Model - Extended user model for scalability and future feature additions
- Protected Routes - Authorization middleware ensuring secure access control
- CSRF Protection - Built-in protection against cross-site request forgery attacks
π₯ User Profiles & Identity
- Rich Profile System - Customizable profiles with biography and avatar support
- Profile Discovery - Browse and explore user profiles across the network
- Real-time Updates - Dynamic profile editing with instant feedback
- User Statistics - Track followers, following, and post counts
- Profile Validation - Input sanitization and validation for data integrity
π Social Network Features
- Follow/Unfollow System - Build connections with one-click follow functionality
- Network Analytics - View comprehensive follower and following lists
- Relationship Tracking - Real-time updates on connection status
- AJAX-powered Interactions - Seamless follow/unfollow without page reloads
π Content Management
- Rich Post Creation - Share content with titles and detailed descriptions
- Full CRUD Operations - Create, read, update, and delete posts with ease
- Personalized Feed - Smart feed showing content from followed users
- Global Feed - Discover new content from the entire community
- Content Ownership - Users maintain complete control over their posts
- Timestamp Tracking - Creation and modification timestamps for all content
β€οΈ Real-time Engagement
- Real-time Like System - AJAX-powered instant like/unlike functionality
- Threaded Comments - Engage in discussions with hierarchical comment structure
- Comment Management - Edit and delete comments with full version control
- Interactive UI - Dynamic updates without page refreshes
π¨ User Experience
- Responsive Design - Mobile-first approach ensuring compatibility across all devices
- Intuitive Navigation - Clean, user-friendly interface with logical flow
- Fast Page Loads - Optimized queries and efficient pagination
- Error Handling - Custom 404 pages and graceful error management
- Accessibility - Semantic HTML and ARIA labels for inclusivity
βοΈ Administrative Features
- Comprehensive Admin Panel - Django admin interface for platform management
- User Moderation - Tools for managing users and content
- Analytics Dashboard - Insights into platform usage and engagement
- Content Moderation - Review and manage reported content
- System Configuration - Flexible settings for platform customization
Tech Stack
Backend Framework
- Django 5.2.7 - High-level Python web framework for rapid development
- Django ORM - Powerful database abstraction layer for efficient queries
- Django Admin - Comprehensive admin interface out-of-the-box
- Django Templates - Server-side rendering with template inheritance
Frontend Technologies
- HTML5 - Semantic markup for accessibility and SEO
- CSS3 - Modern styling with flexbox and grid layouts
- JavaScript (Vanilla) - Dynamic interactions and AJAX functionality
- Responsive Design - Mobile-first CSS for all screen sizes
Database
- SQLite - Lightweight, serverless database for data persistence for local development
- MySQL - Scalable relational database for production environments
- Migration System - Version-controlled database schema management
Deployment & Infrastructure
- Render - Modern cloud platform for seamless deployment
- Git - Version control and deployment automation
- WSGI - Production-ready application server interface
Development Tools
- Django Validators - Input validation and data sanitization
- CSRF Middleware - Security against cross-site request forgery
- Session Framework - Secure user session management
Architecture
Network follows Djangoβs MVT (Model-View-Template) architecture pattern with a modular app structure for maintainability and scalability.
Application Structure
βββββββββββββββββββββββββββββββββββββββββββ
β Django Project Layer β
β (network/settings.py) β
ββββββββββββββββ¬βββββββββββββββββββββββββββ
β
βββββββββ΄ββββββββ
β URL Router β
β (urls.py) β
βββββββββ¬ββββββββ
β
ββββββββββββ΄βββββββββββ
β β
βββββΌβββββ ββββββββΌβββββββ
β Views βββββββββββ€ Models β
βββββ¬βββββ ββββββββ¬βββββββ
β β
β ββββββββΌβββββββββββββ
β β Database β
β β (SQLite / MySQL) β
β βββββββββββββββββββββ
β
βββββΌβββββββββ
β Templates β
ββββββββββββββ
Modular App Design
| App | Responsibility |
|---|---|
| authenticate | User registration, login, and session management |
| users | Profile management, follow system, and user interactions |
| feed_and_posts | Post creation, feeds, comments, and engagement |
| core | Landing pages, about, contact, and static content |
| admincontrol | Administrative functionality and moderation |
Local Setup
Prerequisites
Ensure you have the following installed on your system:
Installation
Follow these steps to set up the project locally:
1οΈβ£ Clone the Repository
git clone https://github.com/krsahil8825/Network-social-media-platform.git
cd Network
2οΈβ£ UV Environment Setup
uv sync
3οΈβ£ Configure Environment Variables
Create a .env file in the project root (optional for local development):
SECRET_KEY=dev-only-insecure-secret-key
ENV=development
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
CSRF_TRUSTED_ORIGINS=http://localhost
DB_ENGINE=sqlite
4οΈβ£ Apply Database Migrations
uv run python manage.py makemigrations
uv run python manage.py migrate
5οΈβ£ Create Superuser (Admin Account)
uv run python manage.py createsuperuser
Follow the prompts to create your admin account.
6οΈβ£ Run Development Server
uv run python manage.py runserver
7οΈβ£ Access the Application
- Main Application: http://localhost:8000
- Admin Panel: http://localhost:8000/admin
Project Structure
Network/
β
βββ π authenticate/ # Authentication & Authorization
β βββ views.py # Login, registration, logout views
β βββ urls.py # Authentication routes
β βββ templates/ # Auth-related templates
β βββ static/ # Auth-specific CSS/JS
β
βββ π users/ # User Profile Management
β βββ models.py # Profile and Follow models
β βββ views.py # Profile CRUD operations
β βββ urls.py # Profile routes
β βββ utils.py # Helper functions
β βββ templates/ # Profile templates
β βββ static/ # Profile-specific JS (follow.js)
β
βββ π feed_and_posts/ # Content & Engagement
β βββ models.py # Post, Comment, Like models
β βββ views.py # Feed, post, comment views
β βββ feed_urls.py # Feed-related routes
β βββ post_urls.py # Post-related routes
β βββ templates/ # Feed and post templates
β βββ static/ # JS for likes, comments
β
βββ π core/ # Core Functionality
β βββ views.py # Home, about, contact views
β βββ urls.py # Core routes
β βββ templates/ # Landing and static pages
β βββ static/ # Global CSS and images
β
βββ π admincontrol/ # Admin Features
β βββ views.py # Admin-specific views
β βββ admin.py # Django admin configuration
β
βββ π network/ # Project Configuration
β βββ settings.py # Django settings
β βββ urls.py # Root URL configuration
β βββ wsgi.py # WSGI application
β βββ asgi.py # ASGI application
β
βββ π database/ # Database Configuration
β βββ docker-compose.yml # Docker setup for DB
β βββ info.txt # Database information
β
βββ π other/ # Utilities
β βββ generateSecret.py # Secret key generator
β βββ Important_commands.md # Useful Django commands
β
βββ π manage.py # Django management script
βββ π db.sqlite3 # SQLite database
βββ π requirements.txt # Python dependencies
βββ π pyproject.toml # Project metadata
βββ π README.md # Project documentation
βββ π LICENSE # MIT License
Usage
For End Users
Getting Started
-
Create an Account
- Navigate to the registration page
- Fill in username, email, and password
- Verify your account and log in
-
Set Up Your Profile
- Click on your username to view your profile
- Click βEdit Profileβ to add:
- Profile biography
- Avatar/profile picture
- Other personal information
-
Build Your Network
- Browse user profiles
- Click βFollowβ on profiles youβre interested in
- View your followers and following lists
-
Create Content
- Click βCreate Postβ from the navigation menu
- Add a compelling title and content
- Publish to share with your network
-
Engage with Content
- Browse your personalized feed of followed users
- Like posts by clicking the heart icon
- Add comments to start discussions
- Edit or delete your own posts and comments
For Administrators
Access Admin Panel
- Navigate to
/adminor click the admin link - Log in with superuser credentials
- Access comprehensive management tools
Admin Capabilities
- User Management: View, edit, and moderate user accounts
- Content Moderation: Review and manage posts and comments
- Statistical Overview: Monitor platform activity and engagement
- Permission Control: Assign roles and permissions
- System Configuration: Modify platform settings
API Reference
Authentication Endpoints
| Endpoint | Method | Description |
|---|---|---|
/auth/register/ | POST | Register new user account |
/auth/login/ | POST | Authenticate user |
/auth/logout/ | POST | End user session |
User Endpoints
| Endpoint | Method | Description |
|---|---|---|
/users/<username>/ | GET | View user profile |
/users/edit/ | POST | Update user profile |
/users/follow/<user_id>/ | POST | Follow/unfollow user |
Post Endpoints
| Endpoint | Method | Description |
|---|---|---|
/feed/ | GET | View personalized feed |
/feed/all/ | GET | View all posts |
/posts/create/ | POST | Create new post |
/posts/<post_id>/ | GET | View specific post |
/posts/<post_id>/edit/ | PUT | Edit post |
/posts/<post_id>/delete/ | DELETE | Delete post |
/posts/<post_id>/like/ | POST | Like/unlike post |
Comment Endpoints
| Endpoint | Method | Description |
|---|---|---|
/posts/<post_id>/comment/ | POST | Add comment |
/comments/<comment_id>/edit/ | PUT | Edit comment |
/comments/<comment_id>/delete/ | DELETE | Delete comment |
Security
Network implements multiple security measures to protect user data and ensure platform integrity:
Implemented Security Features
β Authentication & Authorization
- Secure password hashing using Djangoβs PBKDF2 algorithm
- Session-based authentication with secure cookies
- Login required decorators for protected views
- User permission checks for content modification
β Data Protection
- CSRF protection on all forms
- SQL injection prevention via Django ORM
- XSS protection through template escaping
- Input validation and sanitization
β Production Security
- HTTPS enforcement in production
- Secure cookie flags (HTTPOnly, Secure)
- Content Security Policy headers
- Protection against clickjacking
Security Best Practices
# Example security settings
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_BROWSER_XSS_FILTER = True
X_FRAME_OPTIONS = 'DENY'
SECURE_CONTENT_TYPE_NOSNIFF = True
Reporting Security Issues
If you discover a security vulnerability, please email krsahil8825@gmail.com with details. Do not create public GitHub issues for security vulnerabilities.
Dependencies
Iβve used the following key dependencies:
Django==5.2.7- Web frameworkasgiref==3.10.0- ASGI supportsqlparse==0.5.3- SQL parsingtzdata==2025.2- Timezone datavalidators==0.35.0- Data validationrequests==2.32.5- HTTP library
For complete list, see pyproject.toml.
License
Iβve licensed this project under the MIT License. See the LICENSE file for details.
Contact
Iβd love to hear from you! For questions, feedback, or collaboration:
- GitHub: krsahil8825
- Email: krsahil8825@gmail.com
Acknowledgments
Iβd like to thank the Django community for the excellent framework and documentation that made this project possible.
Made with β€οΈ by Kumar Sahil
Browse other projects that demonstrate real-world problem solving, and production-ready development.