How vgamboa-sys/modelo_ia_proyecto_mineria works
Project Type and Purpose
• SafeMine AI is a full-stack, alert-generation application for mining safety.
• Backend (Python/FastAPI) ingests weather data, enriches it with Google Gemini AI, and persists alert records in a local SQLite database.
• Frontend (React + Vite) presents a dashboard of preventive daily safety alerts to end users.
File Structure Analysis
• Top-level:
• backend/ – the Python API service
• frontend/ – the React SPA
• README.md, requirements.txt for global context
• backend/app/:
• main.py – FastAPI app entry point
• routers/ – API endpoints (weather fetch, AI integration)
• database/db.py – DB connection layer (SQLite)
• schemas/ – Pydantic models for request/response
• .env – config for external API keys
• frontend/:
• src/ – React components (Dashboard, AlertCard, Filter, Header)
• index.html, vite.config.js – SPA hosting/config
• package.json – Node dependencies and scripts
README Insights
• Clearly defines the two main modules and tech stack:
• Frontend: React + Vite
• Backend: FastAPI + Python 3.13.5 + SQLite
• External services: OpenWeatherMap, Google Gemini
a. Main Components
1. User’s Browser / React SPA
2. FastAPI Backend Service
3. SQLite Database (local file)
4. External Weather API (OpenWeatherMap)
5. External AI Service (Google Gemini)
b. Relationships and Data Flows
• Backend → OpenWeatherMap API (fetch raw weather JSON)
• Backend → Google Gemini API (send weather data, receive analysis)
• Backend → SQLite (read/write alert records)
• Backend → Browser (response with processed alert payload)
c. Architectural Patterns
• Monolithic API with clear separation of routers (controllers), schemas (models), and database layer.
• SPA-API pattern: decoupled frontend and backend communicating via REST.
d. Key Technologies
• React + Vite (frontend build & dev server)
• FastAPI + Uvicorn (backend HTTP server)
• Pydantic schemas for data validation
• SQLite via SQLAlchemy or native driver
• OpenWeatherMap & Google Gemini external REST APIs