UBB-SDI-23 / lab-5x-dpie2303

lab-5x-dpie2303 created by GitHub Classroom

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Music Entities Application

Table of Contents
  1. About The Project
  2. Getting Started
  3. Relevant stack choses
  4. Technical debts

About The Project

This project is a web application built for a computer science course at Babes Bolyai University

(back to top)

Built With

  • React
  • Django
  • Postgres
  • Nginx
  • Cerbot
  • Redis

(back to top)

Getting Started

This guide will walk you through the steps to set up a development or production environment.

Prerequisites

This project requires npm, Docker, and Docker Compose.

  • Docker: Visit Docker's website and follow the instructions to install Docker and docker-compose for your operating system.
  • npm: Install npm using nvm from nvm's GitHub page. Make sure to install npm version 7.7.6 or higher.

Installation

  1. Clone the repo:

    git clone https://github.com/UBB-SDI-23/lab-5x-dpie2303
  2. Copy the .env.template files from the server and ui_music directories and rename them to .env.
    Configure the environment variables for the server, database, and hosting services

    POSTGRES_USER= # Username for Postgres
    POSTGRES_PASSWORD= # Password for Postgres
    POSTGRES_DB= # Database name
    DOMAIN= # Domain for Let's Encrypt Production only
    EMAIL= # Email for Let's Encrypt Production only
    DEBUG= # True or False

    Setup base URL's for the frontend application.

    REACT_APP_API_BASE_URL=http://localhost:8000 # example for development env
    REACT_APP_SOCKET_BASE_URL=ws://localhost:8000 # example for development env
  3. To set up a development environment, start the server and database in the server directory:

    docker-compose -f docker-compose-dev.yml build
    docker-compose -f docker-compose-dev.yml up -d

    Then, in the ui_music directory, execute:

    npm install
    npm start
  4. Setting up a production environment

    In the server directory execute the fallowing commands to prepare the SSL certificates for the initial run:

    docker-compose -f docker-compose-initiate.yml build
    docker-compose -f docker-compose-initiate.yml up -d
    docker-compose down

    After the certificates for the HTTPS connection are created, start the Docker Compose setup:

    docker-compose -f build
    docker-compose -f up -d

    For the deployment and hosting of the frontend application, use Netlify. Refer to their documentation for setup instructions.
    Do not forget to setup the enviroment variabiles!

  5. Finalize the setup:

    docker ps # get the server container id
    docker exec -it <container id> bash
    python manage.py migrate # migrate the models to the db

    To stop your application, in the server directory execute:

    docker-compose down 
  6. Optional!
    This aplication contains a setup to populate the database.
    Make sure that your do this setup before you do any actions on the apllication.
    Adjust the number of entities created by modifying the script in server/music_library

    Start the backend setup using the previous steps. Create the .sql files that contain the artificial data.

    docker ps # get the server container id
    docker exec -it <container id> bash
    python music_library/generate_sql.py 

    This may take a while depending on the number of entities and your computer's performance.
    To execute the .sql files and populate the db, execute the following:

    docker ps # get the db container id
    docker exec -it <container id> bash
    chmod +x sql_scripts/populate_db.sh
    ./sql_scripts/populate_db.sh

    Your database should be populated now!

(back to top)

Relevant stack choses.

Django

  1. django-debug-toolba: Great for debugging, but can add overhead and expose sensitive data if not disabled in production. Available only wehn DEBUG is set to True.
  2. djangorestframework_simplejwt: Provides JWT authentication. but it has limited customization options.
  3. scikit-learn: Implements NearestNeighbors for playlist recommendations, but while it provides accurate recommendations, the prediction part can be slow, especially for large datasets.
  4. daphne: Starts the server using ASGI but is less widely used and documented than other servers.

React

  1. axios: Easy-to-use rest API client, but larger and slower than the native fetch API.
  2. mui/material: Popular React UI framework, but can be heavy for simple projects and its design might not suit all.

Nginx & Certbot

These tools are used to create a proxy server and ensure HTTPS connection.

Redis

Redis is used as a communication layer for the Django application, enabling multiple Django threads to communicate with each other using a web socket connection. While Redis is fast and efficient, it requires careful management of data persistence and memory use.

(back to top)

Technical debts

The chron job is runing each 60 days to renew the SSL certificat.

This code is made to work on a VM with 1 GB of RAM and 1 CPU core.

When registering to the app the code to confirm the authenticity of the user is sent to the UI. A steep to send the confirmation code via email needs to be implemented.

There are 3 types of users: admin, moderator, regular. The form of the users generated by pupulation script are, admin_[user index], moderator_[user index], regular_[user index] and the password is Passowrd.123

(back to top)

About

lab-5x-dpie2303 created by GitHub Classroom


Languages

Language:JavaScript 51.6%Language:Python 40.9%Language:PLpgSQL 4.9%Language:TypeScript 1.0%Language:HTML 0.8%Language:Shell 0.7%Language:CSS 0.2%