/algocode-auth

The auth-service for Algocode, a project in microservices. Algocode is a coding practice platform just like leetcode

Primary LanguagePythonGNU General Public License v3.0GPL-3.0


Logo

Algocode - The Leetcode for Hackers

Algocode is a DSA practice platform just like Leetcode!

Read the blog »

Algocode Auth Service . Code Manager Service . RCE Engine Service

General Information

Algocode is an online data structure and algorithm practice backend built in microservices architecture.

Algocode currently has three services: Algocode Auth Service . Code Manager Service . and RCE Engine Service

Algocode Auth is responsible for User Management service for Algocode - a DSA Practice Platform just like Leetcode.

To learn more about Algocode and the architecture, please READ-THE-BLOG-URL or visit Algocode here.

Algocode Auth Service uses celery to asynchronously send email to users,Flower to monitor celery workers, resend for email service, and the auth service is a fully dockerized solution.

To read more on Development or Production stage, please follow the below sections.

NOTE

Workflow

Once a user completes a registration in the Algocode platfrom, a profile for the user is also created of the user using Django Signals

A. Documentation

Please visit the documentation page for the detailed guide on Algocode Auth Service.

However, all the APIs are referenced in the API Reference section below.

B. Deployment

The service is deployed in Azure VM Ubuntu 22.04 server.

C. About Algocode

This is Algocode Auth Service specific guideline.

Please visit Algocode to learn the mircroservices architecture of Algocode and more in-depth guideline how to submit a solution to Algocode platform.



Development Stage

Development Stage of Auth Service

The Algocode Auth Services uses the following services to serve the request during Development Stage.

a. Nginx as webserver.
b. Gunicorn  as application server .
c. Celery to process tasks asynchronously.
d. Flower to monitor celery worker.
e. Mailhog to mock email management.
f. Django as backend.
g. Django Rest Framework for API.
h. PostgreSQL for user management database.
i. Redis for celery backend. 
l. Docker to containerize the service. 

Production Stage

Production Stage of Auth Service

The Algocode Auth Services uses the following services to serve the request during Production Stage.

a. Nginx as webserver.
b. Nginx Proxy Manager to manage Nginx.
c. Portainer to manage and monitor docker container in Auth Service. 
b. Gunicorn as application server.
e. Celery to process tasks asynchronously.
f. Flower to monitor celery worker.
g. Resend as email service.
h. Django as backend.
i. Django Rest Framework for API.
j. PostgreSQL for user management database.
k. Redis for celery backend. 
l. Docker to containerize the service. 

Deployment

The Auth Service is deployed in Azure VM Ubuntu 22.04 Server.


Watch In Action

A. Long Video (Describes all the features and architecture)

  • Watch from 16:30 for code execution begin and 18:30 for code submission result.
Watch the video

B. Short Video (Only core features)

  • Watch from 09:30 for code execution begin and 11:30 for code submission result.
Watch the video

API Reference - User Management

Algocode uses JWT tokens as cookies to manage Authentication/Authorization token.

User Management APIs

Registration
    POST https://auth.algocode.site/api/v1/auth/registration/
Parameter Type Description
username string Required Your username for the account.
email string Required Your valid email address.
password1 string Required Your password.
password2 string Required Confirm your password.
first_name string Required Your first name.
last_name string Required Your last name.
Login
  POST https://auth.algocode.site/api/v1/auth/login/
Parameter Type Description
email string Your registered email.
password string Your password.
Verify Email
    POST  https://auth.algocode.site/api/v1/auth/registration/verify-email/
Parameter Type Description
key string Required. Your copied token from your email

To learn more on Registration APIs please also visit here - Registration in Algocode

Change Password (While Authenticated).
    POST  https://auth.algocode.site/api/v1/auth/password/change/
Parameter Type Description
new_password1 string Required. Your new password.
new_password2 string Required. Confirm your new password.
Reset Password (Forgot Password).
    POST  https://auth.algocode.site/api/v1/auth/password/reset/
Parameter Type Description
email string Required. Your registered email
Confirm Reset Password (Confirm Forgot Password).
    POST  https://auth.algocode.site/api/v1/auth/password/reset/confirm/
Parameter Type Description
token string Required. Token from the email sent to your registered email address.
uid string Required. UID from the email sent to your registered email address.
new_password1 string Required. Your new password.
new_password2 string Required. Confirm your new password.
Refresh Token (While Authenticated).
    POST  https://auth.algocode.site/api/v1/auth/token/refresh/
Refresh Token (While Authenticated).
    POST  https://auth.algocode.site/api/v1/auth/logout/

API Reference - User Details

User Details APIs

Get All User Details
    GET  https://auth.algocode.site/api/v1/user/user-detail/
Get User Details of a User
    GET  https://auth.algocode.site/api/v1/user/user-detail/<uuid:id>/
Parameter Type Description
id string Required The id of the user to get details

API Reference - Profile Details

User Profile Details APIs

Profiles are the more user centric details for a user.

Get All User Profile Details
    GET  https://auth.algocode.site/api/v1/profile/all-user-profiles/
Get Profile Details of an Authenticated User
     GET  https://auth.algocode.site/api/v1/profile/profile/
Get Profile Details of other User
     GET  https://auth.algocode.site/api/v1/profile/profile/<uuid:id>/
Parameter Type Description
id string Required The id of the user to get details
UPDATE Profile Details of an Authenticated User
     GET  https://auth.algocode.site/api/v1/profile/profile/update/
Parameter Type Description
gender string M, for Male F for Female , or O for Other.
twitter_handle string Twitter handle of the user.
phone_number string Phone number of the user.

Healthcheck

     GET  https://auth.algocode.site/api/v1/common/healthcheck/

Please visit the documentation page for more details.


Run Locally and Contribution

Run Locally

Please fork and clone this development branch of Algocode Auth Service, and follow along with the envs-examples.

cd to src and create a virtual environment. Activate the virtual environment.

Run make docker-up and the development setup will start running. Please install make in your host machine.

If you use Windows Operating System, please run the respective docker commands from the dev.yml docker compose file.

Contribution

You are always welcome to contribute to the project. Please open an issue or raise a PR on the project.


Code Submission Result Examples


Some Code Submission Result Snapshots


A. AC Solution

dd8dbfe4-621b-49f1-b3a6-7ab2a892db87

B. WA Solution

bedb4255-86c9-4417-b920-5976e6129cbb

C. Compilation Error

1c5edd39-8ccd-4e23-a61d-66ae9564ca85

D. Segmentation Fault

WhatsApp Image 2024-06-05 at 11 42 42 PM (1)

E. Memory Limit Exceed

WhatsApp Image 2024-06-05 at 11 42 03 PM (1)

F. Time Limit Exceed

WhatsApp Image 2024-06-05 at 11 42 03 PM (1)

Linux Postman C++ Java Python Django AWS Docker Bash Azure CircleCI Node.js Kafka RabbitMQ Nginx

🔗 Links

Email Me Twitter LinkedIn Hashnode Medium Devto LeetCode