Skip to content

roll-social-network/roll-social-network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

roll social network

social networks in their essence.

Crie redes sociais em sua essência. Participe de comunidades "rolls" para consumir e compartilhar fotos. Interaja com outros usuários curtindo suas postagens.

roll social network é um projeto de código livre sob a licença MIT desenvolvido com os frameworks Django e Vue.

in English:

Create social networks in their essence. Join communities "rolls" to consume and share photos. Interact with other users by liking their posts.

roll social network is an open source project under the MIT license developed with the Django and Vue frameworks.

Architecture

Rolls, Social and Timeline

In our social network, a community unit is called roll. Users can join a roll by creating a profile on it. Once associated, the user has access to the timeline and can interact by liking other users' posts, as well as collaborating by publishing their own content.

Entity-relationship model:

ER Model

Auth

Access to our social network rolls requires authentication. To simplify and solve some problems, authentication linked to the customer's phone number was chosen.

UML Diagram:

UML Diagram

Advantages of the chosen authentication model:

  • Simplicity. The user does not need to set or remember a password or have a recovery email.
  • Security. Access can only be done with the verification code sent at each login or by granting it to a third party.
  • Real people. We guarantee, in most cases, that the clients is a real person and not a robot. With this we can also have legal applications, since the data uploaded to the social network can be linked to a real person.

OTP time-based

Users, after validating the time-based OTP code, can authenticate using just the code generated by the 2FA application.

UML Diagram:

UML Diagram

Watcher (WebSocket)

Watcher is a WebSocket solution for real-time state update.

UML Diagram

Protected Media with NGINX X-Accel

When the MEDIA_PATH_AS_NGINX_ACCEL flag is enabled, the /media/ endpoint responds, for authenticated users, with the status code 201 and with the X-Accel-Redirect header. With this you can protect media files against unauthenticated users.

Read more about X-Accel in the NGINX documentation.

See the concept applied in the NGINX media conf file.

Run

Development mode

Requirements:

  • Python 3.12
  • pipenv
  • Node.js 20.11

Init ui submodule:

$ git submodule init ui
$ git submodule update --init --recursive

Install dependencies:

$ pipenv install --dev
$ cd ui/ && npm install --include=dev

The default app settings are setted to run locally in development and watch mode.

Init database tables:

$ pipenv run dbmigrate

Run Django app web server in watch mode:

$ pipenv run dev

Build the Vue app and static style files running the ui package in watch mode:

$ cd ui/ && npm run watch

Lint and Tests

Run pylint:

$ pipenv run lint

Run mypy to check typing:

$ pipenv run check-typing

Run unit tests:

$ pipenv run tests

Run unit tests with code coverage:

$ pipenv run coverage
# print code coverage report
$ pipenv run coverage-report

Local as Production

Using dockerization and the Docker Compose definition, you can up all containers and services required by roll social network as if it were in production mode.

$ docker compose up --build

Services diagram:

Local as Production services diagram.

Settings and Environment Vars

This project follow The Twelve-Factor App methodology so all settings can be defined through environment variables.

All settings were centralized in the settings.py file and can be defined by environment variables due to the python-decople config object.