Welcome to the SparkSentry API repository, an innovative energy management system designed to optimize your energy consumption.
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.
To set up and run the project locally, follow these steps:
- Clone the repository to your local machine.
- Ensure you have Go installed on your machine.
- Install dependencies by running
go mod tidy
. - Configure the necessary environment variables in a
.env
file based on the.env.example
file. - Launch the application with
go run ./cmd/sparksentry/main.go
.
The SparkSentry API exposes the following routes:
POST /api/v1/login
: Log in to the application and receive a JWT token. π
POST /api/v1/register
: Register a new user into the system. π€GET /api/v1/users/me
: Get the authenticated user's information. π€
POST /api/v1/accounts
: Create a new account. π’POST /api/v1/accounts/users
: Associate an existing user to an account. π
POST /api/v1/buildings
: Create a new building with areas. π‘GET /api/v1/buildings
: Retrieve all buildings associated with the authenticated account's ID. ποΈ
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. β
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. π«
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. ποΈ
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.
DB_USER
: Your database usernameDB_PASSWORD
: Your database passwordDB_NAME
: Your database nameDB_HOST
: Your database host, e.g., localhostDB_PORT
: Your database port, e.g., 5432 for PostgreSQLJWT_SECRET_KEY
: A secret key for signing JWTsUSER_ADMIN_EMAIL
: Email for the initial superadmin userUSER_ADMIN_PWD
: Password for the initial superadmin user
Contributions are welcome! If you have suggestions or improvements, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE
file for more details.
For any questions or comments, please contact us at [email protected].