Skip to content

NCKU-CCS/smart-room-backend

Repository files navigation

smart room - backend

Integration

Build

Smart Room Control and Data Collect Service

  • api: Main API Server

    • Flask API Server
    • Data Collection
    • Device Control
    • User Management
  • Redis Server

  • Grafana

  • Relative Projects

    • Database

    • front end

    • controller: A/C Controller

      • Socket Server
      • Receive Command
      • Token Authentication
      • IR Remote Control
    • sensor: Sensors

      • Data Collectction
      • Thermo Sensor
      • Smart Meter
      • CT Sensor

API Document

Document: apiary.apib

Online Document: smart-room document

Getting Started

Prerequisites

  • python 3.7
  • docker 19.03.6

DB Service

Database

Update submodule files

git submodule update --init --remote

When DB schema update, don't forget to update the submodule version

git submodule update --remote

Running Development

  1. Create environment file
cp sample.env .env
  1. Installing Packages & Entering environment
make dev
pipenv shell
  1. Starting external components
make service_up
  1. Migrating database
python api/manage.py db init
python api/manage.py db upgrade
  1. (Optional) Shut down external services
make service_down
  1. (Optional) Version freeze to generate requirements.txt
pipenv lock --requirements > requirements.txt

Running Production

  1. build docker image
make build
  1. update the .env file
  2. run docker-compose
docker-compose up -d

Usage

Add a sensor with new gateway

  1. Add Gateway
  2. Add Sensor
  3. Start to upload data with gateway token