Skip to content

gzukowski/hydroponics

Repository files navigation

HydroAPI

HydroAPI is a simple Django-based API for managing hydroponic systems and their measurements.

Table of Contents

Prerequisites

Ensure you have the following installed on your machine:

Setup

Generate Django Secret Key

Run the following Python code to generate a new secret key:

import secrets

print(secrets.token_urlsafe(50))

Copy the generated secret key for later use.

Create and Fill .env File

Create a file named .env in the root directory of your project and add the following contents:

SECRET=
DB_NAME=
DB_USER=
DB_PASSWORD=
DB_HOST=
DB_PORT=

Replace fields with your credentials.

Build and Run with Docker

  1. Build the Docker image:

    docker-compose build
  2. Start the Docker containers:

    docker-compose up
  3. Create superuser to access /admin panel: Access the backend container console and run

    python manage.py createsuperuser

Your Django project should now be running on http://localhost:8000.

Usage

To interact with the API, you can use tools like Postman, curl or some designed frontend.

API Endpoints

  • Register: POST /api/auth/register/
  • Login: POST /api/auth/login/
  • Create Hydroponic System: POST /api/hydro/
  • Get Hydroponic Systems: GET /api/hydro/
  • Update Hydroponic System: PUT /api/hydro/{id}/
  • Delete Hydroponic System: DELETE /api/hydro/{id}/
  • Create Measurement: POST /api/hydro/{id}/measurements/
  • Get Measurements: GET /api/hydro/{id}/measurements/

Refer to the API Documentation for detailed information on request and response formats.

Additional Notes:

  • Ensure that your Dockerfile and docker-compose.yml are correctly configured to use the .env variables.
  • You might want to add more environment variables depending on your project's requirements (e.g., database settings).
  • Make sure the .env file is listed in your .gitignore to avoid exposing sensitive information.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published