https://github.com/hima890/smartx-platform
A Flask-based web application integrated with a microserver to simulate IoT devices. This project features user authentication, Docker containerization, and real-time IoT device communication.
https://github.com/hima890/smartx-platform
alx-africa alx-software-engineering api docker embeded-systems flask-application iot-platform mysql-database redis
Last synced: about 2 months ago
JSON representation
A Flask-based web application integrated with a microserver to simulate IoT devices. This project features user authentication, Docker containerization, and real-time IoT device communication.
- Host: GitHub
- URL: https://github.com/hima890/smartx-platform
- Owner: hima890
- License: gpl-3.0
- Created: 2025-01-22T15:38:06.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-25T11:27:19.000Z (over 1 year ago)
- Last Synced: 2025-11-12T13:32:21.000Z (7 months ago)
- Topics: alx-africa, alx-software-engineering, api, docker, embeded-systems, flask-application, iot-platform, mysql-database, redis
- Language: CSS
- Homepage:
- Size: 9.98 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README

# Flask Application - Routing and API
This project is a Flask-based web application that provides a robust backend for managing users, devices, and APIs. Below is a detailed overview of the project’s features, setup instructions, and usage guidelines.
## Features
1. **User Management**:
- Login system with session validation.
- User profile management with details like username, email, and last login.
2. **Dashboard and Devices**:
- Individual dashboards for devices.
- Device information and statistics retrieval.
3. **API Support**:
- API key validation for secure operations.
- Endpoints for listing devices, fetching statistics, and updating values.
4. **Database Integration**:
- Handles user and device data storage.
- Supports dynamic data updates.
5. **Environment Configuration**:
- Uses `.env` file for secure storage of environment variables like database credentials.
## Setup Instructions And Infrastructure

### Prerequisites
- Python 3.7+
- Flask
- pip
### Installation
1. Clone the repository:
```bash
git clone
cd
```
2. Create a virtual environment and activate it:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. Install dependencies:
```bash
pip install -r requirements.txt
```
4. Set up the `.env` file with the following variables:
```env
DBUSER=
DBPASSWORD=
DBHOST=
DBNAME=
```
5. Run the application:
```bash
flask run
```
### Folder Structure
```plaintext
.
├── app
│ ├── __init__.py
│ ├── routes.py # Defines routing and API logic
│ ├── database.py # Handles database connections and queries
│ ├── models.py # Defines data models
│ ├── users.py # Handles user-related operations
│ ├── templates/ # HTML templates
│ └── static/ # Static files (CSS, images, JS)
├── .env # Environment variables
├── requirements.txt # Python dependencies
├── README.md # Project documentation
└── run.py # Entry point for the application
```
## API Endpoints
### User Routes
- `/` - Home page.
- `/aboutus` - About Us page.
- `/login` - User login.
- `/logout//` - User logout.
### Dashboard Routes
- `/overview//` - User overview page.
- `/device1//` - Device dashboard.
### Profile Management
- `/profile//` - User profile page.
- `/apisettings//` - API settings page.
### API Routes
- `/api//test` - Test API connection.
- `/api//listdevices` - List devices associated with an API key.
- `/api//deviceinfo/` - Retrieve specific device information.
- `/api//fieldstat/` - Get field statistics across devices.
- `/api//devicestat//` - Get field statistics for a specific device.
- `/api//update/` - Update device values.
## Example Usage
1. **Login**:
- Navigate to `/login` to authenticate.
2. **Dashboard**:
- After login, access your dashboard at `/overview//`.
3. **API Testing**:
- Use the `/api//test` endpoint to verify API connectivity.
4. **Device Information**:
- Retrieve a list of devices using `/api//listdevices`.
- Get details for a specific device at `/api//deviceinfo/`.
5. **Statistics**:
- Fetch field statistics with `/api//fieldstat/`.
- Get device-specific statistics at `/api//devicestat//`.
6. **Update Values**:
- Use `/api//update/` to push updates to device data.
## Contributing
1. Fork the repository.
2. Create a new branch:
```bash
git checkout -b feature/your-feature-name
```
3. Commit changes:
```bash
git commit -m "Add your message here"
```
4. Push to your branch:
```bash
git push origin feature/your-feature-name
```
5. Create a pull request.
## License
This project is licensed under the [MIT License](LICENSE).