Giter VIP home page Giter VIP logo

langcorrect / server Goto Github PK

View Code? Open in Web Editor NEW
21.0 2.0 10.0 27.59 MB

Master grammar, spelling, and syntax in the language(s) you’re learning through direct feedback on your writing from fluent, native speakers.

Home Page: https://langcorrect.com

Python 59.82% JavaScript 1.79% HTML 36.95% Shell 0.74% SCSS 0.71%
edtech hacktoberfest language-learning writing-practice writing-prompts writing-tool

server's Introduction

NOTE: We're switching to an API only backend. The client repository will be made available at a later date.

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

  • User Registration and Authentication
  • Profile Customization
  • Multi-language Support
  • Post Creation and Management
  • Peer Review and Corrections
  • Automatic Correction Syntax Highlighting
  • Site and Email Notifications
  • Writing Prompts
  • Challenges
  • Follow and Unfollow Users
  • Stripe Checkout Integration
  • Premium Subscription for Advanced Features
  • Upload images through Local Media Storage or S3

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

Technologies Used

  • Django 4.x
  • Python 3.x
  • Bootstrap CSS
  • HTMX
  • JavaScript
  • PostgreSQL
  • Redis
  • Celery
  • SendGrid
  • Stripe
  • Sentry
  • AWS S3 (Optional)
  • CI/CD (GitHub Actions, GitLab CI, etc.)

Getting Started

Prerequisites

  • PostgreSQL; refer to the official documentation for installation.
  • Pre-commit; refer to the official documentation for the pre-commit.
  • Cookiecutter; refer to the official GitHub repository of Cookiecutter

Installation

Clone the repository

git clone [email protected]: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.

  • Run flake8 to check the entire project for PEP8 compliance
  • Run pylint <python files that you wish to lint> to perform static 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!

server's People

Contributors

alexcjwei avatar chrisjoel10 avatar danielzeljko avatar dependabot[bot] avatar gaurab-khanal avatar itshesam avatar jimkalis16 avatar keyxcode avatar precondition avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

server's Issues

Implement Follower/Following Page to Display List of Users

We need a page to display the list of followers and the users that one is following.

As a user, I want to view a list of my followers and the users I am following so that I can manage my social connections on the platform. When I click on a user, I want to be taken to their profile page. On this page, I will have the ability to unfollow or re-follow them.

  • Create a new route for the Follower/Following page: /users/{slug}/followers and /users/{slug}/following
  • Display a paginated list of users (~100 users per page)
  • Display respective user counts for num of followers and following
  • Links in the profile to view following and followers

Implement Infinite Scroll for Posts on User Profile Page

To improve user experience, implement an infinite scroll feature for displaying posts on the User Profile Page.

As a user, I want to effortlessly scroll through posts on a user's profile page so that I can continuously browse content without having to click the 'Next' or 'Previous' buttons.

  • Add infinite scroll functionality to the posts list on the User Profile Page.
  • Ensure that the feature is compatible across different browsers (Firefox, Chrome, Safari).
  • Load more posts automatically when the user scrolls to the bottom of the page

Migrate make a correction page

  • initialize the correction UI and logic updates
  • Notify the author when a correction has been made
  • Notify the author when only a comment has been made
  • Show the form for overall feedback
  • Add discard modal
  • Email a premium user when they receive a new correction

Verify emails automatically

Every user who has verified their email address on the older project has the profile flag is_verified set to True. It would be nice to use this flag and programmatically verify all email addresses for user accounts that have been verified.

Post images

  • Attach images to post
  • Display attached images in a post
  • Click to expand image (lightbox)
  • Deleting a post should delete the image from the S3 bucket
  • Make uploading an image a premium perk
  • Support local or s3 media storage

Task to Periodically Update is_corrected Flag on Post Object

Currently, the is_corrected flag on a Post object is set to True when a native speaker corrects the post. However, if all corrections are later removed, the flag remains True instead of reverting back to False.

To resolve this, we can periodically run a task to check if a post has corrections and change the flag as needed. Alternatively, we can use a signal but this would increase the system's complexity.

Migrate premium views and functionality

Functionality

  • Supporter badge
  • CSV exports
  • PDF exports
  • Study more languages
  • Side by side corrections
  • Email notifications
  • Image attachments
  • Ratio watch exemption

Views

  • Success Page
  • payment Cancelation Page
  • pricings
  • checkout
  • Cancel subscription
  • Disallow checkout if active subscription or premium_until > timezone.now()

Migrate replies

Change Reply to PostReply to more accurately reflect what it corresponds to

Implement User Rankings Based on Total Contributions

We need a page to display User Rankings that showcases active and high-contribution users. The ranking should be based on total contributions (post submissions, prompt submissions, and corrections).

As a user, I want to see how I rank in terms of activity or points on the platform. I want to view the top 50 users and also see my own ranking, even if it's below the top 50 so that I can measure my engagement against others.

  • Create a new route/page for displaying User Rankings: /rankings
  • Display the top 50 users based on total contributions
  • Below the list of top 50 users, display the user's own rank (e.g., "You are ranked 51st")
  • Implement the ranking logic to accurately calculate a user's rank based on contribution points
  • Create a celery task to recalculate the points every ~12 hours (excluding items that have been soft deleted) (Also closes #27)

Export corrections as an Anki Deck

The goal of this issue is to implement the ability to export corrections as an Anki deck. This feature was originally slated for inclusion in PR #50 but requires a more specialized approach.

Challenges:

  • Unique Identifiers: We need to generate or assign unique model_id, deck_id, and Note's guid.
  • User Configuration: Depending on the design, some user settings may need to be configurable (e.g., deck settings).

Package:

Create a Page to Display User-Submitted Prompts

We need a dedicated page to display all prompts submitted by a user. This will make it easier for users to manage their submitted prompts.

As a user, I would like to be able to view all of my submitted prompts in one place, the ability to filter the prompts, and easily manage them.

  • New route /submissions/prompts
  • Display a list of all prompts submitted by the user
  • Update the nav item link to point to this new page

image

Create a Page to Display User-Submitted Posts

Create a dedicated page for users to manage and review their journal entries.

As a user, I want a centralized page where I can see all of my journal entries in a table for easier management and review.

  • Create a new route: /submissions/posts (TBD)
  • List all journal entries submitted by the current user
  • Provide options to view, edit, or delete each journal entry

Here's an example of how the old one used to look like:

image

Implement Moderator Tools for Editing and Deleting Prompts and Posts

Site moderators need the ability to edit or delete user-submitted prompts and posts for better content management.

As a moderator, I want the ability to click on a drop-down to edit or delete prompts and posts so that I can manage content effectively.

Prompts

  • Implement a drop-down to edit or delete a prompt
  • Feature to convert a prompt into a post automatically (the slug should be randomly generated)

image

Posts

  • Implement a drop-down to edit or delete a post

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.