Skip to main content
Glama
README.md
# BIM Electrical MCP

BIM Electrical MCP is a Python-based application for processing electrical BIM data from DXF and Revit-style JSON files, sanitizing and storing the extracted information in a Supabase database, and enabling AI-assisted querying through a conversational assistant.

The project is designed to help teams manage and analyze electrical design data more efficiently by combining file processing, structured storage, and intelligent chat-based interaction.

## Key Features

- Upload and process DXF and JSON BIM files
- Extract electrical components and related metadata
- Sanitize and redact sensitive or non-essential information before storage
- Store processed data in Supabase using a structured schema
- Query data through an AI-powered Electrical Chat Assistant powered by Google Gemini
- Support a modular architecture for future integrations and extensions

## Tech Stack

- Python
- Streamlit
- Supabase
- Google Gemini API
- Additional libraries such as ezdxf, pandas, pydantic, python-dotenv, and pytest

## Project Structure

```text
.
├── app.py                     # Main Streamlit application entry point
├── requirements.txt          # Python dependencies
├── .env.example              # Example environment configuration template
├── src/
│   ├── agent/                # AI assistant integration logic
│   ├── db/                   # Supabase client and SQL schema
│   ├── extractors/           # DXF and JSON extraction logic
│   ├── mcp_server/           # MCP server-related components
│   ├── sanitizer/            # Data sanitization/redaction utilities
│   └── ui/                   # Pipeline and UI orchestration helpers
├── tests/                    # Unit and integration tests
└── TDD.md                    # Development/testing notes
```

## Getting Started

### 1. Clone the repository

```bash
git clone <your-repository-url>
cd bim-electrical-mcp
```

### 2. Create and activate a virtual environment

On Windows:

```bash
python -m venv venv
venv\Scripts\activate
```

On macOS/Linux:

```bash
python3 -m venv venv
source venv/bin/activate
```

### 3. Install dependencies

```bash
pip install -r requirements.txt
```

### 4. Configure environment variables

Create a `.env` file in the project root by copying the example template:

```bash
copy .env.example .env
```

Or on macOS/Linux:

```bash
cp .env.example .env
```

Then update the values in `.env` with your own generic configuration. The file should include the required Supabase and Google Gemini settings, for example:

```env
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_KEY=your-service-key
GOOGLE_API_KEY=your-google-api-key
GOOGLE_PROJECT_ID=your-google-project-id
GOOGLE_LOCATION=global
```

> Keep credentials and sensitive values private and never commit the `.env` file to a public repository.

## Database Setup

This project uses Supabase as its data store. After creating a Supabase project:

1. Open the SQL Editor in Supabase.
2. Execute the SQL from [src/db/schema.sql](src/db/schema.sql).
3. Ensure the required PostgreSQL extensions are available, including `vector` and `pgcrypto`.

The schema creates the core tables used by the application, including `components` and `connections`.

## Running the Application

Start the Streamlit app with:

```bash
streamlit run app.py
```

Then open the local Streamlit URL in your browser to upload files, process BIM data, and interact with the assistant.

## Testing

To run the test suite:

```bash
pytest
```

## License

This project is intended for educational, internal, or open-source use. Please review and adjust licensing terms as needed before distribution.