Skip to content

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

163 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏒 Sinhas GmbH β€” Property Data Management Portal

Python Flask MongoDB Pandas Render

A full-stack property data management system with a multi-user upload portal and a real-time admin dashboard β€” powered by Flask, MongoDB Atlas, and Chart.js.

Live Demo Β· GitHub Repo


πŸ“‹ Table of Contents


🌐 Overview

Sinhas GmbH is a web-based data management platform built for managing Swiss property (apartment) records. It provides two distinct interfaces:

  1. User Portal (/) β€” A clean, professional SaaS-style interface for data entry teams to upload Excel/CSV files in bulk, run structured ETL jobs, or manually enter individual property records directly into MongoDB.

  2. Admin Dashboard (/admin) β€” A real-time analytics and data management panel for administrators to view charts, browse all MongoDB collections, search/filter records, and perform inline edits.


✨ Features

πŸ“€ User Portal

Feature Description
Bulk Upload Upload any .xlsx or .csv file; each sheet becomes a MongoDB collection
Occupancy ETL Upload the master OCCUPANCY Excel file; auto-parses into structured cities, buildings, and apartments collections
Manual Entry Form-based single record insertion with all key property fields matching MongoDB schema
Drag & Drop Drag and drop files directly onto the upload zones

πŸ–₯️ Admin Dashboard

Feature Description
KPI Cards Real-time counts β€” Total Properties, Occupied, Available, Buildings
4 Live Charts Occupancy donut, Properties by City bar, System Overview bar, Apartments pie β€” all via Chart.js
Dynamic Sidebar Auto-fetches all MongoDB collections; click any to browse its data
Data Table Paginated, searchable table for any collection with configurable row limit
Load All Data One-click button to fetch all records from the active collection
Inline Edit Click "Edit" on any row to open a field-level modal and save changes to MongoDB

πŸ›  Tech Stack

Layer Technology
Backend Python 3.11, Flask 3.0
Database MongoDB Atlas (PyMongo 4.6)
Data Processing Pandas 2.2, OpenPyXL 3.1
Frontend Vanilla HTML, CSS, JavaScript
Charts Chart.js (CDN)
Server (Prod) Gunicorn 21.2
Deployment Render (via render.yaml)
Fonts Google Fonts β€” Inter

πŸ“ Project Structure

sinhasgmbh/
β”‚
β”œβ”€β”€ app.py                  # Flask application & all API routes
β”œβ”€β”€ index.html              # User Portal β€” upload & manual entry UI
β”œβ”€β”€ admin.html              # Admin Dashboard β€” charts, tables, edit modal
β”‚
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ render.yaml             # Render deployment configuration
β”œβ”€β”€ .env                    # Local environment variables (git-ignored)
β”œβ”€β”€ .gitignore
β”‚
β”œβ”€β”€ migrate_keys.py         # DB migration script (sanitizes field names)
β”œβ”€β”€ import_from_excel.py    # Standalone ETL script (CLI)
β”œβ”€β”€ upload_apartments.py    # CLI uploader for apartment records
β”œβ”€β”€ upload_flat.py          # CLI uploader for flat records
β”œβ”€β”€ analyze_excel.py        # Analysis/inspection utility for sheets
β”œβ”€β”€ test_mongo.py           # MongoDB connection test script
└── test_server.py          # Flask server endpoint test script

πŸš€ Getting Started

Prerequisites

  • Python 3.10+ installed
  • A MongoDB Atlas account with a cluster
  • Git

1. Clone the Repository

git clone https://github.com/deba2k5/sinhasrealty.git
cd sinhasrealty

2. Create & Activate a Virtual Environment

# Windows
python -m venv .venv
.venv\Scripts\activate

# macOS / Linux
python -m venv .venv
source .venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Set Up Environment Variables

Create a .env file in the project root:

MONGO_URI=mongodb+srv://<username>:<password>@<cluster>.mongodb.net/?appName=<app>

See Environment Variables for details.

5. Run Locally

python app.py

Open your browser at:

  • User Portal: http://localhost:5000/
  • Admin Dashboard: http://localhost:5000/admin

πŸ”‘ Environment Variables

Variable Required Description
MONGO_URI βœ… Yes Full MongoDB Atlas connection string with credentials

The app falls back to a default URI if MONGO_URI is not set, but it is strongly recommended to set it via .env for local development and via the hosting provider's environment settings for production.


πŸ“‘ API Reference

All API endpoints return JSON.

Upload Endpoints

Method Endpoint Description
POST /upload Bulk upload any Excel or CSV file to MongoDB
POST /upload_occupancy ETL upload β€” parses Occupancy Excel into Cities/Buildings/Apartments
POST /add_city Insert a single city record into the cities collection
POST /add_property Insert a single record into the database

Admin / Data Endpoints

Method Endpoint Description
GET /admin Serve the Admin Dashboard HTML page
GET /api/collections List all MongoDB collection names
GET /api/data/<collection> Paginated, searchable data from a collection
POST /api/update/<collection>/<doc_id> Update a single document by _id
GET /api/stats Aggregated stats for KPI cards and charts
GET /download_csv?collection=<name> Export any collection as a downloadable CSV

/api/data/<collection> Query Parameters

Param Type Default Description
page int 1 Page number
limit int 50 Records per page (9999 = load all)
search string "" Case-insensitive search across all string fields

☁️ Deployment (Render)

The project is pre-configured for Render via render.yaml.

Steps

  1. Push to GitHub

  2. Create a Render Account at render.com

  3. New Web Service β†’ Connect your GitHub repo deba2k5/sinhasrealty

  4. Render will auto-detect render.yaml. Confirm these settings:

    • Environment: Python
    • Build Command: pip install -r requirements.txt
    • Start Command: gunicorn app:app
  5. Add Environment Variable in the Render dashboard:

    • Key: MONGO_URI
    • Value: (your MongoDB Atlas connection string)
  6. Click "Deploy" β€” your app will be live at:

    https://sinhasgmbh.onrender.com
    

πŸ“Š Data Schema

Shared Records (migrated)

Field Type Description
Apartment Address String Street name of the apartment
City String City name
Floor Number Floor number
POSITION String Unit position (Left / Right / Center)
Apartment SQMT Number Apartment size in square meters
NO OF ROOMS Number Number of rooms (e.g. 3.5)
AWN NO Number Internal AWN reference number
INDIV / SHR String Occupancy type (Family / Sharing / Individual)
Status String Occupancy status (OCCUPIED / AVAILABLE)

πŸ‘€ Author

Debangshu β€” github.com/deba2k5


πŸ“„ License

This project is proprietary software developed for Sinhas GmbH. All rights reserved.


Built with ❀️ for Sinhas GmbH using Flask, MongoDB Atlas, and Chart.js

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages