Network - Social Media Platform

Network - Social Media Platform

Published: 2025-12-23 Updated: 2026-02-07
django web development python

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

AppResponsibility
authenticateUser registration, login, and session management
usersProfile management, follow system, and user interactions
feed_and_postsPost creation, feeds, comments, and engagement
coreLanding pages, about, contact, and static content
admincontrolAdministrative 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


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

  1. Create an Account

    • Navigate to the registration page
    • Fill in username, email, and password
    • Verify your account and log in
  2. 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
  3. Build Your Network

    • Browse user profiles
    • Click β€œFollow” on profiles you’re interested in
    • View your followers and following lists
  4. Create Content

    • Click β€œCreate Post” from the navigation menu
    • Add a compelling title and content
    • Publish to share with your network
  5. 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

  1. Navigate to /admin or click the admin link
  2. Log in with superuser credentials
  3. 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

EndpointMethodDescription
/auth/register/POSTRegister new user account
/auth/login/POSTAuthenticate user
/auth/logout/POSTEnd user session

User Endpoints

EndpointMethodDescription
/users/<username>/GETView user profile
/users/edit/POSTUpdate user profile
/users/follow/<user_id>/POSTFollow/unfollow user

Post Endpoints

EndpointMethodDescription
/feed/GETView personalized feed
/feed/all/GETView all posts
/posts/create/POSTCreate new post
/posts/<post_id>/GETView specific post
/posts/<post_id>/edit/PUTEdit post
/posts/<post_id>/delete/DELETEDelete post
/posts/<post_id>/like/POSTLike/unlike post

Comment Endpoints

EndpointMethodDescription
/posts/<post_id>/comment/POSTAdd comment
/comments/<comment_id>/edit/PUTEdit comment
/comments/<comment_id>/delete/DELETEDelete 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 framework
  • asgiref==3.10.0 - ASGI support
  • sqlparse==0.5.3 - SQL parsing
  • tzdata==2025.2 - Timezone data
  • validators==0.35.0 - Data validation
  • requests==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:

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.