How georetina/chat2geo works
Main Components
• Frontend: The UI is built in Next.js using React components. The “app” directory is organized into sections such as (auth), (broadcast), and (main). Each section contains layouts, pages, and API routes. Additionally, there is a “components” folder and specific feature folders (e.g., features/chat, features/maps, features/knowledge-base, features/user-profile, and so on).
• Backend/API: Many API endpoints are defined within the “app” subdirectories. These API routes handle authentication, geospatial analyses (e.g., chat, gee, google-maps-related endpoints), data fetching, and integration with external services.
• Geospatial Processing: The integration with Google Earth Engine (GEE) for remote-sensing analyses is a primary backend capability. There are also helper functions in “lib/geospatial” that perform various analyses (urban heat island, land cover mapping, pollution analysis, etc.).
• External Services & Integrations:
• Google Cloud Platform services (Google Earth Engine and Vertex AI).
• Supabase for database and authentication.
• Google Maps API and Esri integration endpoints.
• Additional external libraries and APIs (OpenAI ChatGPT API, LangChain for RAG, Maplibre GL for maps, Turf for spatial operations).
Relationships and Interactions
• User Interface (React components, pages) makes API calls (using Next.js API routes) to the backend.
• Authentication flows: There is a dedicated (auth) module handling login, confirm flows, and Esri-specific OAuth workflows.
• Knowledge Base/RAG: Integration for the retrieval-augmented generation is managed within related “features/knowledge-base” components and supported by custom configurations and actions.
• Database and Authentication: Supabase is integrated for storing chat histories, user profiles, usage metrics, and document uploads (knowledge base documents) as indicated by the “db-schema” folder and environment variable guidelines.
• External Data and Processing: The backend orchestrates interactions with GEE for heavy geospatial computations, forwarding the results to the chat interface and map components.
Architectural Patterns & Principles
• Modular & Feature-driven Design: The project is organized in a feature-first style with separate folders for each domain (e.g., chat, maps, knowledge base), facilitating clear boundaries.
• Serverless/API Routes: Next.js API routes are used to expose backend functionalities.
• Integration and Loose Coupling: The system decouples its frontend rendering from backend processing (e.g., calling external APIs, GEE analysis) to allow scalable deployment.
• Extensibility: The rich usage of custom configurations (custom-configs) and utility functions (lib, utils) suggest an architecture designed for further extensions (like adding new geospatial analyses).
a. Main Components:
• User Interface (Front-end): Displaying chat interfaces, map views, user profile modals, and integration pages.
• API Gateway / Next.js API Routes: Split into categories (Authentication, Chat, Geospatial analysis, and Feedback/Services).
• Geospatial Analysis Engine: Google Earth Engine integration, including sub-components for various analyses (UHI, land cover, air pollution analysis).
• External Integrations: Connectors to Supabase (database & auth), Google Maps / Esri, Vertex AI, OpenAI, and additional external services.
• Supporting components: Utility libraries and feature branches (knowledge base, text editor, file/document management).
b. Relationships & Interactions:
• Bi-directional interactions where needed; for example, the user’s interactions affect map updates and chat responses.
• That the configuration and utility libraries underpin both UI and API functionalities.
c. Technologies and Their Placement:
• Next.js as the front-end framework & server-side rendering.
• Google Cloud products (GEE, Vertex AI, Cloud Run) as processing services.
• Supabase as a database/authentication layer.
• Additional integration modules for Google Maps, Esri, and OpenAI.