{"id":23263800,"url":"https://github.com/gitericsson/enerdit-be","last_synced_at":"2026-05-10T05:32:24.946Z","repository":{"id":268867347,"uuid":"905668729","full_name":"gitEricsson/Enerdit-BE","owner":"gitEricsson","description":"Enerdit Backend is the server-side component of the Enerdit application, designed to handle user authentication, energy audit data management, and provide a RESTful API for the frontend. It is built using Django and Django REST Framework.","archived":false,"fork":false,"pushed_at":"2024-12-20T16:47:37.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T06:34:29.299Z","etag":null,"topics":["django","django-rest-framework","gunicorn","postgresql","uvicorn"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gitEricsson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":"audits/__init__.py","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-19T09:40:04.000Z","updated_at":"2024-12-20T16:47:40.000Z","dependencies_parsed_at":"2024-12-19T11:40:42.504Z","dependency_job_id":"f979e396-d295-48ee-af0f-180dcc6b290f","html_url":"https://github.com/gitEricsson/Enerdit-BE","commit_stats":null,"previous_names":["gitericsson/enerdit-be"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gitEricsson/Enerdit-BE","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitEricsson%2FEnerdit-BE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitEricsson%2FEnerdit-BE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitEricsson%2FEnerdit-BE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitEricsson%2FEnerdit-BE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gitEricsson","download_url":"https://codeload.github.com/gitEricsson/Enerdit-BE/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitEricsson%2FEnerdit-BE/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261808048,"owners_count":23212687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-rest-framework","gunicorn","postgresql","uvicorn"],"created_at":"2024-12-19T14:27:38.553Z","updated_at":"2026-05-10T05:32:24.874Z","avatar_url":"https://github.com/gitEricsson.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Enerdit Backend\n\nEnerdit Backend is the server-side component of the Enerdit application, designed to handle user authentication, energy audit data management, and provide a RESTful API for the frontend. It is built using Django and Django REST Framework.\n\n## Table of Contents\n\n- [Features](#features)\n- [Technologies Used](#technologies-used)\n- [Installation](#installation)\n- [Usage](#usage)\n- [API Endpoints](#api-endpoints)\n- [Database Models](#database-models)\n\n## Features\n\n- User authentication with JWT tokens\n- Management of energy audit data\n- RESTful API for frontend integration\n- Support for multiple building types and compartments\n- Energy consumption calculations and recommendations\n\n## Technologies Used\n\n- **Django**: A high-level Python web framework for rapid development.\n- **Django REST Framework**: A powerful toolkit for building Web APIs.\n- **PostgreSQL**: A powerful, open-source object-relational database system.\n- **Django CORS Headers**: For handling Cross-Origin Resource Sharing (CORS).\n- **Django Environ**: For managing environment variables.\n- **Gunicorn**: A Python WSGI HTTP Server for UNIX, used to serve the application.\n- **Uvicorn**: A lightning-fast ASGI server for Python, suitable for asynchronous applications.\n\n## Installation\n\nTo set up the Enerdit backend, follow these steps:\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/yourusername/enerdit-backend.git\n   ```\n\n2. Navigate to the project directory:\n\n   ```bash\n   cd enerdit-backend\n   ```\n\n3. Create a virtual environment:\n\n   ```bash\n   python -m venv venv\n   ```\n\n4. Activate the virtual environment:\n\n   - On Windows:\n     ```bash\n     venv\\Scripts\\activate\n     ```\n   - On macOS/Linux:\n     ```bash\n     source venv/bin/activate\n     ```\n\n5. Install the dependencies:\n\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n6. Create a `.env` file in the root directory and add the following environment variables:\n\n   ```\n   SECRET_KEY=your_secret_key\n   DEBUG=True\n   DATABASE_URL=postgres://user:password@localhost:5432/yourdbname\n   ```\n\n7. Run database migrations:\n\n   ```bash\n   python manage.py migrate\n   ```\n\n8. Create a superuser (optional):\n   ```bash\n   python manage.py createsuperuser\n   ```\n\n## Usage\n\nTo run the application, use the following command:\n\n```bash\npython manage.py runserver\n```\n\nThis will start the development server at `http://127.0.0.1:8000/`.\n\n### Running with Uvicorn\n\nFor production, you can run the application using Uvicorn. Use the following command:\n\n```bash\npython -m uvicorn Enerdit.asgi:application --host 0.0.0.0 --port 8000\n```\n\n### Running with Gunicorn\n\nAlternatively, you can use Gunicorn to serve your application with Uvicorn workers. This is recommended for production environments. Use the following command:\n\n```bash\ngunicorn -w 4 -k uvicorn.workers.UvicornWorker Enerdit.asgi:application --host 0.0.0.0 --port 8000\n```\n\n- `-w 4`: This option specifies the number of worker processes. Adjust this based on your server's CPU cores.\n- `-k uvicorn.workers.UvicornWorker`: This option tells Gunicorn to use Uvicorn as the worker class.\n\n## API Endpoints\n\nThe following are the main API endpoints available:\n\n- **Authentication**\n\n  - `POST /auth/login/`: Log in a user and receive a JWT token.\n  - `POST /auth/signup/`: Register a new user.\n\n- **Energy Audit**\n  - `POST /energy-audit/`: Create a new energy audit report.\n\n## Database Models\n\nThe backend includes the following key models:\n\n- **User**: Represents the user of the application.\n- **Building**: Represents a building with attributes like type, number of floors, and energy consumption.\n- **Compartment**: Represents a compartment within a building, containing appliances.\n- **Appliance**: Represents an appliance with attributes like power rating and usage time.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitericsson%2Fenerdit-be","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgitericsson%2Fenerdit-be","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitericsson%2Fenerdit-be/lists"}