How reearth/reearth-visualizer works
This project is a full‐stack GIS visualization platform (Re:Earth Visualizer) that combines a modern Go-based backend with a rich React/TypeScript frontend. Its purpose is to display and let users interact with spatial data via Cesium and other WebGIS technologies, while also supporting features like interactive geometry editing, conditional layer styling, storytelling, and an extensible plugin system.
Main Components
• Frontend (Web): Located in the “web” directory, this is built with React and TypeScript. It handles user interactions, renders the GIS map (using Cesium) and storytelling features, and integrates with plugins through dedicated modules.
• Backend (Server): The “server” directory contains Go code that implements the GraphQL API, handles business logic, authentication, file handling, integration with databases and external services, and supports real-time operations.
• Database & Persistence: The infrastructure (notably under server/internal/infrastructure/mongo and other storage-related packages) indicates that MongoDB is used, possibly with additional support for file storage (e.g., GCS, S3).
• Plugin System & WebAssembly: The project features a plugin system (visible in directories like “server/pkg/plugin” and “web” components handling plugin UI) and uses WebAssembly for executing plugins. This shows extensibility thinking and a clear separation of plugin-related functionalities.
• External Services & API Gateways: This includes authentication (mock auth and possible integrations like Auth0), Cesium Ion token integration for map rendering, and connections with external APIs (GraphQL endpoints, marketplace).
• DevOps and CI/CD: The repository’s .github/workflows and Docker/Docker-compose files indicate continuous integration, deployment scripts, and containerized services.
• Shared Libraries & Utilities: The “pkg”, “internal/usecase”, “services”, and “lib” directories for both server and web provide reusable logic for internationalization (i18n), authentication, error handling, theming and UI components.
Relationships and Data Flow
• The Frontend connects to the Backend via GraphQL and REST API endpoints for data (assets, properties, projects, etc.) and also loads plugins (using WebAssembly and dedicated endpoints).
• The Backend communicates with the database (MongoDB) for storing GIS data, projects, users and runs migrations and other business logic.
• External services (Cesium Ion, authentication providers) are integrated into the flow, with the backend providing necessary configuration details to the frontend.
• The plugin system acts as an extension module whereby plugins (developed externally or in-house) can be dynamically deployed and interact with the API.
Architectural Patterns & Key Design Principles
• Separation of Concerns:
– Frontend vs. Backend separation is clear.
– Domain logic is separated into use cases, repositories, and adapters (as seen in the “server/internal/usecase” and “server/internal/adapter”).
• Microservice-ish Modularization:
– Although not strictly microservices, the code organization in “internal/infrastructure” and “internal/app” suggests a modular organization.
• Extensibility:
– The plugin system is architected to allow integration via WebAssembly and dedicated plugin packages.
• CI/CD and containerization:
– Docker, Makefiles, and GitHub workflows attest to automated builds, tests, and deployment pipelines.
Technologies and Frameworks
• Frontend: React, TypeScript, Yarn; uses libraries such as Cesium for 3D mapping and other UI frameworks.
• Backend: Go, GraphQL server (using gqlgen), and integrations with MongoDB.
• Authentication: Built-in mock auth with the possibility for OpenID Connect or Auth0.
• Testing and Deployment: Docker Compose for environment setup; CI/CD pipelines defined in .github/workflows.