Django-based social network with real-time messaging
Provides real-time messaging, friendship management, user profiles, and two-factor authentication. Designed for secure communication with a modern dark-themed interface.
Simple Social Network is a Django-based web application that provides real-time messaging, friendship management, user profiles, and two-factor authentication. The platform is designed for secure communication and social interaction with a modern, dark-themed interface.
Backend:
Frontend:
Security:
Prerequisites: Python 3.11+, PostgreSQL 15+, Redis 7+, Git
# Clone repository git clone https://github.com/aixandrolab/simple-social-network.git cd simple-social-network # Create virtual environment python -m venv venv source venv/bin/activate # Install dependencies pip install -r requirements.txt
Configure PostgreSQL:
# Arch Linux
sudo pacman -S postgresql
sudo su - postgres -c "initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'"
sudo systemctl start postgresql
sudo systemctl enable postgresql
# Create database
sudo -u postgres psql
CREATE DATABASE simple_social_network_db
OWNER postgres
ENCODING 'UTF-8'
LC_COLLATE 'en_US.UTF-8'
LC_CTYPE 'en_US.UTF-8'
TEMPLATE template0;
Configure Redis:
# Arch Linux sudo pacman -S redis sudo systemctl start redis sudo systemctl enable redis
Environment Variables (.env):
DJANGO_ENV=development SECRET_KEY=your-secret-key-here DEBUG=True ALLOWED_HOSTS=localhost,127.0.0.1 DB_NAME=simple_social_network_db DB_USER=postgres DB_PASSWORD=your-db-password DB_HOST=localhost DB_PORT=5432 REDIS_URL=redis://localhost:6379/1
Apply Migrations & Run:
python manage.py migrate python manage.py createsuperuser python manage.py collectstatic python manage.py runserver
Access at: http://localhost:8000
simple-social-network/ ├── chats/ │ ├── signals.py # Post-save signals │ ├── forms/ # Chat settings form │ ├── templatetags/ # Custom template tags │ ├── models/ # Chat, ChatStatus, ChatMessage │ └── views/ # Chat views ├── core/ │ ├── consumers.py # WebSocket consumers │ ├── context_processors.py # Site config context │ ├── models.py # SiteConfig singleton │ ├── services.py # Email services │ ├── routing.py # WebSocket routing │ ├── signals.py # SiteConfig signals │ ├── utils/ # Pagination utilities │ └── views/ # Home, auth, password views ├── friends/ │ ├── services.py # Friendship business logic │ ├── signals.py # Status change logging │ ├── models/ # Friendship, FriendshipHistory │ └── views/ # Friend request views ├── profiles/ │ ├── middleware.py # Last activity tracking │ ├── signals.py # User profile creation │ ├── forms/ # Profile, 2FA, password forms │ ├── utils/ # Image validation │ ├── models/ # Profile, token models │ └── views/ # Profile, 2FA, settings views ├── static/ # Static files ├── templates/ # Base templates and components ├── media/ # User-uploaded files ├── .env # Environment variables ├── manage.py ├── requirements.txt └── README.md
WebSocket:
ws://localhost:8000/ws/chat/{chat_id}/
Message Types:
chat_message_event — Send/receive new messagesedit_message_event — Edit existing messagesdelete_message_event — Delete messagesURL Patterns:
| URL | Description |
|---|---|
/ | Home page |
/login/ | User login |
/register/ | User registration |
/profile/detail/{slug}/ | User profile |
/profile/search/ | Search users |
/friends/@username/ | Friends list |
/friends/incoming/ | Incoming friend requests |
/friends/outgoing/ | Outgoing friend requests |
/chats/active/ | Active chats list |
/chats/archived/ | Archived chats |
/chats/deleted/ | Deleted chats |
/chats/create/{profile_id}/ | Create new chat |
/chat/details/{chat_id}/ | Chat detail/messages |
/chat/settings/{chat_id}/ | Chat settings |
/two-factor/ | 2FA management |
| Variable | Description | Default |
|---|---|---|
DJANGO_ENV | Environment (development/production) | development |
SECRET_KEY | Django secret key | Required |
DEBUG | Debug mode | True |
ALLOWED_HOSTS | Comma-separated hosts | localhost |
DB_NAME | Database name | simple_social_network_db |
DB_USER | Database user | postgres |
DB_PASSWORD | Database password | Required |
DB_HOST | Database host | localhost |
DB_PORT | Database port | 5432 |
REDIS_URL | Redis connection URL | redis://localhost:6379/1 |
EMAIL_ON | Enable email sending | False |
sudo systemctl status postgresqlsudo -u postgres psql -lsudo systemctl status redisredis-cli pingps aux | grep daphnepython manage.py shell → from django.contrib.sessions.models import Session; Session.objects.all().delete()By using this software, you agree to the full disclaimer terms.
Software provided "AS IS" without warranty. You assume all risks.
Full legal disclaimer: See DISCLAIMER.md
License: BSD 3-Clause License