# pabloamomo/dloc-platform architecture

> Architecture diagram of the GitHub repository pabloamomo/dloc-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pabloamomo/dloc-platform
- Repository: https://github.com/pabloamomo/dloc-platform

## Overview

DLOC is a GPS tracking platform: device messages enter through the server’s HTTP or protocol-specific socket handlers, are persisted, and are exposed through an API to a React frontend. The API also manages devices, sharing, authentication, images, and live WebSocket updates. The sampled code supports the server’s main dispatch and persistence relationships; several frontend and API service connections are documented only at a high level, so those links are dashed and unverified.

Main entry points: [`dloc-frontend/src/App.tsx`](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-frontend/src/App.tsx) (React application), [`dloc-server/source/server.ts`](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-server/source/server.ts) (GPS server), [`dloc-api/source/server.ts`](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/server.ts) (API server), [`dloc-server/source/controllers/server-http/routes/routesLocation.ts`](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-server/source/controllers/server-http/routes/routesLocation.ts) (HTTP location)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gps["GPS ingestion"]
  node_server["GPS server<br/>[server.ts]"]
  node_socket_ingest["Socket handler"]
  node_protocols["Protocol adapters"]
  node_http_ingest["HTTP location<br/>[routesLocation.ts]"]
  node_packet_processor["Packet processing"]
end

subgraph group_api["API services"]
  node_api_server["API server<br/>[server.ts]"]
  node_api_routes["HTTP routes<br/>[routes.ts]"]
  node_device_services["Device services"]
  node_auth["Token authentication<br/>[checkToken.ts]"]
  node_api_socket["WebSocket handler<br/>[socketHandler.ts]"]
  node_position_service["Position updates"]
  node_profile_service["Power profiles"]
  node_api_persistence["Persistence contract<br/>[_Persistence.ts]"]
end

subgraph group_web["Frontend"]
  node_frontend["React application<br/>[App.tsx]"]
  node_map["Tracking map<br/>[Map.tsx]"]
  node_device_ui["Device management<br/>[Profile.tsx]"]
  node_frontend_providers["Application providers"]
  node_frontend_services["API clients<br/>[serviceCall.ts]"]
end

subgraph group_storage["Persistence"]
  node_server_store["Server persistence"]
  node_mysql[("MySQL")]
  node_api_mysql["MySQL adapter"]
end

node_devices(("GPS devices"))
node_user(("Platform user"))

node_devices -.->|"send packets"| node_socket_ingest
node_devices -.->|"submit locations"| node_http_ingest
node_server -->|"starts socket"| node_socket_ingest
node_server -->|"starts HTTP"| node_http_ingest
node_server -->|"selects adapter"| node_protocols
node_socket_ingest -->|"dispatches packets"| node_protocols
node_http_ingest -->|"processes packet"| node_packet_processor
node_http_ingest -->|"gets persistence"| node_server_store
node_server -->|"starts persistence"| node_server_store
node_server_store -.->|"reads and writes"| node_mysql
node_api_server -.->|"starts HTTP"| node_api_routes
node_api_server -->|"starts WebSocket"| node_api_socket
node_api_server -->|"sets persistence"| node_api_mysql
node_api_server -->|"uses contract"| node_api_persistence
node_api_routes -.->|"serves device APIs"| node_device_services
node_api_socket -->|"validates token"| node_auth
node_api_socket -->|"reads data signature"| node_api_persistence
node_position_service -->|"loads positions"| node_api_persistence
node_profile_service -->|"updates profile"| node_api_persistence
node_api_mysql -.->|"reads and writes"| node_mysql
node_user -.->|"uses platform"| node_frontend
node_frontend -.->|"presents tracking"| node_map
node_frontend -.->|"manages devices"| node_device_ui
node_frontend -.->|"uses providers"| node_frontend_providers
node_frontend_providers -.->|"requests data"| node_frontend_services
node_frontend_services -.->|"calls API"| node_api_routes
node_frontend -.->|"receives live updates"| node_api_socket

click node_server "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-server/source/server.ts"
click node_socket_ingest "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-server/source/controllers/server-socket/serverSocketHandler.ts"
click node_protocols "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-server/source/infraestucture/models/ServerSocketHandlerPropsInjection.ts"
click node_http_ingest "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-server/source/controllers/server-http/routes/routesLocation.ts"
click node_packet_processor "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-server/source/services/server-http/protoHttpHandlePacket.ts"
click node_server_store "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-server/source/infraestucture/mySql/mySqlPersistence.ts"
click node_api_server "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/server.ts"
click node_api_routes "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/controllers/routes.ts"
click node_device_services "https://github.com/pabloamomo/dloc-platform/tree/main/dloc-api/source/services/device"
click node_auth "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/functions/checkToken.ts"
click node_api_socket "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/sockets/socketHandler.ts"
click node_position_service "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/sockets/services/getPositionService.ts"
click node_profile_service "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/sockets/services/updatePowerProfileService.ts"
click node_api_persistence "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/persistence/_Persistence.ts"
click node_api_mysql "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/persistence/mySql/_mySqlPersistence.ts"
click node_frontend "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-frontend/src/App.tsx"
click node_map "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-frontend/src/pages/Map/Map.tsx"
click node_device_ui "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-frontend/src/pages/Profile/Profile.tsx"
click node_frontend_providers "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-frontend/src/providers/DevicesProvider.tsx"
click node_frontend_services "https://github.com/pabloamomo/dloc-platform/blob/main/dloc-frontend/src/functions/serviceCall.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_socket_ingest,node_protocols,node_http_ingest,node_packet_processor,node_user toneBlue
class node_api_server,node_api_routes,node_device_services,node_auth,node_api_socket,node_position_service,node_profile_service,node_api_persistence toneAmber
class node_frontend,node_map,node_device_ui,node_frontend_providers,node_frontend_services toneMint
class node_server_store,node_mysql,node_api_mysql toneRose
class node_devices toneIndigo
```

## Components

### GPS ingestion

- [GPS server](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-server/source/server.ts): `dloc-server/source/server.ts`
- [Socket handler](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-server/source/controllers/server-socket/serverSocketHandler.ts): `dloc-server/source/controllers/server-socket/serverSocketHandler.ts`
- [Protocol adapters](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-server/source/infraestucture/models/ServerSocketHandlerPropsInjection.ts): `dloc-server/source/infraestucture/models/ServerSocketHandlerPropsInjection.ts`
- [HTTP location](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-server/source/controllers/server-http/routes/routesLocation.ts): `dloc-server/source/controllers/server-http/routes/routesLocation.ts`
- [Packet processing](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-server/source/services/server-http/protoHttpHandlePacket.ts): `dloc-server/source/services/server-http/protoHttpHandlePacket.ts`

### API services

- [API server](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/server.ts): `dloc-api/source/server.ts`
- [HTTP routes](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/controllers/routes.ts): `dloc-api/source/controllers/routes.ts`
- [Device services](https://github.com/pabloamomo/dloc-platform/tree/main/dloc-api/source/services/device): `dloc-api/source/services/device`
- [Token authentication](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/functions/checkToken.ts): `dloc-api/source/functions/checkToken.ts`
- [WebSocket handler](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/sockets/socketHandler.ts): `dloc-api/source/sockets/socketHandler.ts`
- [Position updates](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/sockets/services/getPositionService.ts): `dloc-api/source/sockets/services/getPositionService.ts`
- [Power profiles](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/sockets/services/updatePowerProfileService.ts): `dloc-api/source/sockets/services/updatePowerProfileService.ts`
- [Persistence contract](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/persistence/_Persistence.ts): `dloc-api/source/persistence/_Persistence.ts`

### Frontend

- [React application](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-frontend/src/App.tsx): `dloc-frontend/src/App.tsx`
- [Tracking map](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-frontend/src/pages/Map/Map.tsx): `dloc-frontend/src/pages/Map/Map.tsx`
- [Device management](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-frontend/src/pages/Profile/Profile.tsx): `dloc-frontend/src/pages/Profile/Profile.tsx`
- [Application providers](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-frontend/src/providers/DevicesProvider.tsx): `dloc-frontend/src/providers/DevicesProvider.tsx`
- [API clients](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-frontend/src/functions/serviceCall.ts): `dloc-frontend/src/functions/serviceCall.ts`

### Persistence

- [Server persistence](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-server/source/infraestucture/mySql/mySqlPersistence.ts): `dloc-server/source/infraestucture/mySql/mySqlPersistence.ts`
- **MySQL**
- [MySQL adapter](https://github.com/pabloamomo/dloc-platform/blob/main/dloc-api/source/persistence/mySql/_mySqlPersistence.ts): `dloc-api/source/persistence/mySql/_mySqlPersistence.ts`

### Other components

- **GPS devices**
- **Platform user**

## Connections

- GPS devices → Socket handler: send packets
- GPS devices → HTTP location: submit locations
- GPS server → Socket handler: starts socket (evidence: `dloc-server/source/server.ts`)
- GPS server → HTTP location: starts HTTP (evidence: `dloc-server/source/server.ts`)
- GPS server → Protocol adapters: selects adapter (evidence: `dloc-server/source/server.ts`)
- Socket handler → Protocol adapters: dispatches packets (evidence: `dloc-server/source/controllers/server-socket/serverSocketHandler.ts`)
- HTTP location → Packet processing: processes packet (evidence: `dloc-server/source/controllers/server-http/routes/routesLocation.ts`)
- HTTP location → Server persistence: gets persistence (evidence: `dloc-server/source/controllers/server-http/routes/routesLocation.ts`)
- GPS server → Server persistence: starts persistence (evidence: `dloc-server/source/server.ts`)
- Server persistence → MySQL: reads and writes
- API server → HTTP routes: starts HTTP
- API server → WebSocket handler: starts WebSocket (evidence: `dloc-api/source/server.ts`)
- API server → MySQL adapter: sets persistence (evidence: `dloc-api/source/server.ts`)
- API server → Persistence contract: uses contract (evidence: `dloc-api/source/server.ts`)
- HTTP routes → Device services: serves device APIs
- WebSocket handler → Token authentication: validates token (evidence: `dloc-api/source/sockets/socketHandler.ts`)
- WebSocket handler → Persistence contract: reads data signature (evidence: `dloc-api/source/sockets/socketHandler.ts`)
- Position updates → Persistence contract: loads positions (evidence: `dloc-api/source/sockets/services/getPositionService.ts`)
- Power profiles → Persistence contract: updates profile (evidence: `dloc-api/source/sockets/services/updatePowerProfileService.ts`)
- MySQL adapter → MySQL: reads and writes
- Platform user → React application: uses platform
- React application → Tracking map: presents tracking
- React application → Device management: manages devices
- React application → Application providers: uses providers
- Application providers → API clients: requests data
- API clients → HTTP routes: calls API
- React application → WebSocket handler: receives live updates
