Code Monkey home page Code Monkey logo

sparksentry-api's Introduction

SparkSentry API ⚑

Welcome to the SparkSentry API repository, an innovative energy management system designed to optimize your energy consumption.

Features ⭐

SparkSentry offers a robust platform for energy data collection and analysis, enabling users to monitor and optimize their energy consumption efficiently. It now supports flexible user-account associations, account creation, detailed management of buildings, areas, systems, and equipment, catering to a wide range of energy management needs.

Setup βš™οΈ

To set up and run the project locally, follow these steps:

  1. Clone the repository to your local machine.
  2. Ensure you have Go installed on your machine.
  3. Install dependencies by running go mod tidy.
  4. Configure the necessary environment variables in a .env file based on the .env.example file.
  5. Launch the application with go run ./cmd/sparksentry/main.go.

API Routes πŸ—ΊοΈ

The SparkSentry API exposes the following routes:

Authentication

  • POST /api/v1/login: Log in to the application and receive a JWT token. πŸ”‘

User Management (JWT token required)

  • POST /api/v1/register: Register a new user into the system. πŸ‘€
  • GET /api/v1/users/me: Get the authenticated user's information. πŸ‘€

Account Management (JWT token required)

  • POST /api/v1/accounts: Create a new account. 🏒
  • POST /api/v1/accounts/users: Associate an existing user to an account. πŸ”—

Building Management (JWT token required)

  • POST /api/v1/buildings: Create a new building with areas. 🏑
  • GET /api/v1/buildings: Retrieve all buildings associated with the authenticated account's ID. 🏘️

Area Management (JWT token required)

  • POST /api/v1/buildings/:building_id/areas: Add a new area to a specific building. :park:
  • GET /api/v1/buildings/:building_id/areas: List all areas within a specific building. 🏞️
  • PUT /api/v1/areas/:area_id: Update details of a specific area. 🚧
  • DELETE /api/v1/areas/:area_id: Remove a specific area. β›”

System Management (JWT token required)

  • POST /api/v1/buildings/:building_id/areas/:area_id/systems: Add a new system to a specific area within a building. βš™οΈ
  • GET /api/v1/buildings/:building_id/areas/:area_id/systems: Retrieve all systems associated with a specific area within a building. πŸ”§
  • PUT /api/v1/systems/:system_id: Update details of a specific system. πŸ› οΈ
  • DELETE /api/v1/systems/:system_id: Remove a specific system. 🚫

Equipment Management (JWT token required)

  • POST /systems/:system_id/equipments: Add new equipment to a specific system. βž•
  • GET /systems/:system_id/equipments: List all equipments within a specific system. πŸ“‹
  • PUT /equipments/:equipment_id: Update details of a specific piece of equipment. πŸ“
  • DELETE /equipments/:equipment_id: Remove a specific piece of equipment. πŸ—‘οΈ

Hot Reloading with Air πŸ”₯

This project uses Air for hot reloading during development. Air automatically rebuilds and restarts your application when file changes in the directory are detected, making development faster and more efficient.

To use Air, ensure you have the .air.toml configuration file at the root of your project, then simply run air in your terminal within the project directory.

Environment Variables πŸ”‘

  • DB_USER: Your database username
  • DB_PASSWORD: Your database password
  • DB_NAME: Your database name
  • DB_HOST: Your database host, e.g., localhost
  • DB_PORT: Your database port, e.g., 5432 for PostgreSQL
  • JWT_SECRET_KEY: A secret key for signing JWTs
  • USER_ADMIN_EMAIL: Email for the initial superadmin user
  • USER_ADMIN_PWD: Password for the initial superadmin user

Contribution 🀝

Contributions are welcome! If you have suggestions or improvements, feel free to open an issue or submit a pull request.

License πŸ“„

This project is licensed under the MIT License. See the LICENSE file for more details.

Contact πŸ“¬

For any questions or comments, please contact us at [email protected].

sparksentry-api's People

Contributors

jibe0123 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.