Skip to content

🌱💧A Django-based application to manage hydroponic systems with full CRUD capabilities, sensor data management, and user authentication.

License

Notifications You must be signed in to change notification settings

filipwroblewski/django-hydroponics-management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-hydroponics-management

🌱💧A Django-based application to manage hydroponic systems with full CRUD capabilities, sensor data management, and user authentication.

Description

Django Hydroponics Management is a web application built with Django and Django REST Framework that allows users to manage hydroponic systems and sensor data. It provides endpoints for CRUD operations on hydroponic systems and sensor measurements, user authentication, and more.

Installation

Follow these steps to set up and run the application locally:

  1. Clone the repository:

    git clone https://github.com/filipwroblewski/django-hydroponics-management.git
  2. Navigate to the project directory:

    cd django-hydroponics-management
  3. Create a .env file in the root directory and add the following variables:

    SECRET_KEY=<your_secret_key>
    
    POSTGRES_DB=<your_database_name>
    POSTGRES_USER=<your_database_user>
    POSTGRES_PASSWORD=<your_database_password>
    POSTGRES_HOST=db
    
    • Replace <your_secret_key> with value, generated by

      from django.core.management.utils import get_random_secret_key
      print(get_random_secret_key())

      Note: You should have your django installed.

    • Replace <your_database_name>, <your_database_user>, and <your_database_password> with your own values.

    Note: The .env file is used to store environment variables that are specific for local development environment. This file should not be committed to version control. The .env should be listed in .gitignore file.

Configuration

Make sure Docker and Docker Compose are installed on your machine. You can download Docker from the official Docker website.

Running the Application

Once everything is set up, you can run the application with Docker using the following commands:

  1. Build and start the Docker containers:

    docker-compose up --build

    This command will:

    • Build the Docker images as specified in the Dockerfile.
    • Start the services defined in docker-compose.yml.

    Example output

    If you have not built yet, use docker-compose up --build. If you have already built, use docker-compose up.

    docker-compose up --build

    Example output

  2. Apply database migrations:

    After the containers are up and running, create and apply the Django migrations to set up your database schema:

    1. Make Migrations

      docker-compose exec web python manage.py makemigrations

      Example output:

      No changes detected
    2. Migrate

      docker-compose exec web python manage.py migrate

      Example output

  3. Create a superuser:

    To create a Django superuser for accessing the admin interface, run:

    docker-compose exec web python manage.py createsuperuser

    Example output

  4. Access application:

    Description URL
    Access application http://localhost:8000
    Access Django admin interface http://localhost:8000/admin

API Usage

Hydroponics Management API allows you to interact with hydroponic systems and measurements. To explore and test the API endpoints, you can use Api documentation interface using Swagger.

You can access the Swagger UI at http://127.0.0.1:8000/api-docs/. This interface provides information about each API endpoint, including the available methods, parameters, and expected responses. You can also use it to execute API requests directly from your browser, making it easier to understand how to interact with the API effectively.

To get started with the API:

  1. Ensure your server is running.
  2. Navigate to http://127.0.0.1:8000/api-docs/.
  3. Use the interactive documentation to explore the available endpoints and try out API requests.

API Docs Image

Testing

To test API you can run:

docker-compose exec web python manage.py test

Example output:

Found 52 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
....................................................
----------------------------------------------------------------------
Ran 52 tests in 33.261s

OK
Destroying test database for alias 'default'...

You can find tests here

Stopping the Application

To stop the application, run:

  1. Press ctrl + C

    Example output:

    Gracefully stopping... (press Ctrl+C again to force)
    [+] Running 2/2
    - Container django-hydroponics-management-web-1  Stopped                             0.8s
    - Container django-hydroponics-management-db-1   Stopped                             0.7s canceled
  2. Remove containers:

    docker-compose down

    Example output:

    [+] Running 3/3
    - Container django-hydroponics-management-web-1  Removed                             0.0s
    - Container django-hydroponics-management-db-1   Removed                             0.0s
    - Network django-hydroponics-management_default  Removed                             0.8s

This command will stop and remove the containers, but the data in the PostgreSQL volume will be preserved.

License

This project is licensed under the MIT License.

About

🌱💧A Django-based application to manage hydroponic systems with full CRUD capabilities, sensor data management, and user authentication.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published