From c5cd0494adee06730400f95533a473737bcc4a3f Mon Sep 17 00:00:00 2001 From: Miguel Date: Tue, 26 Aug 2025 11:22:42 +0200 Subject: [PATCH] Update routing in App component and adjust CORS settings in main.py; add project overview documentation --- GEMINI.md | 59 +++++++++++++++++++++++++++++++++++++++++++ frontend/src/App.jsx | 2 +- frontend/src/main.jsx | 2 +- main.py | 4 +-- 4 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 GEMINI.md diff --git a/GEMINI.md b/GEMINI.md new file mode 100644 index 0000000..c8c9d63 --- /dev/null +++ b/GEMINI.md @@ -0,0 +1,59 @@ +# Project Overview + +This project is a web-based application for monitoring and logging data from a Siemens S7 PLC. It consists of a Python backend and a React frontend. + +**Backend:** + +* **Framework:** Flask +* **PLC Communication:** `python-snap7` +* **Data Processing:** pandas, numpy +* **Functionality:** + * Provides a REST API for interacting with the PLC. + * Streams data from the PLC in real-time. + * Logs data to CSV files with rotation and cleanup. + * Manages PLC and application configurations. + * Serves the React frontend. + +**Frontend:** + +* **Framework:** React +* **Build Tool:** Vite +* **UI Library:** Chakra UI +* **Charting:** Chart.js +* **Internationalization:** i18next +* **Functionality:** + * Provides a user interface for configuring the PLC connection and data logging. + * Displays real-time data from the PLC in charts. + * Allows browsing and visualizing historical data. + +# Building and Running + +**1. Install Dependencies:** + +* **Backend:** `pip install -r requirements.txt` +* **Frontend:** `cd frontend && npm install` + +**2. Build the Frontend:** + +```bash +cd frontend && npm run build +``` + +**3. Run the Application:** + +* **Development:** + 1. Start the backend: `python main.py` + 2. Start the frontend dev server: `cd frontend && npm run dev` +* **Production (standalone executable):** + 1. Build the frontend as described above. + 2. Clean previous builds: `rmdir /s /q build dist` + 3. Run PyInstaller: `conda activate snap7v12; pyinstaller main.spec --clean` + +The production build will create a single executable file in the `dist` directory. + +# Development Conventions + +* The backend follows a modular structure with a `core` directory containing the main application logic. +* The frontend is located in the `frontend` directory and follows standard React project conventions. +* Configuration is managed through JSON files in the `config/data` directory. +* The application uses a rotating logger system for the backend, with logs stored in the `.logs` directory. diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index d1c52a7..aea59fe 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -26,7 +26,7 @@ function Home() { Acciones rĂ¡pidas - + diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx index 989926f..4c5f40c 100644 --- a/frontend/src/main.jsx +++ b/frontend/src/main.jsx @@ -15,7 +15,7 @@ createRoot(document.getElementById('root')).render( - + diff --git a/main.py b/main.py index f74d648..c0582ad 100644 --- a/main.py +++ b/main.py @@ -121,8 +121,8 @@ CORS( resources={ r"/api/*": { "origins": [ - "http://localhost:5173/app", - "http://127.0.0.1:5173/app", + "http://localhost:5173", + "http://127.0.0.1:5173", "*", ] }