Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

Latest commit

 

History

History
146 lines (109 loc) · 4.47 KB

README.md

File metadata and controls

146 lines (109 loc) · 4.47 KB

Technical documentation

📄 Description

The website where users can write public notes.

Functionality:

  • Notes:
    • Displaying a single list (main page)
    • Displaying by category. Each note can belong to one category
    • Displaying by tags. Each note can have multiple tags
    • Number of views counter
    • Search by titles
    • Adding public and private notes
    • Ability to pin notes (pinned notes will be displayed at the top of the list on the profile page)
    • Rating system: each like increases the rating by 1, each dislike decreases
    • Editing
    • Deleting
  • Displaying the list of authors
  • Profile:
    • Registration
    • Confirmation of e-mail by one-time link
    • Displaying profile and notes
    • Rating system: user's rating is the sum of ratings of his public notes
    • Changing profile data
    • Changing the password
    • Deleting a profile
  • Categories:
    • Displaying categories as a list with different levels of nesting
    • Each category can have subcategories. Notes can belong to both parent and child categories
  • Support for Russian and English languages

Supported languages (in the interface)

  • English
  • Russian (Русский)

📙 Architecture

Modules diagram

Original: modules_diagram.drawio

📘 Database

Schema

Database schema

Original: database_schema.drawio

PostgreSQL

Used if the project is running inside a docker container using Docker compose. Runs before django project.

Configuration in .env and .env.dev files (see getting started tutorial)

Script wait_for_postgres.sh checks that Postgresql is running and available. If this is not the case, the Django app does not launch

SQLite3

Used by default if the project is running on a local machine.

To use another DBMS during development, set the settings for it in .env.localdev file (see settings list in getting started tutorial)

Caching

By default, the cache is saved to /var/tmp/django_cache/publicnotes/. Updates every 5 minutes

📁 Folders and files

  • publicnotes - project source code
    • media - folder with media files
    • locale - folder with translations
    • config - project settings
    • templates - common project templates
    • wall - the main Django application of the project
      • locale - folder with translations
      • migrations - migration files
      • services - business logic of the application
      • static - static files
      • templates - application templates
      • templatetags - custom tags
      • tests - tests
      • admin.py - admin panel settings
      • apps.py
      • exceptions.py - custom exceptions
      • forms.py - forms and their settings
      • generate_fake_data.py - script for generating random notes (for manual testing)
      • models.py - application models
      • urls.py - application URL settings
      • utils.py - utilities used in business logic
      • views.py - model representations
  • docs - documentation
  • docker-compose.dev.yaml - Docker compose config for development
  • docker-compose.yaml - Docker compose config for production
  • Dockerfile.dev - docker config for development
  • Dockerfile - docker config for production
  • wait_for_postgres.sh - script for checking access to Postgresql

🔧 Settings

Loading environment variables for development and run on a local machine

See environment variables list in getting started tutorial

settings.py

# Load environment variables if they don't exist (for development on a local machine)
if 'DJANGO_SECRET_KEY' not in os.environ:
    load_dotenv(dotenv_path=os.path.join(os.path.dirname(BASE_DIR), '.env.localdev'))

Choose the interface language

settings.py

# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/

# LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = 'ru'

Set the path to the cache folder

settings.py

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
        'LOCATION': os.path.join('/var/tmp/django_cache/', os.path.basename(BASE_DIR)),
    }
}