How devfullcycle/imersao12 works
1. This repository is a small multi-service system, not a single app. It contains three runnable products — a Go simulator, a NestJS API, and a React frontend — plus Kafka and Kubernetes deployment assets.
2. The React frontend (react-frontend) is the user-facing entrypoint. Its structure suggests a map-based UI: Mapping.tsx, Navbar.tsx, util/geolocation.ts, util/map.ts, and util/models.ts indicate browser geolocation, map rendering, and route visualization. route-exists.error.ts implies the UI handles route-creation conflicts or validation feedback from the backend.
3. The NestJS backend (nest-api) is the domain/API layer. It is organized around a single routes feature module with controller, service, DTOs, entity, and a gateway. That indicates a classic Nest structure with:
- HTTP endpoints for route CRUD/commands
- a WebSocket gateway for realtime updates
- a persistence model centered on a Route entity
4. The backend likely owns the system’s authoritative route state. The presence of .docker/mongo/init.js and Mongo-specific Docker assets strongly suggests MongoDB is the persistence boundary for the API. The API is packaged independently with both development and production Dockerfiles.
5. The simulator (simulator) is a separate Go service that produces movement or destination events. Its structure splits into application/route, application/kafka, and infra/kafka, which shows a clean separation between business behavior and Kafka plumbing. The destinations/*.txt files suggest the simulator reads predefined coordinate or destination sequences and emits them as streaming events.
6. Kafka is the asynchronous integration backbone. The apache-kafka directory contains Kafka compose setup and a Kafka Connect Elasticsearch connector configuration, so the repository is prepared for event streaming plus sink export to Elasticsearch. In architecture terms, Kafka is the decoupling layer between the simulator and downstream consumers.
7. The system’s main data flow is likely:
- user interacts with the React UI
- UI calls the NestJS API to create/query routes
- simulator emits route/destination events into Kafka
- backend and/or Kafka Connect consume those events for realtime updates or indexing
- frontend reflects updates via API/WebSocket data
The gateway in the backend is the main hint that live updates are pushed rather than polled.
8. Kubernetes manifests under k8s/ show production-style deployment boundaries for backend, frontend, and simulator, each with its own deploy.yaml and service.yaml, and some with configmap.yaml. That means each service is independently deployable and configurable, with environment-specific settings externalized from the containers.
9. Local development is container-first across the repo. Each major app has Docker assets and a docker-compose.yaml, so the intended workflow is to run the stack as multiple containers rather than as one monolith. This also reinforces the service boundaries: UI, API, simulator, Kafka, and Mongo are separate runtime units.
10. The main architectural boundaries to draw are:
- browser UI boundary: React app
- synchronous API boundary: NestJS HTTP endpoints
- realtime boundary: NestJS gateway / WebSocket path
- persistence boundary: MongoDB for route data
- streaming boundary: Kafka for simulated route events
- deployment boundary: Docker/Kubernetes per service
The repo is essentially a microservices/event-driven demo centered on route tracking and live movement visualization.
Main entry points: routes.module.ts Routes module · Mapping.tsx Mapping · App.tsx App · routes.service.ts Routes service
Components 26
React frontend
Browser UI for map-based route viewing and interaction.
- App · Frontend composition root and app wiring.
react-frontend/src/App.tsx - Mapping · Primary map-based route visualization and interaction screen.
react-frontend/src/components/Mapping.tsx - Navbar · Top-level navigation and user controls.
react-frontend/src/components/Navbar.tsx - Geo utils · Client-side location lookup and browser position helpers.
react-frontend/src/util/geolocation.ts - Map utils · Map rendering and route visualization helpers.
react-frontend/src/util/map.ts - Models · Shared frontend data models for route and map state.
react-frontend/src/util/models.ts - Route error · Frontend error for duplicate or invalid route creation.
react-frontend/src/errors/route-exists.error.ts
Nest API
HTTP and realtime domain layer for route state.
- Main · API process entrypoint.
nest-api/src/main.ts - App module · Root module that composes the application.
nest-api/src/app.module.ts - Routes module · Feature boundary for route management.
nest-api/src/routes/routes.module.ts - Routes API · HTTP endpoints for route commands and queries.
nest-api/src/routes/routes.controller.ts - Routes service · Route business logic and persistence coordination.
nest-api/src/routes/routes.service.ts - Routes gateway · Realtime update channel for route changes.
nest-api/src/routes/routes.gateway.ts - Route entity · Authoritative route persistence model.
nest-api/src/routes/entities/route.entity.ts - Route DTOs · Create and update payload contracts for the route API.
nest-api/src/routes/dto/create-route.dto.ts
Go simulator
Event producer that emits destination and route movement data.
- Main · Simulator process entrypoint.
simulator/main.go - Route engine · Simulator route behavior and movement logic.
simulator/application/route/route.go - Kafka produce · Application-level event publishing workflow.
simulator/application/kafka/produce.go - Kafka infra · Low-level Kafka producer and consumer wiring.
simulator/infra/kafka/producer.go - Destinations · Predefined destination sequences for the simulator.
simulator/destinations/1.txt
Kafka stack
Async messaging and sink integration boundary.
- Kafka compose · Kafka runtime and connector composition.
apache-kafka/docker-compose.yaml - ES connector · Kafka Connect Elasticsearch sink configuration.
apache-kafka/connectors/elasticsearch.properties
Deploy assets
Container and Kubernetes packaging for independent runtime units.
- Mongo init · Mongo initialization script for the API datastore.
nest-api/.docker/mongo/init.js - Backend deploy · Kubernetes deployment and service boundary for the API.
k8s/backend/deploy.yaml - Frontend deploy · Kubernetes deployment and service boundary for the UI.
k8s/frontend/deploy.yaml - Simulator deploy · Kubernetes deployment boundary for the Go simulator.
k8s/simulator/deploy.yaml
Connections 30
- App → Mapping: renders · The app composes the main map experience.
- App → Navbar: renders · The app includes global navigation.
- Mapping → Geo utils: uses · Map UI reads browser location.
- Mapping → Map utils: uses · Map UI delegates rendering and route visualization.
- Mapping → Models: shares · Map UI relies on shared frontend data structures.
- Mapping → Route error: handles · Map UI surfaces route validation failures.
- Main → App module: boots · Nest entrypoint starts the root module.
- App module → Routes module: loads · The root module wires the routes feature.
- Routes module → Routes API: contains · Feature module exposes HTTP handlers.
- Routes module → Routes service: contains · Feature module contains domain logic.
- Routes module → Routes gateway: contains · Feature module exposes realtime updates.
- Routes module → Route entity: persists · Feature module binds the route model.
- Routes module → Route DTOs: contracts · Feature module defines API payloads.
- Routes API → Routes service: calls · HTTP layer delegates business operations.
- Routes service → Route entity: stores · Service owns route persistence.
- Routes service → Routes gateway: publishes · Service pushes route changes to realtime consumers.
- Main → Route engine: starts · Simulator entrypoint initializes route behavior.
- Route engine → Destinations: reads · Route logic consumes predefined destination sequences.
- Route engine → Kafka produce: emits · Route logic forwards events for streaming.
- Kafka produce → Kafka infra: uses · Producer workflow depends on Kafka client plumbing.
- Kafka infra → Kafka compose: connects · Kafka client targets the Kafka runtime boundary.
- ES connector → Kafka compose: extends · Connect config plugs into the Kafka stack.
- Routes gateway → Kafka compose: consumes · Realtime path can subscribe to streamed events.
- Routes service → Mongo init: initializes · API data boundary is backed by Mongo setup.
- App → Routes API: requests · UI talks to the HTTP API for route actions.
- App → Routes gateway: subscribes · UI can receive realtime route updates.
- Main → Kafka compose: produces · Simulator publishes events into Kafka.
- Backend deploy → Routes module: deploys · Kubernetes packages the API service.
- Frontend deploy → App: deploys · Kubernetes packages the frontend service.
- Simulator deploy → Main: deploys · Kubernetes packages the simulator service.