# cheasezz/file-service architecture

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

- Interactive diagram: https://gitdiagram.com/cheasezz/file-service
- Repository: https://github.com/cheasezz/file-service

## Overview

File Service is a gRPC-backed file storage and synchronization application. A client uploads and downloads files in chunks, lists stored names, and compares local SHA-256 hashes with server state; synchronization uploads only files the server reports as missing or changed. The server separates gRPC handlers, application services, domain validation, and filesystem storage. The README documents the four RPC patterns and parallel client uploads. Some handler and hash-storage implementations were not excerpted, so their specific call paths are shown only where the README or sampled code supports them.

Main entry points: [`internal/service/service.go`](https://github.com/cheasezz/file-service/blob/main/internal/service/service.go) (File service), [`cmd/client/main.go`](https://github.com/cheasezz/file-service/blob/main/cmd/client/main.go) (Client workflow), [`internal/grpc/server.go`](https://github.com/cheasezz/file-service/blob/main/internal/grpc/server.go) (gRPC server), [`internal/app/app.go`](https://github.com/cheasezz/file-service/blob/main/internal/app/app.go) (Server assembly)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_clientapp["Client workflow<br/>[main.go]"]
  node_localfiles[("Local files<br/>[main.go]")]
end

subgraph group_transport["gRPC transport"]
  node_upload["Upload handler<br/>[upload.go]"]
  node_download["Download handler<br/>[download.go]"]
  node_listnames["List handler"]
  node_checkfiles["Sync handler<br/>[checkFiles.go]"]
  node_grpcserver["gRPC server<br/>[server.go]"]
  node_protocol["RPC protocol<br/>[fileService.proto]"]
end

subgraph group_application["Application services"]
  node_service["File service<br/>[service.go]"]
  node_createfile["Upload writer<br/>[create.go]"]
  node_hashlist["Hash comparison<br/>[hashList.go]"]
  node_domainfile["File validation<br/>[file.go]"]
  node_domainerrors["Domain errors<br/>[errors.go]"]
  node_app["Server assembly<br/>[app.go]"]
  node_config["Configuration<br/>[config.go]"]
  node_serverentry["Server entry<br/>[main.go]"]
end

subgraph group_storage["Filesystem storage"]
  node_repository[("Filesystem repository<br/>[repo.go]")]
  node_storedhashes[("Stored hash lists<br/>[hashList.go]")]
end

node_user(("User"))

node_user -->|"uses"| node_clientapp
node_clientapp -->|"reads and writes"| node_localfiles
node_clientapp -->|"calls RPCs"| node_protocol
node_clientapp -->|"connects to"| node_grpcserver
node_grpcserver -->|"registers service"| node_protocol
node_grpcserver -->|"dispatches"| node_upload
node_grpcserver -.->|"dispatches"| node_download
node_grpcserver -.->|"dispatches"| node_listnames
node_grpcserver -.->|"dispatches"| node_checkfiles
node_upload -->|"creates and finishes upload"| node_service
node_checkfiles -->|"gets user hashes"| node_service
node_download -->|"opens file"| node_service
node_listnames -->|"lists names"| node_service
node_service -->|"implements upload creation"| node_createfile
node_createfile -->|"validates file info"| node_domainfile
node_createfile -->|"creates stored file"| node_repository
node_service -->|"opens and lists files"| node_repository
node_service -->|"loads user hashes"| node_hashlist
node_hashlist -.->|"reads hash list"| node_storedhashes
node_service -->|"returns domain errors"| node_domainerrors
node_app -->|"initializes"| node_repository
node_app -->|"constructs"| node_service
node_app -->|"constructs"| node_grpcserver
node_serverentry -->|"loads"| node_config
node_serverentry -->|"starts"| node_app
node_config -->|"configures"| node_grpcserver
node_clientapp -->|"compares hashes"| node_checkfiles
node_clientapp -->|"uploads chunks"| node_upload
node_clientapp -->|"downloads chunks"| node_download
node_clientapp -->|"requests names"| node_listnames

click node_clientapp "https://github.com/cheasezz/file-service/blob/main/cmd/client/main.go"
click node_localfiles "https://github.com/cheasezz/file-service/blob/main/cmd/client/main.go"
click node_upload "https://github.com/cheasezz/file-service/blob/main/internal/grpc/upload.go"
click node_download "https://github.com/cheasezz/file-service/blob/main/internal/grpc/download.go"
click node_listnames "https://github.com/cheasezz/file-service/blob/main/internal/grpc/getAllFilesNames.go"
click node_checkfiles "https://github.com/cheasezz/file-service/blob/main/internal/grpc/checkFiles.go"
click node_grpcserver "https://github.com/cheasezz/file-service/blob/main/internal/grpc/server.go"
click node_protocol "https://github.com/cheasezz/file-service/blob/main/proto/fileService.proto"
click node_service "https://github.com/cheasezz/file-service/blob/main/internal/service/service.go"
click node_createfile "https://github.com/cheasezz/file-service/blob/main/internal/service/create.go"
click node_hashlist "https://github.com/cheasezz/file-service/blob/main/internal/service/hashList.go"
click node_domainfile "https://github.com/cheasezz/file-service/blob/main/internal/core/file.go"
click node_domainerrors "https://github.com/cheasezz/file-service/blob/main/internal/core/errors.go"
click node_repository "https://github.com/cheasezz/file-service/blob/main/internal/repo/repo.go"
click node_storedhashes "https://github.com/cheasezz/file-service/blob/main/internal/repo/hashList.go"
click node_app "https://github.com/cheasezz/file-service/blob/main/internal/app/app.go"
click node_config "https://github.com/cheasezz/file-service/blob/main/config/config.go"
click node_serverentry "https://github.com/cheasezz/file-service/blob/main/cmd/server/main.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_clientapp,node_localfiles,node_user toneBlue
class node_upload,node_download,node_listnames,node_checkfiles,node_grpcserver,node_protocol toneAmber
class node_service,node_createfile,node_hashlist,node_domainfile,node_domainerrors,node_app,node_config,node_serverentry toneMint
class node_repository,node_storedhashes toneRose
```

## Components

### Client

- [Client workflow](https://github.com/cheasezz/file-service/blob/main/cmd/client/main.go): `cmd/client/main.go`
- [Local files](https://github.com/cheasezz/file-service/blob/main/cmd/client/main.go): `cmd/client/main.go`

### gRPC transport

- [Upload handler](https://github.com/cheasezz/file-service/blob/main/internal/grpc/upload.go): `internal/grpc/upload.go`
- [Download handler](https://github.com/cheasezz/file-service/blob/main/internal/grpc/download.go): `internal/grpc/download.go`
- [List handler](https://github.com/cheasezz/file-service/blob/main/internal/grpc/getAllFilesNames.go): `internal/grpc/getAllFilesNames.go`
- [Sync handler](https://github.com/cheasezz/file-service/blob/main/internal/grpc/checkFiles.go): `internal/grpc/checkFiles.go`
- [gRPC server](https://github.com/cheasezz/file-service/blob/main/internal/grpc/server.go): `internal/grpc/server.go`
- [RPC protocol](https://github.com/cheasezz/file-service/blob/main/proto/fileService.proto): `proto/fileService.proto`

### Application services

- [File service](https://github.com/cheasezz/file-service/blob/main/internal/service/service.go): `internal/service/service.go`
- [Upload writer](https://github.com/cheasezz/file-service/blob/main/internal/service/create.go): `internal/service/create.go`
- [Hash comparison](https://github.com/cheasezz/file-service/blob/main/internal/service/hashList.go): `internal/service/hashList.go`
- [File validation](https://github.com/cheasezz/file-service/blob/main/internal/core/file.go): `internal/core/file.go`
- [Domain errors](https://github.com/cheasezz/file-service/blob/main/internal/core/errors.go): `internal/core/errors.go`
- [Server assembly](https://github.com/cheasezz/file-service/blob/main/internal/app/app.go): `internal/app/app.go`
- [Configuration](https://github.com/cheasezz/file-service/blob/main/config/config.go): `config/config.go`
- [Server entry](https://github.com/cheasezz/file-service/blob/main/cmd/server/main.go): `cmd/server/main.go`

### Filesystem storage

- [Filesystem repository](https://github.com/cheasezz/file-service/blob/main/internal/repo/repo.go): `internal/repo/repo.go`
- [Stored hash lists](https://github.com/cheasezz/file-service/blob/main/internal/repo/hashList.go): `internal/repo/hashList.go`

### Other components

- **User**

## Connections

- User → Client workflow: uses (evidence: `README.md`)
- Client workflow → Local files: reads and writes (evidence: `cmd/client/main.go`)
- Client workflow → RPC protocol: calls RPCs (evidence: `cmd/client/main.go`)
- Client workflow → gRPC server: connects to (evidence: `cmd/client/main.go`)
- gRPC server → RPC protocol: registers service (evidence: `internal/grpc/server.go`)
- gRPC server → Upload handler: dispatches (evidence: `internal/grpc/server.go`)
- gRPC server → Download handler: dispatches
- gRPC server → List handler: dispatches
- gRPC server → Sync handler: dispatches
- Upload handler → File service: creates and finishes upload (evidence: `internal/grpc/upload.go`)
- Sync handler → File service: gets user hashes (evidence: `internal/grpc/checkFiles.go`)
- Download handler → File service: opens file (evidence: `README.md`)
- List handler → File service: lists names (evidence: `README.md`)
- File service → Upload writer: implements upload creation (evidence: `internal/service/create.go`)
- Upload writer → File validation: validates file info (evidence: `internal/service/create.go`)
- Upload writer → Filesystem repository: creates stored file (evidence: `internal/service/create.go`)
- File service → Filesystem repository: opens and lists files (evidence: `README.md`)
- File service → Hash comparison: loads user hashes (evidence: `internal/service/hashList.go`)
- Hash comparison → Stored hash lists: reads hash list
- File service → Domain errors: returns domain errors (evidence: `internal/service/service.go`)
- Server assembly → Filesystem repository: initializes (evidence: `internal/app/app.go`)
- Server assembly → File service: constructs (evidence: `internal/app/app.go`)
- Server assembly → gRPC server: constructs (evidence: `internal/app/app.go`)
- Server entry → Configuration: loads (evidence: `cmd/server/main.go`)
- Server entry → Server assembly: starts (evidence: `cmd/server/main.go`)
- Configuration → gRPC server: configures (evidence: `config/config.go`)
- Client workflow → Sync handler: compares hashes (evidence: `cmd/client/main.go`)
- Client workflow → Upload handler: uploads chunks (evidence: `cmd/client/main.go`)
- Client workflow → Download handler: downloads chunks (evidence: `cmd/client/main.go`)
- Client workflow → List handler: requests names (evidence: `cmd/client/main.go`)
