Monitor App is a high-performance data monitoring and management application that automatically generates SQLite databases from CSV data and manages data through both Web UI and REST API.
π― Main Use Cases:
- Rapid CSV Data Visualization: Instantly create web apps and APIs by simply placing CSV files
- Quick Frontend for Existing DB Systems: Add Web UI and REST API to existing MySQL/PostgreSQL systems with just configuration changes
- Accelerated Prototype Development: Complete full-featured CRUD applications by just defining data structures
π§ Key Features:
- Comprehensive REST API: Full CRUD operations (Create, Read, Update, Delete) support
- Automatic API Documentation: FastAPI-like automatic documentation generation with Swagger UI (
/docs) - Separated Architecture: Clear separation between CRUD operation tables and display views
- Flexible View Display: Custom query-based data display (JOIN, aggregation, filtering, etc.), real-time updates (2-second intervals)
- Advanced Styling Features: Conditional cell styling based on values (color coding, font size, alignment)
- CORS Support: Easy integration with frontend applications
- Comprehensive Testing: Automated tests for REST API, Web UI, and all configurations
This project is inspired by Flask and Django, specifically built on Flask as the foundation.
Designed to be accessible for Python beginners and aimed at rapid web app development for manufacturing and data analysis tasks.
- Create new projects with
monitor-app startproject - Easy conversion of CSV data to SQLite
- Display and edit data through Web UI
- Support for SQLite / MySQL / PostgreSQL using
Flask-SQLAlchemy - Stylish UI using Bootstrap
- Customizable through
config.py - Automatic generation of full-featured REST API
- Real-time data update functionality
- Instant Web App from CSV: Complete full-featured web applications by simply placing CSV files
- Zero-Coding REST API: Automatically generate CRUD-capable REST APIs without programming
- Instant Integration with Existing Systems: Add web interfaces to existing MySQL/PostgreSQL databases with just configuration changes
- Multi-Database Support: Switch between SQLite (development/prototype) and MySQL/PostgreSQL (production) through configuration
- Customizable UI: Visual representation of data importance and status through conditional styling features
- JOIN Functionality: Integrated display of related data from multiple tables, intuitive understanding of complex data structures
- Non-Engineer Friendly: Anyone can manipulate data through the Web UI
- API Integration: Frontend teams can freely build UIs using REST APIs
- Real-time Updates: Always display the latest data even when multiple users work simultaneously
- Comprehensive Test Coverage: Automated tests for all API, UI, and configuration features
- Error Handling: Proper error handling for invalid data and operations
- CORS Support: Support for secure cross-origin communication
- Reduced Development Hours: Shorten development work from days/weeks to minutes
- Reduced Maintenance Costs: Long-term operation assured with Flask-based simple architecture
- Minimized Learning Costs: Designed to be accessible for Python beginners
Easy installation with pip install.
pip install monitor-appmonitor-app startproject <project_name>π Example: Create template with the name my_project
monitor-app startproject my_projectβ‘ Creates a Monitor-app application template in the my_project folder.
cd my_project
python <project_name>/app.py import-csvβ‘ Converts CSV files in the csv/ folder to SQLite database.
python <project_name>/app.py runserverβ‘ Access http://127.0.0.1:9990!
| Option | Description |
|---|---|
--csv |
Register CSV before starting |
--debug |
Start in debug mode |
--port <PORT> |
Specify port (default: 9990) |
π Example: Start after registering CSV
python <project_name>/app.py runserver --csvπ Example: Start in debug mode on port 8000
python <project_name>/app.py runserver --debug --port 8000my_project/
βββ monitor_app/
β βββ app.py # Main Flask application file
β βββ cli.py # Command file for template creation
β βββ csv_to_db.py # Script to import CSV to database
β βββ config/
β β βββ config.py # Configuration file
β βββ templates/ # HTML templates
β βββ static/ # CSS / JavaScript / Images
β βββ csv/ # Folder to store CSV data
β βββ instances/ # SQLite database storage location
βββ pyproject.toml # Poetry configuration file
βββ README.md # This fileAll project settings can be changed in config/config.py. The following are details of all configurable items.
# Specify the type of database to use
DB_TYPE = "sqlite" # "sqlite" | "mysql" | "postgresql"# Custom path settings for SQLite
CUSTOM_SQLITE_DB_PATH = None # Uses instances/database.db if None
# CUSTOM_SQLITE_DB_PATH = "/path/to/custom/database.db" # Custom path specification# Used when DB_TYPE = "mysql"
MYSQL_USER = "root"
MYSQL_PASSWORD = "password"
MYSQL_HOST = "localhost"
MYSQL_PORT = "3306"
MYSQL_DB = "monitor_app"# Used when DB_TYPE = "postgresql"
POSTGRES_USER = "postgres"
POSTGRES_PASSWORD = "password"
POSTGRES_HOST = "localhost"
POSTGRES_PORT = "5432"
POSTGRES_DB = "monitor_app"Monitor App clearly separates settings for CRUD operations and display purposes:
ALLOWED_TABLES: Table definitions for CRUD API operationsVIEW_TABLES: View definitions for screen displayTABLE_CELL_STYLES: Styling settings for view display
This separation maintains data operation security while achieving display flexibility.
ALLOWED_TABLES defines tables that can be CRUD operated via REST API. For security, tables not defined here cannot be accessed at all.
- Security: Prevent unauthorized table access
- Automatic REST API Generation: Automatically create CRUD APIs only for defined tables
- Input Validation: Column validation for POST/PUT requests
- Data Structure Definition: Management of primary key and foreign key information
ALLOWED_TABLES = {
"users": {
"columns": ["id", "name", "email"], # Columns for CRUD operations
"primary_key": "id" # Primary key
},
"products": {
"columns": ["id", "name", "price"],
"primary_key": "id"
},
"orders": {
"columns": ["id", "user_id", "product_id", "amount"],
"primary_key": "id",
"foreign_keys": {"user_id": "users.id", "product_id": "products.id"}
}
}VIEW_TABLES defines views exclusively for display on web screens. Complex JOINs, aggregations, filtering, etc. are possible.
- Display Only: No CRUD operations, only display
- Flexible Queries: Free description of JOINs, aggregations, subqueries, etc.
- Metadata Support: Setting titles and descriptions
- Column Name Control: Control display names through AS clauses
VIEW_TABLES = {
"users_view": {
"query": "SELECT id, name, email FROM users",
"title": "User List",
"description": "List of users registered in the system"
},
"products_view": {
"query": "SELECT id, name, price FROM products",
"title": "Product List",
"description": "List of products registered in the system"
},
"orders_summary": {
"query": """
SELECT
orders.id,
users.name AS user_name,
products.name AS product_name,
orders.amount
FROM orders
JOIN users ON orders.user_id = users.id
JOIN products ON orders.product_id = products.id
""",
"title": "Order Summary",
"description": "Detailed order list including user names and product names"
}
}VIEW_TABLES = {
"sales_summary": {
"query": """
SELECT
users.name as user_name,
COUNT(orders.id) as order_count,
SUM(orders.amount * products.price) as total_sales,
AVG(orders.amount * products.price) as avg_order_value
FROM users
LEFT JOIN orders ON users.id = orders.user_id
LEFT JOIN products ON orders.product_id = products.id
GROUP BY users.id, users.name
HAVING order_count > 0
ORDER BY total_sales DESC
""",
"title": "Sales Summary",
"description": "Order statistics and sales aggregation by user"
}
}TABLE_CELL_STYLES is an advanced feature that dynamically changes cell appearance based on values during view display. Applied only to views defined in VIEW_TABLES, using actual column names (names specified with AS clauses) as keys.
- View Only: Applied only to views defined in
VIEW_TABLES - Column Name Based: Use actual output column names from queries
- Stability: Design less affected by database column name changes
TABLE_CELL_STYLES = {
"view_name": {
"actual_column_name": { # Name specified with AS clause or original column name
# Conditional branching by value
"greater_than": {"value": number, "class": "CSS_class"},
"less_than": {"value": number, "class": "CSS_class"},
"equal_to": {"value": value, "class": "CSS_class"},
# Display style settings
"width": "width%",
"font_size": "sizepx",
"align": "alignment",
"bold": True/False
}
}
}TABLE_CELL_STYLES = {
"products_view": {
"price": { # Use actual column name
# Blue background for 1000 and above (high-price products)
"greater_than": {"value": 1000, "class": "bg-primary text-white"},
# Light blue background for under 500 (low-price products)
"less_than": {"value": 500, "class": "bg-info text-dark"},
# Gray background for exactly 750 (standard price)
"equal_to": {"value": 750, "class": "bg-secondary text-white"},
"width": "20%",
"align": "right",
"bold": False
}
},
"orders_summary": {
"amount": { # Original column name without AS clause
"greater_than": {"value": 10, "class": "bg-danger text-white"},
"less_than": {"value": 5, "class": "bg-warning text-dark"},
"equal_to": {"value": 7, "class": "bg-success text-white"},
"width": "15%",
"font_size": "32px",
"align": "center",
"bold": True
}
}
}TABLE_CELL_STYLES = {
"orders": {
"status": {
"equal_to": [
{"value": "Completed", "class": "bg-success text-white"},
{"value": "In Progress", "class": "bg-warning text-dark"},
{"value": "Cancelled", "class": "bg-danger text-white"},
{"value": "On Hold", "class": "bg-secondary text-white"}
]
}
}
}TABLE_CELL_STYLES = {
"sales": {
"amount": {
# Color coding by conditions
"greater_than": {"value": 1000000, "class": "bg-success text-white"},
"less_than": {"value": 100000, "class": "bg-danger text-white"},
# Display styles
"width": "20%", # Column width (CSS width)
"font_size": "24px", # Font size
"align": "right", # Text alignment
"bold": True # Make bold
}
}
}# Background color classes
"bg-primary" # Blue (important)
"bg-secondary" # Gray (normal)
"bg-success" # Green (success/complete)
"bg-danger" # Red (danger/error)
"bg-warning" # Yellow (warning/caution)
"bg-info" # Light blue (information)
"bg-light" # Light gray
"bg-dark" # Black
# Text color classes
"text-white" # White text (for dark backgrounds)
"text-dark" # Black text (for light backgrounds)
"text-primary" # Blue text
"text-success" # Green text
"text-danger" # Red text
"text-warning" # Yellow text
"text-info" # Light blue text
# Combination examples
"bg-success text-white" # Green background with white text
"bg-warning text-dark" # Yellow background with black text
"bg-danger text-white" # Red background with white text"align": "left" # Left align (default)
"align": "center" # Center align
"align": "right" # Right align (recommended for numbers)# Basic information
APP_TITLE = "Monitor App" # Browser title
HEADER_TEXT = "π Monitor Dashboard" # Page header
FOOTER_TEXT = "Β© 2025 Monitor App - Powered by Flask & Bootstrap" # Footer
FAVICON_PATH = "favicon.ico" # Favicon
# Operation settings
TABLE_REFRESH_INTERVAL = 2000 # Table auto-refresh interval (milliseconds)
SQLALCHEMY_TRACK_MODIFICATIONS = False # SQLAlchemy change tracking (usually False)# CSV file directory
CUSTOM_CSV_DIR = None # Uses project/csv/ if None
# CUSTOM_CSV_DIR = "/data/csv_files" # Custom directory specificationMonitor App provides REST APIs that support both database CRUD operations and view display.
FastAPI-like automatically generated documentation is available:
GET /docs- Interactive API documentation with Swagger UIGET /apispec_1.json- OpenAPI specification (JSON format)
GET /api/tables- Get schema information for all tables
GET /api/<table_name>- Get all records from tableGET /api/<table_name>/<id>- Get record with specified IDPOST /api/<table_name>- Create new recordPUT /api/<table_name>/<id>- Update record with specified IDDELETE /api/<table_name>/<id>- Delete record with specified ID
GET /api/table/<table_name>- Get raw table data (no style information)GET /api/view/<view_name>- Get view data (with style information)
# Check API specifications with Swagger UI
curl -X GET http://localhost:9990/docs
# Get API specifications in JSON format
curl -X GET http://localhost:9990/apispec_1.jsoncurl -X GET http://localhost:9990/api/tablescurl -X GET http://localhost:9990/api/userscurl -X POST http://localhost:9990/api/users \
-H "Content-Type: application/json" \
-d '{"name": "John Doe", "email": "john@example.com"}'curl -X PUT http://localhost:9990/api/users/1 \
-H "Content-Type: application/json" \
-d '{"name": "John Smith", "email": "john.updated@example.com"}'curl -X DELETE http://localhost:9990/api/users/1# Raw data without style information
curl -X GET http://localhost:9990/api/table/users# View data with style information
curl -X GET http://localhost:9990/api/view/users_view
# Get order summary view
curl -X GET http://localhost:9990/api/view/orders_summary{
"success": true,
"message": "Record created successfully",
"data": {
"id": 1,
"name": "John Doe",
"email": "john@example.com"
}
}{
"error": "Record not found"
}{
"view_name": "orders_summary",
"title": "Order Summary",
"description": "Detailed order list including user names and product names",
"columns": ["id", "user_name", "product_name", "amount"],
"data": [
{
"id": 1,
"user_name": "John Doe",
"product_name": "Apple",
"amount": 5
}
],
"cell_styles": {
"amount": {
"greater_than": {"value": 10, "class": "bg-danger text-white"},
"less_than": {"value": 5, "class": "bg-warning text-dark"},
"width": "15%",
"font_size": "32px",
"align": "center",
"bold": true
}
}
}- Only tables defined in
ALLOWED_TABLEScan be operated - Primary keys (usually
id) are set automatically, so no need to send in POST requests - For tables with foreign key constraints, verify the existence of related records before operations
- Only views defined in
VIEW_TABLESare accessible - View data is display-only (CRUD operations not possible)
- Style settings apply only to views defined in
TABLE_CELL_STYLES
- CRUD operations:
/api/<table_name>βALLOWED_TABLES - Display data:
/api/view/<view_name>βVIEW_TABLES+TABLE_CELL_STYLES - Raw data:
/api/table/<table_name>βALLOWED_TABLES(no styling)
Monitor App includes a comprehensive test suite that verifies REST API operations.
Tests require pytest (already installed in Poetry environments).
# Using Poetry
poetry install
# Using pip
pip install pytestpython -m pytest tests/test_api.py -v# User API tests only
python -m pytest tests/test_api.py::TestUsersAPI -v
# Product API tests only
python -m pytest tests/test_api.py::TestProductsAPI -v
# Error handling tests only
python -m pytest tests/test_api.py::TestErrorHandling -vpython -m pytest tests/test_api.py::TestUsersAPI::test_create_user -vGET /api/tables- Table schema retrieval
GET /api/users- Get all usersGET /api/users/<id>- Get specific userPOST /api/users- Create userPUT /api/users/<id>- Update userDELETE /api/users/<id>- Delete user- Error cases (non-existent user, invalid data)
GET /api/products- Get all productsPOST /api/products- Create productPUT /api/products/<id>- Update product
GET /api/orders- Get all ordersPOST /api/orders- Create order (with foreign key constraints)
- Access to non-existent tables
- Invalid JSON format requests
- Requests without Content-Type header
- Automatic removal of extra fields
- Foreign key constraint validation
$ python -m pytest tests/test_api.py -v
============================= test session starts ==============================
platform darwin -- Python 3.13.1, pytest-8.3.5, pluggy-1.5.0
collecting ... collected 20 items
tests/test_api.py::TestTableAPI::test_get_tables PASSED [ 5%]
tests/test_api.py::TestUsersAPI::test_get_all_users PASSED [ 10%]
tests/test_api.py::TestUsersAPI::test_get_user_by_id PASSED [ 15%]
tests/test_api.py::TestUsersAPI::test_get_user_not_found PASSED [ 20%]
tests/test_api.py::TestUsersAPI::test_create_user PASSED [ 25%]
...
============================== 20 passed in 0.95s ===========================If setting up CI/CD for your project, add the following commands to your build scripts:
# Run tests
python -m pytest tests/test_api.py
# Run tests with coverage report (optional)
pip install pytest-cov
python -m pytest tests/test_api.py --cov=monitor_app --cov-report=htmltests/test_api.py- REST API teststests/test_app.py- Web application teststests/test_config.py- Configuration tests
Comprehensive testing of REST APIs. Main contents:
-
TestTableAPI: Database table schema information retrieval API
GET /api/tablestesting (table list, column info, primary key verification)
-
TestUsersAPI: User management API
- Get all users, get specific user, create user, update, delete
- Error handling (non-existent user, invalid data)
-
TestProductsAPI: Product management API
- Product retrieval, creation, update functionality tests
-
TestOrdersAPI: Order management API
- Order retrieval, creation functionality (including foreign key constraint verification)
-
TestErrorHandling: Error handling
- Access to non-existent tables, invalid JSON, requests without Content-Type
-
TestDataValidation: Data validation
- Extra field removal, foreign key constraint tests
Tests basic web application functionality:
-
test_index_page: Root page (
/) display verification- Status code 200, "Monitor Dashboard" display verification
-
test_table_page: Table display page (
/table/users) operation verification- Allowed table display verification
Configuration file validation:
-
test_database_uri: Database connection setting verification
- SQLite/MySQL/PostgreSQL URI format checks
-
test_allowed_tables: Allowed table setting verification
- users, orders, products table setting verification
-
test_app_metadata: Application setting verification
- App title, header, footer text setting verification
| Command | Description |
|---|---|
monitor-app startproject <name> |
Create new project |
monitor-app import-csv |
Register CSV to database |
python <project_name>/app.py |
Start web application |
python <project_name>/app.py --csv |
Start after CSV registration |
python <project_name>/app.py --port <PORT> |
Start on specified port |
- Python 3.10+
Flask,Flask-SQLAlchemy,pandas,clickPoetry(development environment)
Provided under MIT License.
Pull Requests are welcome! π
Bug reports and improvement suggestions are also welcome!
π GitHub: Monitor App Repository
π Documentation:
- English: README.md
- ζ₯ζ¬θͺ: README_ja.md
β
Now you can easily install & use monitor-app! π