Skip to content

Kandeel4411/peam-backend

Repository files navigation

Peam Backend

CI Python: 3.8+ Generic badge Code-style: black

Backend repository for the Peam app.

Getting Started

  • Clone the repo or click here to download the zip file then extract it locally.

  • Install Docker and ensure it is running.

  • Install Make if you're on Windows. OSX already has it installed. Linux will tell you how to install it (i.e., sudo apt-get install make)

  • Run make build

  • Run make run

  • Navigate to http://localhost:8000/ to view the API documentation.

  • Optional: Create a default admin user account by running make create-admin-user for the django admin panel.

Development

  • Install Poetry (1.4.2) for managing dependencies or just use python's pip.

    • Poetry provides a custom installer that can be ran via

      curl -sSL https://install.python-poetry.org | python3 - --version 1.4.2

      Alternatively, poetry can be installed via pip/pip3 with pip install --user poetry or pip3 install --user poetry

      Note: if using an existing local virtual environment, to disable poetry's default venv creation run

      poetry config virtualenvs.create false
  • Run poetry install to install dependencies locally. if you are encountering an error with psycopg2 during poetry installation, ensure postgreqsql is installed (macOS: brew install postgresql)

    • Clone the following dependency repos for plagiarism detection.
    ## In project root directory... ##
    
    git -C src/plagiarism/vendor/ clone https://github.com/tree-sitter/tree-sitter-javascript
    git -C src/plagiarism/vendor/ clone https://github.com/tree-sitter/tree-sitter-python
    • Run the following command to compile the cloned languages
    ## In project root directory... ##
    poetry run python src/manage.py setup_plagiarism
  • Incase of any code changes, make sure to run the following commands to check linting and tests before committing

    ## In project root directory... ##
    
    # Rebuild docker image
    make build
    # Check tests
    make test
    # Format & check linting
    make fmtlint

    To view all available make commands. check here

Notes

If developing locally, you need to create a .env.local.dev file similar to .env.local.dev.example and overriding the default values appropriately.

## In project root directory... ##

# Run migrate to create db / apply migrations
poetry run python src/manage.py migrate

# Create a new admin user
poetry run python src/manage.py create_admin_user \
    --noinput \
    --username admin \
    --password admin \
    --email [email protected]

# Setup site domain and display
poetry run python src/manage.py setup_site

# Run local development server
poetry run python src/manage.py runserver

# Run tests
poetry run pytest src

# Run formatting and linting
poetry run black src
# the next line shouldn't output anything to the terminal if it passes
poetry run flake8 src

if you want to be able to reload server on any code changes without having to run make build every time then you could change the docker-compose.dev.yml's volume section to the following instead:

  volumes:
    # - .:/app       # Uncomment this line
    ...

Releases

No releases published

Packages

No packages published