SecureLynk – Secure IoT Data Transmission Using Docker & Cloud



 SecureLynk – Secure IoT Data Transmission Using Docker & Cloud Introduction

The Internet of Things (IoT) is transforming how devices connect and exchange information. But as the volume of IoT data grows, so do the risks — unauthorized access, data tampering, and insecure communication channels.

SecureLynk is a hands-on project designed to demonstrate secure IoT data transmission using a three-tier Dockerized architecture. The system integrates three main components:

  1. IoT Simulator – generates and sends random IoT messages.

  2. Cloud Application – encrypts and stores messages securely.

  3. Receiver Dashboard – decrypts and displays messages for authorized users.

Each component runs in its own Docker container, communicating over a virtual network and sharing a common SQLite database. Lightweight encryption is achieved through a combination of XOR Cipher and Base64 Encoding, ensuring data confidentiality throughout the transmission process.

This tutorial walks you through how to set up and run SecureLynk from scratch.


 Step 1: System Overview

Before we start, here’s the overall structure of SecureLynk:

Module Container Name Function Exposed Port
IoT Simulator securelynk_iot_simulator Generates and sends random IoT data
Cloud Application securelynk_cloud_app Encrypts, stores, and visualizes IoT data 5000
Receiver Dashboard securelynk_receiver_app Authenticates users and decrypts their data 5001

All containers communicate through a shared volume (db_data) that holds the SQLite database file.


 Step 2: Software & Tools Used

Software / Tool Purpose / Function
Python 3.10 Core programming language for all modules
Flask Lightweight web framework for Cloud and Receiver dashboards
Docker Containerization tool for isolated deployments
Docker Compose Multi-container orchestration and volume sharing
SQLite3 Central database to store encrypted IoT messages
HTML, CSS, Bootstrap 5 Frontend design for dashboards
Chart.js Visualization of message statistics on Cloud Dashboard
Base64 Library (Python) Encodes/decodes encrypted data for safe transmission
Requests Library (Python) Sends HTTP POST requests from IoT Simulator
JSON Standard format for IoT data packets
Logging Library (Python) Monitors system events (data receipt, encryption, etc.)

 Step 3: Project Architecture

The SecureLynk system follows a 3-tier architecture:

  1. IoT Simulator (Data Generation Layer)

    • Generates random device data (device_id, receiver_id, message).

    • Sends JSON packets to the cloud server via HTTP POST.

  2. Cloud Application (Encryption & Storage Layer)

    • Receives IoT data.

    • Encrypts messages using XOR Cipher + Base64 Encoding.

    • Stores encrypted data in a shared SQLite database.

    • Displays analytics (message counts, charts) via Flask UI.

  3. Receiver Dashboard (Decryption & Visualization Layer)

    • Authenticates receiver ID.

    • Fetches relevant encrypted messages.

    • Decrypts and displays readable messages in a web dashboard.


 Step 4: Project Structure

After downloading or cloning the project, the directory should look like this:

securelynk/
│
├── cloud_app/
│   ├── app.py
│   ├── templates/
│   ├── Dockerfile
│
├── receiver_app/
│   ├── app.py
│   ├── templates/
│   ├── Dockerfile
│
├── iot_simulator/
│   ├── simulator.py
│   ├── Dockerfile
│
├── docker-compose.yml
└── README.md

 Step 5: Preparatory Steps

Before running the system:

  1. Inspect the repository structure to confirm all modules exist.

  2. Check Dockerfiles for required dependencies (Flask, requests, etc.).

  3. Open docker-compose.yml and verify container names, exposed ports, and the shared volume:

    volumes:
      - db_data:/data
    
  4. Ensure Docker and Docker Compose are installed on your machine.


 Step 6: Build and Run All Containers

Run the following command inside the project directory:

docker-compose up --build

This command:

  • Builds all three Docker images.

  • Creates containers for IoT Simulator, Cloud App, and Receiver Dashboard.

  • Mounts a shared volume (db_data) for the SQLite database.

Once complete, the services will be live at:


 Step 7: Container-Wise Setup and Verification

A. Cloud Application (securelynk_cloud_app)

Purpose: Receive IoT data, encrypt, and store securely.

  1. Navigate to cloud_app/app.py – this file implements the XOR + Base64 encryption.

  2. The database (messages.db) initializes automatically when the container starts.

  3. Check the logs to confirm database creation:

    docker logs securelynk_cloud_app
    
  4. Open the Cloud Dashboard in your browser to view:

    • Total message count

    • Receiver-wise statistics

    • Live data chart using Chart.js

Example URL:
http://localhost:5000


B. Receiver Dashboard (securelynk_receiver_app)

Purpose: Display decrypted IoT messages to authenticated receivers.

  1. Confirm the DATABASE_PATH in receiver_app/app.py points to /data/messages.db.

  2. Run the container and access the Receiver Dashboard:

    docker-compose up -d receiver_app
    
  3. Open the portal:
    http://localhost:5001

  4. Log in using a receiver ID (e.g., Receiver 997).

  5. View decrypted messages with metadata and timestamps.


C. IoT Simulator (securelynk_iot_simulator)

Purpose: Simulate IoT devices sending random messages to the cloud.

  1. Open iot_simulator/simulator.py.

  2. Ensure the environment variable in docker-compose.yml points to:

    environment:
      - CLOUD_URL=http://cloud_app:5000/api/data
    
  3. Start the simulator container:

    docker-compose up -d iot_simulator
    
  4. Monitor logs to verify successful message transmissions:

    docker logs -f securelynk_iot_simulator
    

    You should see responses like:
    POST /api/data → 201 Created


 Step 8: Common Commands

Action Command
Build and start all containers docker-compose up --build
Rebuild a single service docker-compose build cloud_app
Restart a service docker-compose restart receiver_app
View logs docker logs -f securelynk_cloud_app

 Step 9: Verification Checklist

 Cloud app dashboard is accessible at port 5000.
 Receiver app successfully decrypts messages.
 IoT simulator logs show HTTP 201 responses.
 Database messages.db contains encrypted records.
 Charts display correct message statistics.


 Step 10: Troubleshooting Tips

  • If containers can’t connect, ensure the simulator uses http://cloud_app:5000 (not localhost).

  • If the Receiver App can’t read messages, verify the /data volume is shared.

  • Rebuild containers after any code or template modification:

    docker-compose up --build -d
    
  • Check database permissions if errors occur on Linux:

    sudo chown $USER:$USER -R .
    

 Step 11: Conclusion

Through SecureLynk, we built a secure, cloud-integrated IoT data transmission system using Docker containers and lightweight encryption techniques.

The project demonstrated how to:

  • Simulate real-time IoT communication.

  • Encrypt and store IoT messages securely in a cloud environment.

  • Provide user-specific decryption through a web interface.

By combining Python, Flask, Docker, and SQLite, SecureLynk showcases a real-world model for secure IoT communication — modular, scalable, and easy to deploy.



Comments