# aaditya-5281/realtime_tracker architecture

> Architecture diagram of the GitHub repository aaditya-5281/realtime_tracker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aaditya-5281/realtime_tracker
- Repository: https://github.com/aaditya-5281/realtime_tracker

## Overview

##### Project Type and Purpose
- This is a full-stack web application that provides real-time location sharing.
- The backend is powered by Node.js/Express with Socket.IO handling the real-time communication.
- The frontend is served as static assets (HTML templates, CSS, and JavaScript) from designated directories.

##### File Structure
- The main server file is “app.js” which initializes the Express server and Socket.IO for handling HTTP endpoints and WebSocket events.
- The “public” folder contains the client-side static assets (“css” for styling and “js” for client side scripts) that are loaded by the browser.
- The “views” folder contains the EJS template (“index.ejs”), which dynamically renders the main page.
- The project contains a “package.json” that lists dependencies such as express, socket.io, and ejs, confirming the technical stack.

##### Core Components
a. Client (Browser):
- Within this component, note that HTML/CSS/JS are served from “views” and “public” directories. The browser loads the main page (index.ejs) and the associated static files.
- That the client uses the Socket.IO client library (included via “public/js/script.js”) to communicate in real-time.

b. Server:
- Within this server component:
- Express as handling HTTP requests. The “GET /” route serves the main page.
- That Socket.IO is integrated into the server to handle WebSocket events like “sendLocation”, “receiveLocation”, and “userDisconnected”.

##### Relationships and Interactions
- HTTP requests (i.e., GET / for loading the page).
- Real-time communication:

##### Architectural Patterns and Technologies
- Tiered separation:
- The Frontend tier is clearly separated (served through static files and EJS templates).
- The Backend tier comprises Express to handle HTTP requests and Socket.IO for enabling bi-directional real-time communication.
- That the application uses an event-driven architectural style facilitated by Socket.IO.
- Make note of the technologies: Node.js, Express, Socket.IO, and EJS.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "Client (Browser)"
        CT["HTML Template"]:::frontend
        CSS["Static Asset: style.css"]:::frontend
        JS["Static Asset: script.js"]:::frontend
        sio_client["Socket.IO (Client Side)"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Server – Node.js/Express"
        server_main["Main Server: app.js"]:::backend
        express["Express (HTTP Handling)"]:::backend
        sio_server["Socket.IO (Real-Time)"]:::backend
    end

    %% Internal Server Initialization
    server_main -->|"initializes"| express
    server_main -->|"initializes"| sio_server

    %% Client to Server Communication
    CT -->|"GET/"| express
    sio_client -->|"sendLocation"| sio_server
    sio_server -->|"receiveLocation"| sio_client
    sio_server -->|"userDisconnected"| sio_client

    %% Click Events
    click CT "https://github.com/aaditya-5281/realtime_tracker/blob/main/views/index.ejs"
    click CSS "https://github.com/aaditya-5281/realtime_tracker/blob/main/public/css/style.css"
    click JS "https://github.com/aaditya-5281/realtime_tracker/blob/main/public/js/script.js"
    click sio_client "https://github.com/aaditya-5281/realtime_tracker/blob/main/public/js/script.js"
    click server_main "https://github.com/aaditya-5281/realtime_tracker/blob/main/app.js"
    click sio_server "https://github.com/aaditya-5281/realtime_tracker/blob/main/app.js"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#003399,stroke-width:2px,color:#003399;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px,color:#155724;
```
