# ishan1o1/location_tracker architecture

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

- Interactive diagram: https://gitdiagram.com/ishan1o1/location_tracker
- Repository: https://github.com/ishan1o1/location_tracker

## Overview

#### Purpose and System Shape
This is a client/server location-oriented application with authentication, user profiles, a dashboard map, REST APIs, persistence, and real-time socket handling. The frontend is a Vite/React single-page client; the backend is a Node.js HTTP service organized around routes, controllers, services, models, and middleware.

#### Frontend Entry and UI Composition
The browser entry point is `client/src/main.jsx`, which mounts the application defined in `client/src/App.jsx`. Page-level flows are separated into login, dashboard, and profile views:
- `client/src/pages/LoginPage.jsx`
- `client/src/pages/Dashboard.jsx`
- `client/src/pages/ProfilePage.jsx`

The dashboard’s defining UI boundary is the location/map experience, composed from `client/src/component/Map.jsx`, `client/src/component/Sidebar.jsx`, and `client/src/component/UserCard.jsx`.

#### Client API, Auth, and Real-Time Boundary
HTTP communication is centralized under the client service layer:
- `client/src/services/api.js`
- `client/src/services/authService.js`

This layer should isolate API base URL, request configuration, and authentication-oriented calls from UI components. Runtime environment values are exposed through `client/src/config/env.js` and the template `client/.env.example`.

Real-time connectivity is distinct from REST calls through `client/src/socket.js`; map/dashboard state can consume socket events without coupling directly to request services.

#### Server Entry and Request Pipeline
`server/server.js` is the backend composition and process entry point. It connects infrastructure, mounts route modules, configures middleware, and initializes the socket subsystem.

Request flow is expected to follow:
1. Client calls an auth or location endpoint.
2. A route selects the controller.
3. Protected operations pass through auth middleware.
4. Controllers delegate business logic or persistence.
5. Responses return through the HTTP boundary.

The main route boundaries are:
- `server/routes/authRoutes.js`
- `server/routes/locationRoute.js`
- `server/middleware/authMiddleware.js`

#### Identity and Authorization
Authentication is split between transport/controller responsibilities and reusable service logic:
- `server/controllers/authController.js`
- `server/services/authService.js`
- `server/utils/jwt.js`

`server/models/User.js` defines the persisted user-domain boundary. JWT generation/validation is intentionally separated from controller code, while `server/middleware/authMiddleware.js` protects downstream location or profile-related operations.

#### Location and Real-Time Updates
Location-specific HTTP operations are handled by:
- `server/routes/locationRoute.js`
- `server/controllers/locationController.js`

The real-time counterpart is `server/socketHandler.js`. This establishes a separate event-driven control path for live updates, likely allowing connected clients to receive location/user changes without polling. The frontend map and the backend socket handler are the key boundary for this feature, mediated by `client/src/socket.js`.

#### Infrastructure and Deployment
Database initialization is isolated in `server/config/database.js`; its concrete provider is not identifiable from the supplied tree. Server diagnostics are centralized in `server/logger.js`.

The client is configured for Vite development/build output through `client/vite.config.js` and includes Vercel deployment configuration in `client/vercel.json`. Environment-dependent values should remain outside source control, using the provided client environment template and corresponding server runtime configuration.

Main entry points: [`client/src/App.jsx`](https://github.com/ishan1o1/location_tracker/blob/main/client/src/App.jsx) (App shell), [`client/src/pages/Dashboard.jsx`](https://github.com/ishan1o1/location_tracker/blob/main/client/src/pages/Dashboard.jsx) (Dashboard), [`server/server.js`](https://github.com/ishan1o1/location_tracker/blob/main/server/server.js) (Server composition), [`server/models/User.js`](https://github.com/ishan1o1/location_tracker/blob/main/server/models/User.js) (User model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_client_main["Browser entry<br/>React entry<br/>[main.jsx]"]
  node_client_app["App shell<br/>React composition<br/>[App.jsx]"]
  node_login_page["Login<br/>page<br/>[LoginPage.jsx]"]
  node_dashboard["Dashboard<br/>page<br/>[Dashboard.jsx]"]
  node_profile_page["Profile<br/>page<br/>[ProfilePage.jsx]"]
  node_map_ui["Map experience<br/>UI components<br/>[Map.jsx]"]
  node_client_api["HTTP service layer<br/>API client<br/>[api.js]"]
  node_client_auth["Auth client<br/>auth service<br/>[authService.js]"]
  node_client_socket["Socket client<br/>realtime client<br/>[socket.js]"]
end

subgraph group_server["Node server"]
  node_server_entry["Server composition<br/>Node entry<br/>[server.js]"]
  node_auth_routes["Auth routes<br/>REST routes<br/>[authRoutes.js]"]
  node_location_routes["Location routes<br/>REST routes<br/>[locationRoute.js]"]
  node_auth_middleware["Auth guard<br/>middleware<br/>[authMiddleware.js]"]
  node_auth_controller["Auth controller<br/>[authController.js]"]
  node_location_controller["Location controller"]
  node_auth_service["Identity service<br/>business service<br/>[authService.js]"]
  node_jwt["JWT utility<br/>token utility<br/>[jwt.js]"]
  node_socket_handler["Socket handler<br/>realtime server<br/>[socketHandler.js]"]
end

subgraph group_data["Infrastructure"]
  node_user_model[("User model<br/>persistence model<br/>[User.js]")]
  node_database[("Database initialization<br/>database adapter<br/>[database.js]")]
end

node_client_main -->|"mounts"| node_client_app
node_client_app -->|"renders"| node_login_page
node_client_app -->|"renders"| node_dashboard
node_client_app -->|"renders"| node_profile_page
node_dashboard -->|"composes"| node_map_ui
node_login_page -->|"sign-in calls"| node_client_auth
node_client_auth -->|"uses"| node_client_api
node_dashboard -->|"location requests"| node_client_api
node_dashboard -->|"consumes events"| node_client_socket
node_client_api -->|"REST"| node_server_entry
node_client_socket -->|"socket events"| node_socket_handler
node_server_entry -->|"mounts"| node_auth_routes
node_server_entry -->|"mounts"| node_location_routes
node_server_entry -->|"initializes"| node_socket_handler
node_auth_routes -->|"dispatches"| node_auth_controller
node_location_routes -->|"protects"| node_auth_middleware
node_auth_middleware -->|"authorizes"| node_location_controller
node_auth_controller -->|"delegates"| node_auth_service
node_auth_service -->|"issues tokens"| node_jwt
node_auth_middleware -->|"validates tokens"| node_jwt
node_auth_service -->|"reads/writes"| node_user_model
node_location_controller -->|"accesses users"| node_user_model
node_user_model -->|"persists through"| node_database
node_socket_handler -.->|"publishes updates from"| node_user_model

click node_client_main "https://github.com/ishan1o1/location_tracker/blob/main/client/src/main.jsx"
click node_client_app "https://github.com/ishan1o1/location_tracker/blob/main/client/src/App.jsx"
click node_login_page "https://github.com/ishan1o1/location_tracker/blob/main/client/src/pages/LoginPage.jsx"
click node_dashboard "https://github.com/ishan1o1/location_tracker/blob/main/client/src/pages/Dashboard.jsx"
click node_profile_page "https://github.com/ishan1o1/location_tracker/blob/main/client/src/pages/ProfilePage.jsx"
click node_map_ui "https://github.com/ishan1o1/location_tracker/blob/main/client/src/component/Map.jsx"
click node_client_api "https://github.com/ishan1o1/location_tracker/blob/main/client/src/services/api.js"
click node_client_auth "https://github.com/ishan1o1/location_tracker/blob/main/client/src/services/authService.js"
click node_client_socket "https://github.com/ishan1o1/location_tracker/blob/main/client/src/socket.js"
click node_server_entry "https://github.com/ishan1o1/location_tracker/blob/main/server/server.js"
click node_auth_routes "https://github.com/ishan1o1/location_tracker/blob/main/server/routes/authRoutes.js"
click node_location_routes "https://github.com/ishan1o1/location_tracker/blob/main/server/routes/locationRoute.js"
click node_auth_middleware "https://github.com/ishan1o1/location_tracker/blob/main/server/middleware/authMiddleware.js"
click node_auth_controller "https://github.com/ishan1o1/location_tracker/blob/main/server/controllers/authController.js"
click node_location_controller "https://github.com/ishan1o1/location_tracker/blob/main/server/controllers/locationController.js"
click node_auth_service "https://github.com/ishan1o1/location_tracker/blob/main/server/services/authService.js"
click node_jwt "https://github.com/ishan1o1/location_tracker/blob/main/server/utils/jwt.js"
click node_socket_handler "https://github.com/ishan1o1/location_tracker/blob/main/server/socketHandler.js"
click node_user_model "https://github.com/ishan1o1/location_tracker/blob/main/server/models/User.js"
click node_database "https://github.com/ishan1o1/location_tracker/blob/main/server/config/database.js"

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_client_main,node_client_app,node_login_page,node_dashboard,node_profile_page,node_map_ui,node_client_api,node_client_auth,node_client_socket toneBlue
class node_server_entry,node_auth_routes,node_location_routes,node_auth_middleware,node_auth_controller,node_location_controller,node_auth_service,node_jwt,node_socket_handler toneAmber
class node_user_model,node_database toneMint
```

## Components

### React client

Vite single-page application.

- [Browser entry](https://github.com/ishan1o1/location_tracker/blob/main/client/src/main.jsx): React entry · `client/src/main.jsx`
- [App shell](https://github.com/ishan1o1/location_tracker/blob/main/client/src/App.jsx): React composition · `client/src/App.jsx`
- [Login](https://github.com/ishan1o1/location_tracker/blob/main/client/src/pages/LoginPage.jsx): page · `client/src/pages/LoginPage.jsx`
- [Dashboard](https://github.com/ishan1o1/location_tracker/blob/main/client/src/pages/Dashboard.jsx): page · Primary map and live-location view. · `client/src/pages/Dashboard.jsx`
- [Profile](https://github.com/ishan1o1/location_tracker/blob/main/client/src/pages/ProfilePage.jsx): page · `client/src/pages/ProfilePage.jsx`
- [Map experience](https://github.com/ishan1o1/location_tracker/blob/main/client/src/component/Map.jsx): UI components · Map, sidebar, and user-card composition. · `client/src/component/Map.jsx`
- [HTTP service layer](https://github.com/ishan1o1/location_tracker/blob/main/client/src/services/api.js): API client · Centralizes request configuration and API access. · `client/src/services/api.js`
- [Auth client](https://github.com/ishan1o1/location_tracker/blob/main/client/src/services/authService.js): auth service · `client/src/services/authService.js`
- [Socket client](https://github.com/ishan1o1/location_tracker/blob/main/client/src/socket.js): realtime client · `client/src/socket.js`

### Node server

HTTP API and real-time service.

- [Server composition](https://github.com/ishan1o1/location_tracker/blob/main/server/server.js): Node entry · Mounts middleware, routes, infrastructure, and sockets. · `server/server.js`
- [Auth routes](https://github.com/ishan1o1/location_tracker/blob/main/server/routes/authRoutes.js): REST routes · `server/routes/authRoutes.js`
- [Location routes](https://github.com/ishan1o1/location_tracker/blob/main/server/routes/locationRoute.js): REST routes · `server/routes/locationRoute.js`
- [Auth guard](https://github.com/ishan1o1/location_tracker/blob/main/server/middleware/authMiddleware.js): middleware · Protects downstream operations using JWT validation. · `server/middleware/authMiddleware.js`
- [Auth controller](https://github.com/ishan1o1/location_tracker/blob/main/server/controllers/authController.js): controller · `server/controllers/authController.js`
- [Location controller](https://github.com/ishan1o1/location_tracker/blob/main/server/controllers/locationController.js): controller · `server/controllers/locationController.js`
- [Identity service](https://github.com/ishan1o1/location_tracker/blob/main/server/services/authService.js): business service · `server/services/authService.js`
- [JWT utility](https://github.com/ishan1o1/location_tracker/blob/main/server/utils/jwt.js): token utility · `server/utils/jwt.js`
- [Socket handler](https://github.com/ishan1o1/location_tracker/blob/main/server/socketHandler.js): realtime server · Event-driven path for live location and user updates. · `server/socketHandler.js`

### Infrastructure

- [User model](https://github.com/ishan1o1/location_tracker/blob/main/server/models/User.js): persistence model · `server/models/User.js`
- [Database initialization](https://github.com/ishan1o1/location_tracker/blob/main/server/config/database.js): database adapter · Concrete database provider is unspecified. · `server/config/database.js`

## Connections

- Browser entry → App shell: mounts
- App shell → Login: renders
- App shell → Dashboard: renders
- App shell → Profile: renders
- Dashboard → Map experience: composes
- Login → Auth client: sign-in calls
- Auth client → HTTP service layer: uses
- Dashboard → HTTP service layer: location requests
- Dashboard → Socket client: consumes events
- HTTP service layer → Server composition: REST
- Socket client → Socket handler: socket events
- Server composition → Auth routes: mounts
- Server composition → Location routes: mounts
- Server composition → Socket handler: initializes
- Auth routes → Auth controller: dispatches
- Location routes → Auth guard: protects
- Auth guard → Location controller: authorizes
- Auth controller → Identity service: delegates
- Identity service → JWT utility: issues tokens
- Auth guard → JWT utility: validates tokens
- Identity service → User model: reads/writes
- Location controller → User model: accesses users
- User model → Database initialization: persists through
- Socket handler → User model: publishes updates from
