jamesrutter / fablabOS

An set of systems of services for running a community fab lab (makerspace).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Project: fablabOS Author: James Rutter Start Date: Jan. 9, 2024

This is an ambitious project to build out a integrated set of systems and services to better improve the user experience at the Haystack Fab Lab. This design could be applied to other contexts, such as community makerspaces, university labs, fab labs, and communal studios. The goal is to utilize a series of open hardware devices, such as the RaspberryPi and Arduino to accomplish as much of the system as possible. This project will be open-source and shared and used as a learning opportunity for students of the Fab Lab.

Core Tech Stack

  • htmx this project is intended to utilize a hypermedia-driven approach, or HATEOS, and thus uses htmx for handling a large portion of the client-server data exchange. Most of the front-end is html with htmx attributes, which drive the interactivity and UI, additional scripting is added as necessary.
  • flask the backend technology is written using flask, a microframework for building web applications. Flask works nicely with HTMX as it has a server-side rendering engine built-in that utilizes Jinja2 templates. Thus, most of the front-end content is Jinja2 templates with HTMX attributed applied to HTML, these are all generated by Flask on the server and then sent to the client.

Python Dependencies

Flask alone is quite minimal, yet very capable. However, due to its philosophical approach being a microframework, there is an ecosystem of extensions that are designed to extend Flask's functionality. This allows the developer to add only and exactly that they need to get the job done, providing them to choose the right tool for the job. Below are the extensions that I have chosen for this project, but others may choose to explore their own solutions:

  • WTForms: provides a nice lightweight set of form validation tools for server-side validation.
  • SQLAlchemy: provides a robust toolkit for working with databases. This project is currently designed to run on a raspberry pi and run local on a Fab Lab's local network and thus just uses a SQlite database for persisting data. A variant of this project may explore using Postgres or MySQL if this system is used across multiple locations and organizations or is intended to be deployed as a cloud-service (SaaS).

Installing

git clone https://github.com/jamesrutter/fablabOS.git

Setting up Environment

To setup environment variables, you can utilize .env and .flaskenv files for configuring the application with sensitive keys and global settings. I used python-dotenv in order to work with environment variables for my local development setup, but will utimately use a linux/RaspberryPi based solution once this is deployed onto the pi. Here are the environment variables that you might consider using in your project:

FLASK_APP=<name_of_app.py>
FLASK_DEBUG=<1 | 0>
FLASK_CONFIG=<development | production>
SQLALCHEMY_DATABASE_URI=sqlite:///<db_name.db>
SECRET_KEY=<some_super_secret_key>

Requirements

pip install -r requirements.txt will install all the necessary dependencies for the project. Flask has its own set of dependencies, and I have chosen a couple to include here, which I have noted above.

Project Structure

  • /assets static files utilized for GUI/front-end. Currently has /images, /scripts, and /styles to organize these areas. Images and other media files could be stored on a remote S3 service for better performance (e.g., Supabase).
  • /api is a Flask instance and the primary engine for fablabOS: schedulr. Future development may require multiple Flask apps running in parallel on different ports to handle different tasks of fablabOS.
  • /data is where the database schema and sqlite db reside. Note: In the current implementation, the Flask instance (API) is generating its own db located in /instance, which is not being tracked and being used for development purposes.

Database

Before starting a project, you need to initialize the database. For more information about the database schema, please refer to api.models module which has the class definitions of the tables and related object-models used throughout the application. If you plan to modify the data schema, you should do so in this file and before initializing the database. For setting up the database, please refer to the api.database module. This has two useful functions that can be called from within the Flask shell: init_db which initializes the databased based on the models and seed_db which is an optional helper utility to load mock data into the application so that you can begin using and see how things work. Please note: if you customize your own data schema and modify the models, seed_db will most likely break and cause a SQLAlchemy exception. It should be straightforward to modify seed_db in order to match the model of your data.

Server

To start running the application on the server:

  • flask run --debug OR
  • flask --app api run

Application Usage Overview

There are four primary resources used in the application:

  1. Users - This application is intended to be entirely user-driven and meant to be a convienance for both users and managers of Fab Lab type environments and spaces. Therefore, Users are an import resource within the app, and have the following attributes, methods, and relationships:
    1. id - unique identifer for database management
    2. username - a human-friendly reference to the user, will be automatically constructed based on registration and should be unique across the database.
    3. email - required, and the primary method of communication used to interact with the user outside of the application. unique across the database.
    4. firstname - first name of user (optional)
    5. lastname - last name of user (optional)
    6. password - login password used for authentication, password is encrypted and only the password hash is stored on the server.
    7. role - the level of access and control for the user, see Roles section for more information on how role-based access is handled in the application.
    8. reservations - a collection of past and future reservations in the lab for tracking access and manging the schedule.
  2. Roles - roles are the primary way to handle access and control within the application and also within the context of the lab. For instance, guest accounts do not have access to reserve time in the lab but can view the schedule and be added to a reservation from a user with a higher access.
    1. guest - default and entry level user role. has view-only privlidges within the system.
    2. user - an active user of the lab who has been cleared to reserve time, upgrading a guest to user should initatie a payment or queue a future payment upon checkout to pay for access to the lab (Note: this is a specific feature that Haystack has implmeneted, and is not required for other spaces to use if using this software).
    3. tech or manager - allows for managing and creating reservations.
    4. staff - a variant of user but with no billing account since staff gain access for free, other optional privledges can be added depending on the lab context.
    5. admin - full access and control of the application, be careful with assigning users to this role as they can do destructive operations on the system (e.g., wiping the database of reservations).
  3. Permissions

Feature List

A resource management system for makerspaces and Fab Labs.

Access Control System

An RFID or NFC reader system to control access to certain areas or machines. Members could use RFID tags or cards to gain access. While machine access controls is not all that interested, it could be useful in other contexts within a lab and makes for an interesting technical challenge. RFID/NFC-based systems could be utilized within community spaces in other ways.

  • Priority Level: 4/10

Scheduling System: Equipment Booking & Reservations

Develop a web-interface (UI) to run on an installed kiosk computer or tablet to allow lab users to reserve and book time on equipment in the space.

Equipment Stats and Logs

Record equipment and resource usage and provide a dashboard to review analytics.

Inventory Management System

Implement an inventory management system for tools and supplies. A barcode scanner could be used and then connected to Haystack's Lightspeed API to add and track chargers to student accounts. This same system could be used to log and report bugs and issues with equipment, log maintenance tasks, and notes for future users.

Environment Monitoring

  • Cameras to inspect machines for safety, general security or live-stream camera for project timelapses.
  • Use sensors with Raspberry Pi to monitor environmental conditions like temperature, humidity, or air quality, ensuring a comfortable and safe workspace.

Environment Feedback & Notifications

  • Control lights, speakers, and other output devices based on environmental conditions or other external factors.

Networked Notification System:

Set up a system where Raspberry Pis can display notifications or messages on screens around the space, useful for announcing events, closures, or equipment status.

Backup System

  • Backup all critical data and system information to remote server.

Interactive Learning Stations

Set up stations with Raspberry Pis where participants can engage in self-guided learning, like programming tutorials, electronics basics, or 3D modeling.

Digital Signage and Information Kiosks

  • Use Raspberry Pis to power digital signs or kiosks providing information about the makerspace, upcoming workshops, or project ideas.
  • priortiy: 9/10

Custom Project Showcase

Set up screens where members can showcase their projects or documentations, possibly with interactive elements powered by Raspberry Pis.

Software Tooling

fabMods

fab mods are a community developed set of tools to generate machine code for machines. Currently the UI is lacking and there is not a lot of documentation. This could be incorporated as part of this project, or forked and a new version developed altogether.

Goals

  • Collaborative open-source development. A goal of this project is to attract and collaborate with other Fab Lab network makers who are interested in working and developing such a project.

Technology Stack

  • Backend: Python (Flask)
  • Database: SQLite
  • Frontend:

API Design

User Endpoints

  • GET /api/users: Retrieve a list of users.
  • POST /api/users: Create a new user.
  • GET /api/users/{userid}: Retrieve a detailed view of a specific user.
  • PUT /api/users/{userid}: Update a specific user's details.
  • DELETE /api/users/{userid}: Remove a user.

Equipment Endpoints

  • GET /api/equipment: List all equipment.
  • POST /api/equipment: Add new equipment.
  • GET /api/equipment/{equipmentid}: Get details for a piece of equipment.
  • PUT /api/equipment/{equipmentid}: Update equipment details.
  • DELETE /api/equipment/{equipmentid}: Remove equipment from the database.

Reservation Endpoints

  • GET /api/reservations: List all reservations.
  • POST /api/reservations: Create a new reservation.
  • GET /api/reservations/{reservationid}: View details of a reservation.
  • PUT /api/reservations/{reservationid}: Modify a reservation.
  • DELETE /api/reservations/{reservationid}: Cancel a reservation.

UI Design

Views

  • Login/Registration Page
  • Dashboard
  • Equipment Catalog
  • Equipment Detail Page
  • Reservation System
  • User Profiles
  • Admin Panel

UI Requirements

  • resonsive design (mobile friendly)
  • high quality user experience
  • accessibility
  • high quality user interface and design

Features

About

An set of systems of services for running a community fab lab (makerspace).


Languages

Language:Python 67.6%Language:HTML 31.2%Language:JavaScript 0.9%Language:CSS 0.3%