How yaslopesyweb/iacai works
Project type and purpose
• This is a full-stack, monolithic web application combining a Vaadin-based UI (frontend) with a Spring Boot backend that integrates OpenAI’s GPT API for AI-driven chat.
• Purpose: Provide an intelligent chat assistant on the Acaiacá platform to help users interact, ask questions about sustainable agriculture, and receive context-aware answers.
File structure
• Top-level “frontend” folder: houses generated Flow/TypeScript/WebComponent code (Vaadin Flow client artifacts, JS/CSS, index.html, styles).
• “src/main/java/br/com/senac/ia”: backend code – IaApplication (entry point), IaService (OpenAI integration), views (Vaadin server-side UI classes like HomeView).
• Bundles (“src/main/bundles”): pre-packaged resources for production.
• Configuration files: application.properties, .env for OPENAI_API_KEY.
• Build scripts: mvnw (Maven wrapper), package.json & tsconfig.json (Node for building TS assets).
README
• Confirms use of Java 17+, Spring Boot 3.1, Vaadin 24+, CSS3, and OpenAI GPT.
• Provides functional overview: intelligent chat, conversation history, rapid response.
• Mentions MVC-style organization (config, controller, service, application class).
a. Client Layer
• Browser / User Agent – loads index.html, CSS, and WebComponents.
• Generated Vaadin Flow client code (TS/JS, Web Components under “frontend/generated”).
b. Server Layer
• Vaadin Flow / Spring Boot service – IaApplication as main, Vaadin views (HomeView), Spring controllers (if any), and business/service layer (IaService).
c. External Services
• OpenAI GPT API (calls from IaService over HTTPS).
d. Static Resources & Bundles
• Bundles folder and frontend static assets (JS bundles, CSS themes).
e. Build & Deployment
• Node.js/NPM for TS build, Maven for Java build, environment variables (.env), and application.properties.
Relationships & data flow
• Browser → HTTP(S) GET/POST → Spring Boot server (Vaadin servlet).
• Vaadin server serves dynamic HTML + Web Components + CSS.
• User actions in browser trigger RPC/WebSocket requests (Vaadin protocol) back to server.
• IaService in backend makes outbound HTTPS calls to OpenAI API, processes response.
• Server pushes UI updates to client via Vaadin push or page reload.
Architectural patterns & design principles
• Layered (Presentation → Business/Service → Integration)
• MVC-ish (Vaadin Views = Controllers+Templates, IaService = Model/business logic)
• External integration pattern (adapter to OpenAI API)
• Monolithic deployment (all components packaged and run together)
Technologies & frameworks to annotate
• Java 17+, Spring Boot 3.1, Vaadin 24 (Flow + Web Components)
• Node.js + TypeScript (frontend codegen)
• Maven (build & dependency management)
• OpenAI GPT HTTP API
• CSS3 (chat-theme.css)