# vasishta-04/myvault architecture

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

- Interactive diagram: https://gitdiagram.com/vasishta-04/myvault
- Repository: https://github.com/vasishta-04/myvault

## Overview

MyVault is a small Go file-management server with a static web interface. Users browse a file explorer, then use the REST API to upload files or create folders, browse hierarchical directory data, and download files. The server routes requests to handlers that operate on per-user filesystem paths; directory browsing uses a separate topology generator. The README describes user-isolated storage, but the shown Get_user_id implementation always returns 0, so isolation is not established by the sampled code.

Main entry points: [`main_server.go`](https://github.com/vasishta-04/myvault/blob/main/main_server.go) (Filesystem API), [`ALL_FILES`](https://github.com/vasishta-04/myvault/tree/main/ALL_FILES) (User file storage), [`static/index.html`](https://github.com/vasishta-04/myvault/blob/main/static/index.html) (File explorer), [`util.go`](https://github.com/vasishta-04/myvault/blob/main/util.go) (Request and path helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Web interface"]
  node_explorer["File explorer<br/>[index.html]"]
end

subgraph group_server["HTTP service"]
  node_http["HTTP server<br/>[main_server.go]"]
  node_static_delivery["Static delivery<br/>[main_server.go]"]
  node_api_router["Filesystem API<br/>[main_server.go]"]
  node_request_helpers["Request and path helpers<br/>[util.go]"]
end

subgraph group_files["File management"]
  node_upload["Upload and folders<br/>[main_server.go]"]
  node_browse_download["Browse and download<br/>[main_server.go]"]
  node_topology["Directory topology"]
  node_storage[("User file storage")]
end

node_user(("User"))

node_user -->|"uses"| node_explorer
node_explorer -->|"uses REST API"| node_api_router
node_http -->|"routes requests"| node_static_delivery
node_http -->|"routes requests"| node_api_router
node_static_delivery -->|"serves files"| node_explorer
node_api_router -->|"dispatches POST"| node_upload
node_api_router -->|"dispatches GET"| node_browse_download
node_api_router -->|"logs requests"| node_request_helpers
node_upload -->|"resolves user"| node_request_helpers
node_browse_download -->|"resolves user"| node_request_helpers
node_upload -->|"writes files"| node_storage
node_upload -->|"creates folders"| node_storage
node_browse_download -->|"builds directory JSON"| node_topology
node_browse_download -->|"reads files"| node_storage
node_topology -->|"reads directory entries"| node_storage

click node_explorer "https://github.com/vasishta-04/myvault/blob/main/static/index.html"
click node_http "https://github.com/vasishta-04/myvault/blob/main/main_server.go"
click node_static_delivery "https://github.com/vasishta-04/myvault/blob/main/main_server.go"
click node_api_router "https://github.com/vasishta-04/myvault/blob/main/main_server.go"
click node_upload "https://github.com/vasishta-04/myvault/blob/main/main_server.go"
click node_browse_download "https://github.com/vasishta-04/myvault/blob/main/main_server.go"
click node_topology "https://github.com/vasishta-04/myvault/blob/main/gen_folder_topology.go"
click node_storage "https://github.com/vasishta-04/myvault/tree/main/ALL_FILES"
click node_request_helpers "https://github.com/vasishta-04/myvault/blob/main/util.go"

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_explorer,node_user toneBlue
class node_http,node_static_delivery,node_api_router,node_request_helpers toneAmber
class node_upload,node_browse_download,node_topology,node_storage toneMint
```

## Components

### Web interface

- [File explorer](https://github.com/vasishta-04/myvault/blob/main/static/index.html): `static/index.html`

### HTTP service

- [HTTP server](https://github.com/vasishta-04/myvault/blob/main/main_server.go): `main_server.go`
- [Static delivery](https://github.com/vasishta-04/myvault/blob/main/main_server.go): `main_server.go`
- [Filesystem API](https://github.com/vasishta-04/myvault/blob/main/main_server.go): `main_server.go`
- [Request and path helpers](https://github.com/vasishta-04/myvault/blob/main/util.go): `util.go`

### File management

- [Upload and folders](https://github.com/vasishta-04/myvault/blob/main/main_server.go): `main_server.go`
- [Browse and download](https://github.com/vasishta-04/myvault/blob/main/main_server.go): `main_server.go`
- [Directory topology](https://github.com/vasishta-04/myvault/blob/main/gen_folder_topology.go): `gen_folder_topology.go`
- [User file storage](https://github.com/vasishta-04/myvault/tree/main/ALL_FILES): `ALL_FILES`

### Other components

- **User**

## Connections

- User → File explorer: uses (evidence: `README.md`)
- File explorer → Filesystem API: uses REST API (evidence: `README.md`)
- HTTP server → Static delivery: routes requests (evidence: `main_server.go`)
- HTTP server → Filesystem API: routes requests (evidence: `main_server.go`)
- Static delivery → File explorer: serves files (evidence: `main_server.go`)
- Filesystem API → Upload and folders: dispatches POST (evidence: `main_server.go`)
- Filesystem API → Browse and download: dispatches GET (evidence: `main_server.go`)
- Filesystem API → Request and path helpers: logs requests (evidence: `main_server.go`)
- Upload and folders → Request and path helpers: resolves user (evidence: `main_server.go`)
- Browse and download → Request and path helpers: resolves user (evidence: `main_server.go`)
- Upload and folders → User file storage: writes files (evidence: `main_server.go`)
- Upload and folders → User file storage: creates folders (evidence: `main_server.go`)
- Browse and download → Directory topology: builds directory JSON (evidence: `main_server.go`)
- Browse and download → User file storage: reads files (evidence: `main_server.go`)
- Directory topology → User file storage: reads directory entries (evidence: `gen_folder_topology.go`)
