Skip to content

MashtiK/GI-Backend

Repository files navigation

Endura Grease Interceptor Project - Back-End

Project Structure

├── BackEndAPIs/          # Django project directory
│   ├── settings.py       # Project settings
│   ├── urls.py           # URL configurations
│   └── ...
├── db.sqlite3            # SQLite database file
├── interface/            # Main application
│   ├── models.py         # Data models
│   ├── views.py          # Request handlers
│   ├── serializers.py    # Data serialization
│   ├── validators.py     # Custom validators
│   ├── hashers.py        # Custom password hashers
│   └── ...
├── manage.py             # Django command-line utility
├── requirements.txt      # Project dependencies
├── static/               # Static files
├── user_images/          # Uploaded user images
└── venv/                 # Python virtual environment

Key Components

Models (interface/models.py)

Defines the database schema.

Views (interface/views.py)

Handles HTTP requests and interact with models to return a response, contains the code logic.

Device Management:

  • create_device: Creates a new device.
  • check_key_validity: Verifies device keys.
  • generate_qr_code: Generates QR codes for devices.
  • get_device_info, update_device_info, delete_device_info: CRUD operations on devices.

User Authentication:

  • register: User registration.
  • CustomTokenObtainPairView: JWT token generation.
  • reset_password, forgot_password: Password management.
  • send_email, send_password_token: Email functionalities.

Utilities:

  • Validation functions for phone numbers and emails.
  • Helper functions for sending emails using Azure services.

Common Commands

Setup and Activation

# Create virtual environment
python -m venv venv

# Activate virtual environment
source venv/bin/activate  # On Windows: venv\Scripts\activate

Install Dependencies

pip install -r requirements.txt

Database Migrations

# Create migration files
python manage.py makemigrations

# Apply migrations
python manage.py migrate

Run Development Server

python manage.py runserver

Install New Package

pip install package_name
pip freeze > requirements.txt  # Update dependencies

Updating the Project

Adding Models

  1. Define new models in interface/models.py
  2. Create and apply migrations:
python manage.py makemigrations interface
python manage.py migrate

API Endpoints

Device Endpoints

Create Device: POST /v1/create_device/ Check Key Validity: POST /v1/check_key_validity/ Generate QR Code: POST /v1/generate_qr_code/ Get Device Info: GET /v1/get_device_info/ Update Device Info: PUT /v1/update_device_info/ Delete Device Info: DELETE /v1/delete_device_info/ Get Device List: GET /v1/get_device_list/

User Endpoints

Register: POST /v1/register/ Check User: GET /v1/check_user/ Get User Info: GET /v1/get_user_info/ Reset Password: PUT /v1/reset_password/ Send Password Token: POST /v1/send_password_token/ Forgot Password: PUT /v1/forgot_password/ Update Password: POST /v1/update_password/ Check Confirmation Code: POST /v1/check_code/ Email Confirmation Code: GET /v1/email_code/ Delete User Info: DELETE /v1/delete_user_info/ Update User Info: PUT /v1/update_user_info/ Delete User: DELETE /v1/delete_user/ Get Users: GET /v1/get_users/

Authentication

Obtain Token: POST /v1/api/token/ (Custom JWT) Refresh Token: POST /v1/api/token/refresh/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5