Skip to content

Miccolomi/AretiAsset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Areti Asset Monitoring System

🇮🇹 Versione italiana

Geolocated asset monitoring system built on MongoDB, showcasing Schema-less capabilities and native TimeSeries collections.

Areti MongoDB React

🎯 Demo Goals

This application demonstrates:

  1. Schema-less MongoDB: insert arbitrary fields without altering the schema
  2. Native TimeSeries: collections optimized for temporal data
  3. Geospatial queries: search assets by geographic proximity
  4. Premium UI/UX: design inspired by Areti.it with institutional colors

🏗️ Architecture

Backend

Important

CRITICAL CONFIGURATION: the Asset model MUST keep strict: false to enable schema-less features. Do not remove this setting!

  • Node.js + Express
  • Mongoose with { strict: false } for schema-less
  • RESTful API for assets and telemetry
  • 2dsphere geospatial indexes

Frontend

  • React + Vite
  • Tailwind CSS with Areti palette
  • Leaflet.js for interactive maps
  • Recharts for TimeSeries visualization

Database

  • Asset collection (hybrid): base schema + dynamic fields
  • Telemetry collection (TimeSeries): optimized temporal data

🚀 Setup & Run

Prerequisites

  • Node.js 18+
  • MongoDB 6.0+ running locally (or an Atlas connection string)

Installation

# Clone the repository
git clone https://github.com/Miccolomi/AretiAsset.git
cd AretiAsset

# Configure backend environment
cp backend/.env.example backend/.env
# Edit backend/.env with your MongoDB URI (default: mongodb://localhost:27017/areti-assets)

# Install backend dependencies
cd backend
npm install

# Install frontend dependencies
cd ../frontend
npm install

Seed demo data

From the backend/ folder, run the seed script that creates 30 synthetic assets + 5,400 TimeSeries telemetry records:

cd backend
node scripts/seed.js

Quick start

Use the automated startup script:

chmod +x start.sh
./start.sh

Or start manually:

# Terminal 1 - Backend
cd backend
npm start

# Terminal 2 - Frontend
cd frontend
npm run dev

Access

📡 API Endpoints

Assets

Method Endpoint Description
GET /api/assets List all assets
GET /api/assets/:id Single asset detail
POST /api/assets Create new asset (with schema-less fields)
GET /api/assets/nearby/:lng/:lat/:distance Nearby assets (distance in meters)

Telemetry

Method Endpoint Description
GET /api/telemetry/:assetId Historical data for an asset
POST /api/telemetry Insert telemetry record
POST /api/telemetry/bulk Generate demo data

💡 Schema-less: the trick of the demo

Backend (Mongoose)

const assetSchema = new Schema({
  nome: String,
  dataInstallazione: Date,
  stato: String,
  posizione: GeoJSON
}, {
  strict: false  // MAGIC! Allows undefined fields
});

Frontend (input)

The UI lets users add dynamic key-value pairs:

Extra fields:
┌──────────────┬──────────┐
│ tensione     │ 20kV     │
│ potenza      │ 5MVA     │
│ numeroSerie  │ ABC123   │
└──────────────┴──────────┘

Smart display

The AssetCard component excludes standard fields and shows all the others:

const standardFields = ['_id', 'nome', 'stato', 'posizione'];
const schemalessFields = Object.entries(asset)
  .filter(([key]) => !standardFields.includes(key));

🎨 Areti design

Color palette

  • Institutional blue: #003366 — header, sidebar, primary elements
  • Energy yellow: #FFD700 — accents, highlights, CTAs
  • Font: Inter (Google Fonts)

UI components

  1. Header: blue gradient with Areti logo
  2. Sidebar: navigation with Lucide icons
  3. Map: Leaflet with custom markers
  4. Card: premium design with gradients
  5. Form: rounded fields, live validation

📊 MongoDB TimeSeries

The telemetry collection uses the native TimeSeries type:

{
  timeseries: {
    timeField: 'timestamp',
    metaField: 'metadata',
    granularity: 'minutes'
  }
}

Benefits:

  • Automatic compression
  • Optimized temporal queries
  • High-performance aggregations

🗺️ Geospatial features

2dsphere index

assetSchema.index({ posizione: '2dsphere' });

Proximity query

// Find assets within 5000 meters
GET /api/assets/nearby/12.4964/41.9028/5000

🎬 Demo flow

  1. Add an asset:

    • Fill in the base fields
    • Click on the map to set coordinates
    • Add extra fields: "Tensione" → "20kV", "Potenza" → "5MVA"
    • Submit
  2. View on map:

    • See the marker on the Rome map
    • Click the marker → card with ALL fields (extras included)
  3. TimeSeries analysis:

    • Select an asset
    • Generate 50 demo data points
    • View the Recharts chart
    • Insert telemetry with extra fields

📁 Project structure

AretiAsset/
├── backend/
│   ├── models/
│   │   ├── Asset.js       # Schema with strict: false
│   │   └── Telemetry.js   # TimeSeries collection
│   ├── routes/
│   │   ├── assets.js      # CRUD + geospatial
│   │   └── telemetry.js   # TimeSeries API
│   ├── scripts/
│   │   └── seed.js        # Seed demo data
│   ├── server.js          # Express app
│   └── package.json
├── frontend/
│   ├── src/
│   │   ├── components/
│   │   │   ├── Header.jsx
│   │   │   ├── Sidebar.jsx
│   │   │   ├── MapView.jsx         # Leaflet map
│   │   │   ├── AssetCard.jsx       # Schema-less display
│   │   │   ├── AssetForm.jsx       # Dynamic fields
│   │   │   └── TimeSeriesView.jsx  # Recharts
│   │   ├── App.jsx
│   │   └── api.js
│   ├── tailwind.config.js  # Areti colors
│   └── package.json
├── start.sh                # Startup script
├── README.md               # English (this file)
└── README.it.md            # Italian version

🔍 MongoDB checks

Schema-less verification

db.assets.findOne()
// Output shows different fields per document!

TimeSeries verification

db.getCollectionInfos({ name: "telemetries" })
// type: "timeseries"

🎓 Key takeaways for the demo

  1. Flexibility: each asset can carry different fields
  2. No migrations: add fields without ALTER TABLE
  3. Performance: TimeSeries optimized for IoT/telemetry
  4. Geospatial: complex queries in milliseconds
  5. UI/UX: professional Areti-branded design

📝 Notes

  • Authentication: not implemented (demo only)
  • Validation: basic, extendable for production
  • MongoDB URI: configurable in .env

🤝 Contact

System developed for MongoDB POV demonstrations focused on schema-less and native TimeSeries.


Powered by MongoDB Atlas & Node.js 🍃

About

demo mongoDB areti

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages