LangCorrect / server

Master grammar, spelling, and syntax in the language(s) you’re learning through direct feedback on your writing from fluent, native speakers.
https://langcorrect.com
21 stars 12 forks source link
edtech hacktoberfest language-learning writing-practice writing-prompts writing-tool

Built with Cookiecutter Django Ruff

View the live website here.

Logo

Introduction

Welcome to the LangCorrect repository! This community-driven platform is designed to help users master writing in foreign languages. Ideal for language learners in search of practice and native speakers willing to lend a hand, LangCorrect offers a friendly, engaging environment where you can connect, share, and learn.

This repository houses the source code for the LangCorrect web application, developed using Django for the backend and the Django templating engine for the frontend. Additionally, a React client is currently in development; you can access its repository by clicking on LangCorrect React Client.

Interested in the features we offer or looking to contribute? Read on to find out more.

Features

Note: This is not an exhaustive list of features. LangCorrect is continually evolving, and new features are being added regularly.

Technologies Used

Folder Structure (WIP)

langcorrect/ - Project-specific code
    constants/ - Project-wide constants
    helpers/ - Project-wide helpers
    templates/ - All project templates
    static/ - All project static files
    <app>/ - Specific app folders
        constants/ - App-specific constants
        helpers/ - App-specific helpers
        api/ - wip App-specific API files

Road Map (WIP)

Getting Started

Prerequisites

Installation

Clone the repository

git clone git@github.com:LangCorrect/server.git

Create and activate a virtual environment

python3 -m venv venv
source venv/bin/activate

Install project dependencies

pip install -r requirements/local.txt

Install dictionaries

We use Fugashi and NLTK for text parsing. Fugashi parses Japanese text and NLTK parses text in various languages.

python -m unidic download
python -m nltk.downloader popular

Create the database

psql
CREATE DATABASE langcorrect;

Run the migrations

python manage.py migrate

Setup pre-commit

Make sure to setup pre-commit, otherwise there will be a bunch of CI and Linter errors.

pre-commit install

Install fixtures

python manage.py loaddata fixtures/languages.json
python manage.py loaddata fixtures/correction_types.json

Run the server

python manage.py runserver

The site will be accessible via http://localhost:8000.

Note: User registrations require email confirmations. Check your terminal for this link!

Start a celery worker (optional)

celery -A config.celery_app worker --loglevel=info

Forward Stripe events to the webhook endpoint (optional)

stripe listen --forward-to localhost:8000/subscriptions/webhook/

Settings

This project was started with Cookiecutter Django. To see a table of configurable settings visit settings.

Linters and Testing

This project uses several tools to maintain code quality. Below are the commands to run these tools.

Linters

We use flake8 for checking Python code for style and syntax errors and pylint for additional code analysis.

Testing

Pytest

This project uses the Pytest, a framework for easily building simple and scalable tests.

python manage.py pytest #runs all tests
python manage.py pytest langcorrect/<app> #test specific app

Coverage

You should build your tests to provide the highest level of code coverage. You can run the pytest with code coverage by typing in the following command:

python manage.py coverage run -m pytest
python manage.py coverage report

Unit Tests

python manage.py test

Forward strip events to the webhook endpoint (optional)

stripe listen --forward-to localhost:8000/subscriptions/webhook/

Celery

This app utilizes Celery as an asynchronous task queue to efficiently manage background tasks, such as updating user rankings and running periodic tasks via the Beat scheduler.

To run a celery worker:

cd langcorrect
celery -A config.celery_app worker -l info

Please note: For Celery's import magic to work, it is important where the celery commands are run. If you are in the same folder with manage.py, you should be right.

To run periodic tasks, you'll need to start the celery beat scheduler service. You can start it as a standalone process:

cd langcorrect
celery -A config.celery_app beat

or you can embed the beat service inside a worker with the -B option (not recommended for production use):

cd langcorrect
celery -A config.celery_app worker -B -l info

Sentry

Sentry is an error logging aggregator service. You can sign up for a free account at https://sentry.io/signup/?code=cookiecutter or download and host it yourself. The system is set up with reasonable defaults, including 404 logging and integration with the WSGI application.

You must set the DSN url in production.

Contributing to LangCorrect

We welcome contributions from everyone, whether you are a seasoned programmer or a first-timer. Below are the steps and guidelines you should follow to contribute to this project.

Please make sure that you have:

  1. Set up the project and have it running locally. Follow the instructions in the Getting Started section.
  2. Familiarized yourself with our Code of Conduct (TBD).

Contribution Workflow:

  1. Find an Issue: Browse the open issues and comment on one expressing your intent to work on that issue.
  2. New Issue: If you've found a new issue or have a new feature to suggest, create a new issue to report it.
  3. Fork & Clone: Fork the project to your own GitHub account, and clone it to your local machine.
  4. Create a Feature Branch: Create a new branch named after the issue you are solving, Prefix the branch name with the issue number: git checkout -b 154-fixing-some-issue.
  5. Make Changes: Implement your changes.
  6. Run pre-commit Checks: Before commiting, run pre-commit checks to ensure code style and quality: pre-commit.
  7. Commit Changes: Commit your changes with a meaningful commit message, referencing the issue number: git commit -m "Add meaningful description here (#154)"
  8. Push Changes: Push your changes.
  9. Open Pull Request: Open a PR in the original repository and fill in the PR template.
  10. Address Reviews: Maintainers will review your PR. Make any requested changes if needed.

If you have any questions or need further clarification on any of the steps, feel free to reach out to our Discord: https://discord.gg/Vk7KcV26Fe.

We look forward to your contributions!