Skip to content

Social network built with Django Framework.

License

Notifications You must be signed in to change notification settings

monosans/socnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SocNet

CI

Social network built with Django Framework.

Features

  • Multi-language (currently English and Russian). Selected based on browser settings.
  • Light and dark theme support with a switch. The browser theme is selected by default.
  • Progressive Web App (PWA) support.

Regular users

  • Register and confirm their account by email
  • Sign in
  • Add backup email addresses in case they lose access to the primary address
  • Reset and change their password
  • Use two-factor authentication with time-based one-time passwords (TOTP)
  • Provide information about themselves in their profile
  • Write real-time messages with Markdown and HTML support to other users using WebSockets
  • Create, edit, like and delete posts and comments with Markdown and HTML support
  • View images in posts, comments and messages as a gallery using viewerjs
  • Subscribe to other users to see their posts in their news feed
  • Inexact search for posts by text
  • Inexact search for messages by text
  • Inexact search for users by selectable fields
  • Delete their account
  • And a lot of other little things

Administrators

  • All of the above
  • Use Django admin panel
  • Use a REST API that has a Swagger UI and supports all CRUD operations and filtering
  • Receive error notifications in Sentry or by email

Installation

Install Docker Compose.

Configuration

Copy the .env.example file to .env. Set the settings you need in the .env file.

Development

# Pull service images
docker compose pull --ignore-buildable
# Build services
docker compose build --pull
# Run DB migrations
docker compose run --rm django python3 manage.py migrate
# Create a superuser if you want
docker compose run --rm django python3 manage.py createsuperuser
# Compile translations
docker compose run --rm django python3 manage.py compilemessages --locale en --locale ru

# Run without debugpy
docker compose up --remove-orphans
# Or run with debugpy
docker compose -f compose.yaml -f compose.override.yaml -f compose.debug.yaml up --remove-orphans

Production

To run this in production, you need to specify the production settings in .env.

# Pull service images
docker compose -f compose.yaml -f compose.prod.yaml pull --ignore-buildable
# Build services
docker compose -f compose.yaml -f compose.prod.yaml build --pull
# Run DB migrations
docker compose -f compose.yaml -f compose.prod.yaml run --rm django python3 manage.py migrate
# Create a superuser if you want
docker compose -f compose.yaml -f compose.prod.yaml run --rm django python3 manage.py createsuperuser
# Run
docker compose -f compose.yaml -f compose.prod.yaml up -d --remove-orphans

Tech Stack

Containerization

  • Docker
  • Docker Compose

Backend

  • Python 3.12
  • Django 5.1
  • django-allauth
  • django-bootstrap5
  • django-cleanup
  • django-environ
  • django-filter
  • django-logentry-admin
  • djangorestframework
  • drf-spectacular
  • channels
  • channels-redis
  • sentry-sdk
  • websockets

Markdown parsing, HTML minification and sanitization, and a few other things are implemented in Rust in the socnet_rs package using the following libraries:

  • ammonia
  • minify-html
  • pulldown-cmark
  • pyo3

Databases

  • PostgreSQL 17 for persistent data
  • Valkey 8 (FOSS Redis fork) for cache and as a layer for Channels

Frontend

  • HTML with Django Template language
  • HTMX 2
  • Bootstrap CSS 5.x
  • Font Awesome 6
  • TypeScript (compiled and minified with esbuild)
  • viewerjs
  • luxon

Web servers

  • Caddy
  • gunicorn
  • uvicorn

Testing

  • pytest
  • factory-boy

Linting

  • mypy
  • ruff
  • eslint
  • stylelint

DB schema

License

MIT