# abhi-95-18/trustshare architecture

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

- Interactive diagram: https://gitdiagram.com/abhi-95-18/trustshare
- Repository: https://github.com/abhi-95-18/trustshare

## Overview

TrustShare is a web platform for encrypted file management and controlled collaboration. Users authenticate through the frontend and FastAPI, then manage files, folders, and shares; the backend also records activity and exposes monitoring capabilities. The README documents PostgreSQL, MongoDB, and Redis roles, while sampled source confirms file encryption/storage and audit behavior. Frontend-to-API and documented infrastructure links are shown at the system level; unsampled page-to-endpoint wiring is not inferred.

Main entry points: [`backend/app/main.py`](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/services/audit.py`](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/audit.py) (Audit and activity), [`backend/app/core/database.py`](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/core/database.py) (PostgreSQL), [`backend/app/api/auth.py`](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/api/auth.py) (Authentication routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_frontend["Next.js interface"]
  node_api_client["API client<br/>[api.ts]"]
  node_auth_tokens["Token storage<br/>[auth.ts]"]
end

subgraph group_api["API and identity"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_auth_api["Authentication routes<br/>[auth.py]"]
  node_auth_service["Identity and sessions<br/>[auth.py]"]
  node_auth_guard["JWT authorization<br/>[dependencies.py]"]
end

subgraph group_files["File collaboration"]
  node_files_api["File operations<br/>[files.py]"]
  node_folders_api["Folder operations<br/>[folders.py]"]
  node_folder_service["Folder logic<br/>[folder.py]"]
  node_file_processing["Encryption workflow<br/>[file_utils.py]"]
  node_encryption["File encryption<br/>[encryption.py]"]
  node_storage["Encrypted storage<br/>[storage.py]"]
  node_shares_api["Sharing routes<br/>[shares.py]"]
  node_share_records["Share and session records<br/>[collaboration.py]"]
end

subgraph group_security["Security and monitoring"]
  node_monitor_api["Monitoring routes<br/>[monitoring.py]"]
  node_audit["Audit and activity<br/>[audit.py]"]
  node_security_monitor["Security detection"]
  node_notifications["Notifications<br/>[notifications.py]"]
end

subgraph group_persistence["Persistence"]
  node_postgres[("PostgreSQL<br/>[database.py]")]
  node_mongodb[("MongoDB<br/>[mongodb.py]")]
  node_redis[("Redis<br/>[redis.py]")]
end

node_user(("User"))
node_object_storage[("S3 storage")]

node_user -->|"uses"| node_frontend
node_frontend -.->|"requests through"| node_api_client
node_api_client -->|"uses"| node_auth_tokens
node_frontend -->|"calls REST API"| node_fastapi
node_fastapi -->|"registers"| node_auth_api
node_fastapi -->|"registers"| node_files_api
node_fastapi -->|"registers"| node_folders_api
node_fastapi -->|"registers"| node_shares_api
node_fastapi -->|"registers"| node_monitor_api
node_auth_api -->|"delegates to"| node_auth_service
node_auth_api -->|"depends on"| node_auth_guard
node_auth_api -->|"uses OAuth state"| node_redis
node_auth_api -->|"records activity"| node_audit
node_auth_service -->|"persists identity"| node_postgres
node_auth_guard -->|"checks sessions"| node_postgres
node_files_api -->|"processes files"| node_file_processing
node_files_api -->|"records activity"| node_audit
node_files_api -->|"reads and writes"| node_postgres
node_file_processing -->|"uses"| node_encryption
node_file_processing -->|"uses"| node_storage
node_storage -.->|"stores objects"| node_object_storage
node_folders_api -->|"delegates to"| node_folder_service
node_folders_api -->|"reads and writes"| node_postgres
node_shares_api -->|"manages"| node_share_records
node_shares_api -->|"records activity"| node_audit
node_shares_api -->|"notifies users"| node_notifications
node_shares_api -->|"reads and writes"| node_postgres
node_monitor_api -->|"queries activity"| node_audit
node_monitor_api -->|"uses"| node_notifications
node_audit -->|"stores events"| node_mongodb
node_fastapi -->|"health checks"| node_postgres
node_fastapi -->|"health checks"| node_mongodb
node_fastapi -->|"health checks"| node_redis
node_security_monitor -.->|"analyzes activity"| node_audit

click node_frontend "https://github.com/abhi-95-18/trustshare/tree/main/frontend/app"
click node_api_client "https://github.com/abhi-95-18/trustshare/blob/main/frontend/lib/api.ts"
click node_auth_tokens "https://github.com/abhi-95-18/trustshare/blob/main/frontend/lib/auth.ts"
click node_fastapi "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/main.py"
click node_auth_api "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/api/auth.py"
click node_auth_service "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/auth.py"
click node_auth_guard "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/api/dependencies.py"
click node_files_api "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/api/files.py"
click node_folders_api "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/api/folders.py"
click node_folder_service "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/folder.py"
click node_file_processing "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/file_utils.py"
click node_encryption "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/encryption.py"
click node_storage "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/storage.py"
click node_shares_api "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/api/shares.py"
click node_share_records "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/models/collaboration.py"
click node_monitor_api "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/api/monitoring.py"
click node_audit "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/audit.py"
click node_security_monitor "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/security_monitor.py"
click node_notifications "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/notifications.py"
click node_postgres "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/core/database.py"
click node_mongodb "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/core/mongodb.py"
click node_redis "https://github.com/abhi-95-18/trustshare/blob/main/backend/app/core/redis.py"

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_frontend,node_api_client,node_auth_tokens,node_user toneBlue
class node_fastapi,node_auth_api,node_auth_service,node_auth_guard,node_object_storage toneAmber
class node_files_api,node_folders_api,node_folder_service,node_file_processing,node_encryption,node_storage,node_shares_api,node_share_records toneMint
class node_monitor_api,node_audit,node_security_monitor,node_notifications toneRose
class node_postgres,node_mongodb,node_redis toneIndigo
```

## Components

### Web client

- [Next.js interface](https://github.com/abhi-95-18/trustshare/tree/main/frontend/app): `frontend/app`
- [API client](https://github.com/abhi-95-18/trustshare/blob/main/frontend/lib/api.ts): `frontend/lib/api.ts`
- [Token storage](https://github.com/abhi-95-18/trustshare/blob/main/frontend/lib/auth.ts): `frontend/lib/auth.ts`

### API and identity

- [FastAPI application](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication routes](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [Identity and sessions](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/auth.py): `backend/app/services/auth.py`
- [JWT authorization](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/api/dependencies.py): `backend/app/api/dependencies.py`

### File collaboration

- [File operations](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/api/files.py): `backend/app/api/files.py`
- [Folder operations](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/api/folders.py): `backend/app/api/folders.py`
- [Folder logic](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/folder.py): `backend/app/services/folder.py`
- [Encryption workflow](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/file_utils.py): `backend/app/services/file_utils.py`
- [File encryption](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/encryption.py): `backend/app/services/encryption.py`
- [Encrypted storage](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/storage.py): `backend/app/services/storage.py`
- [Sharing routes](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/api/shares.py): `backend/app/api/shares.py`
- [Share and session records](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/models/collaboration.py): `backend/app/models/collaboration.py`

### Security and monitoring

- [Monitoring routes](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/api/monitoring.py): `backend/app/api/monitoring.py`
- [Audit and activity](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/audit.py): `backend/app/services/audit.py`
- [Security detection](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/security_monitor.py): `backend/app/services/security_monitor.py`
- [Notifications](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/services/notifications.py): `backend/app/services/notifications.py`

### Persistence

- [PostgreSQL](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/core/database.py): `backend/app/core/database.py`
- [MongoDB](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/core/mongodb.py): `backend/app/core/mongodb.py`
- [Redis](https://github.com/abhi-95-18/trustshare/blob/main/backend/app/core/redis.py): `backend/app/core/redis.py`

### Other components

- **User**
- **S3 storage**

## Connections

- User → Next.js interface: uses (evidence: `README.md`)
- Next.js interface → API client: requests through
- API client → Token storage: uses (evidence: `frontend/lib/api.ts`)
- Next.js interface → FastAPI application: calls REST API (evidence: `README.md`)
- FastAPI application → Authentication routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → File operations: registers (evidence: `backend/app/main.py`)
- FastAPI application → Folder operations: registers (evidence: `backend/app/main.py`)
- FastAPI application → Sharing routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Monitoring routes: registers (evidence: `backend/app/main.py`)
- Authentication routes → Identity and sessions: delegates to (evidence: `backend/app/api/auth.py`)
- Authentication routes → JWT authorization: depends on (evidence: `backend/app/api/auth.py`)
- Authentication routes → Redis: uses OAuth state (evidence: `backend/app/api/auth.py`)
- Authentication routes → Audit and activity: records activity (evidence: `backend/app/api/auth.py`)
- Identity and sessions → PostgreSQL: persists identity (evidence: `backend/app/services/auth.py`)
- JWT authorization → PostgreSQL: checks sessions (evidence: `backend/app/api/dependencies.py`)
- File operations → Encryption workflow: processes files (evidence: `backend/app/api/files.py`)
- File operations → Audit and activity: records activity (evidence: `backend/app/api/files.py`)
- File operations → PostgreSQL: reads and writes (evidence: `backend/app/api/files.py`)
- Encryption workflow → File encryption: uses (evidence: `backend/app/services/file_utils.py`)
- Encryption workflow → Encrypted storage: uses (evidence: `backend/app/services/file_utils.py`)
- Encrypted storage → S3 storage: stores objects
- Folder operations → Folder logic: delegates to (evidence: `backend/app/api/folders.py`)
- Folder operations → PostgreSQL: reads and writes (evidence: `backend/app/api/folders.py`)
- Sharing routes → Share and session records: manages (evidence: `backend/app/api/shares.py`)
- Sharing routes → Audit and activity: records activity (evidence: `backend/app/api/shares.py`)
- Sharing routes → Notifications: notifies users (evidence: `backend/app/api/shares.py`)
- Sharing routes → PostgreSQL: reads and writes (evidence: `backend/app/api/shares.py`)
- Monitoring routes → Audit and activity: queries activity (evidence: `backend/app/api/monitoring.py`)
- Monitoring routes → Notifications: uses (evidence: `backend/app/api/monitoring.py`)
- Audit and activity → MongoDB: stores events (evidence: `backend/app/services/audit.py`)
- FastAPI application → PostgreSQL: health checks (evidence: `backend/app/main.py`)
- FastAPI application → MongoDB: health checks (evidence: `backend/app/main.py`)
- FastAPI application → Redis: health checks (evidence: `backend/app/main.py`)
- Security detection → Audit and activity: analyzes activity
