Skip to content

A self-hosted web application designed to capture readings from my Xiaomi Mi Scale S400, save them in a database, and allow me to access the history from the web app and view the data graphically.

License

Notifications You must be signed in to change notification settings

bytevictor/byteFit

Repository files navigation

byteFit

A self-hosted web application designed to capture readings from my Xiaomi Mi Scale S400, save them in a database, and allow me to access the history from the web app and view the data graphically.

Features

  • MongoDB Database: Stores weight and body fat percentage readings with timestamps
  • Data Visualization: Beautiful charts showing weight and body fat trends over time using Recharts
  • Docker Support: Easy deployment with Docker and Docker Compose
  • Modern UI: Built with Next.js 16 and Tailwind CSS with dark mode support
  • Responsive Design: Works on desktop and mobile devices

Tech Stack

  • Frontend: Next.js 16, React 19, TypeScript, Tailwind CSS
  • Charts: Recharts (React charting library)
  • Database: MongoDB
  • Containerization: Docker, Docker Compose

Getting Started

Prerequisites

  • Node.js 22 or later
  • MongoDB (local or Docker)
  • npm

Local Development

  1. Clone the repository:

    git clone https://github.com/bytevictor/byteFit.git
    cd byteFit
  2. Install dependencies:

    npm install
  3. Create a .env file based on .env.example:

    cp .env.example .env
  4. Start MongoDB (if running locally):

    mongod
  5. Start the development server:

    npm run dev
  6. Open http://localhost:3000 in your browser.

Docker Deployment

  1. Build and start the containers:

    docker-compose up -d
  2. The application will be available at http://localhost:3000

  3. MongoDB will be accessible at localhost:27017

  4. Sample data is automatically loaded on first startup. The mongo-init/init-data.js script creates 31 sample readings (past 30 days) when the MongoDB container initializes for the first time.

    To reset the sample data, remove the MongoDB volume and restart:

    docker-compose down -v
    docker-compose up -d

Data Structure

Readings are stored in MongoDB with the following schema:

{
  _id: ObjectId,
  date: Date,           // Timestamp of the reading
  weight: number,       // Weight in kilograms
  bodyFatPercentage: number  // Body fat percentage
}

Adding Data

You can add readings directly to MongoDB using the MongoDB shell or a client like MongoDB Compass:

use bytefit

db.readings.insertOne({
  date: new Date(),
  weight: 75.5,
  bodyFatPercentage: 18.2
})

API Endpoints

GET /api/readings

Returns all readings sorted by date.

Response:

[
  {
    "_id": "...",
    "date": "2024-01-15T10:30:00.000Z",
    "weight": 75.5,
    "bodyFatPercentage": 18.2
  }
]

Environment Variables

Variable Description Default
MONGODB_URI MongoDB connection string mongodb://localhost:27017
MONGODB_DB Database name bytefit

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

About

A self-hosted web application designed to capture readings from my Xiaomi Mi Scale S400, save them in a database, and allow me to access the history from the web app and view the data graphically.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •