/

Developer Guide

Deep Dive into Microservices

At a macro level, CrowdVision relies on a distributed microservices architecture. However, at a micro level, each individual service is built as an internally monolithic, layered application.

By standardizing the internal architecture of these services, developers can easily jump between the Auth, Twin, or Notification services and instantly understand where to find the business logic, database queries, and route handlers.


🥞 The Internal Layered Architecture

The primary REST APIs (Auth, Twin, and Notification) share a strict 4-tier internal architecture. The flow of data is strictly unidirectional: requests enter through the Router, pass to the Controller, are processed by the Service, and interact with the Database via the Model.

graph TD
    subgraph Single Microservice Boundary
        R[Router Layer<br/>`src/router.ts`] --> C[Controller Layer<br/>`src/controller/`]
        C --> S[Service Layer<br/>`src/services/`]
        S --> M[Model Layer<br/>`src/models/`]
        M -.-> DB[(Dedicated MongoDB)]
    end

Layer Breakdown


🔍 Service-by-Service Breakdown

Let’s look at the specific responsibilities and internal components of each microservice.

1. Auth Service (/auth/*)

The Auth Service is the gatekeeper of the platform.

2. Twin Service (/twin/*)

The Twin Service is the spatial engine.

3. Notification Service (/notification/*)

The Notification Service acts as the rule engine and dispatcher.

4. Socket Service (/socket.io/*)

Unlike the REST APIs, the Socket Service is highly specialized and much flatter in its architecture.

5. Agent Service (LLM)

This service is experimental and represents our future AI capabilities.