# noorthistime/fosseeusersystem architecture

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

- Interactive diagram: https://gitdiagram.com/noorthistime/fosseeusersystem
- Repository: https://github.com/noorthistime/fosseeusersystem

## Overview

This repository provides a dual-backend authentication and file-access system: a custom Node.js/PostgreSQL implementation and an Appwrite adapter, plus a browser mock backend for demonstration. The principal workflow is registration or login, token-based access to the current profile and tenant-isolated files, and logout; file details and downloads are separate protected stages. The diagram focuses on runtime behavior and documented persistence/integrations. Source excerpts support the main route and service relationships; some custom middleware behavior and the browser page’s implementation were not sampled.

Main entry points: [`appwrite-backend/src/server.js`](https://github.com/noorthistime/fosseeusersystem/blob/main/appwrite-backend/src/server.js) (Auth & File Routes), [`index.html`](https://github.com/noorthistime/fosseeusersystem/blob/main/index.html) (Browser Client), [`custom-backend/src/server.js`](https://github.com/noorthistime/fosseeusersystem/blob/main/custom-backend/src/server.js) (Auth & File Routes), [`mock-api.js`](https://github.com/noorthistime/fosseeusersystem/blob/main/mock-api.js) (Mock API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser Demo"]
  node_browser["Browser Client<br/>[index.html]"]
  node_mock["Mock API<br/>[mock-api.js]"]
  node_seed["Seed Data<br/>[seed-data.json]"]
end

subgraph group_custom["Custom Backend"]
  node_custom_routes["Auth &amp; File Routes<br/>[server.js]"]
  node_custom_auth["Auth Middleware<br/>[middlewares.js]"]
  node_custom_db["Database Pool<br/>[db.js]"]
  node_custom_schema["SQL Schema<br/>[migrations.js]"]
end

subgraph group_appwrite["Appwrite Adapter"]
  node_appwrite_routes["Auth &amp; File Routes<br/>[server.js]"]
end

subgraph group_services["Persistence Services"]
  node_postgres[("PostgreSQL")]
  node_local_files[("Local File Storage")]
  node_aw_auth["Appwrite Auth"]
  node_aw_database[("Appwrite Database")]
  node_aw_storage[("Appwrite Storage")]
end

node_user(("User"))

node_user -->|"uses"| node_browser
node_browser -->|"intercepts fetch"| node_mock
node_mock -->|"loads"| node_seed
node_browser -.->|"calls API"| node_custom_routes
node_browser -.->|"calls API"| node_appwrite_routes
node_custom_routes -->|"guards routes"| node_custom_auth
node_custom_routes -->|"queries"| node_custom_db
node_custom_auth -->|"checks revocation"| node_postgres
node_custom_db -->|"connects"| node_postgres
node_custom_schema -->|"creates tables"| node_postgres
node_custom_routes -->|"streams downloads"| node_local_files
node_appwrite_routes -->|"creates sessions"| node_aw_auth
node_appwrite_routes -->|"revokes sessions"| node_aw_auth
node_appwrite_routes -->|"reads profiles"| node_aw_database
node_appwrite_routes -->|"lists files"| node_aw_database
node_appwrite_routes -->|"downloads files"| node_aw_storage

click node_browser "https://github.com/noorthistime/fosseeusersystem/blob/main/index.html"
click node_mock "https://github.com/noorthistime/fosseeusersystem/blob/main/mock-api.js"
click node_seed "https://github.com/noorthistime/fosseeusersystem/blob/main/seed-data.json"
click node_custom_routes "https://github.com/noorthistime/fosseeusersystem/blob/main/custom-backend/src/server.js"
click node_custom_auth "https://github.com/noorthistime/fosseeusersystem/blob/main/custom-backend/src/middlewares.js"
click node_custom_db "https://github.com/noorthistime/fosseeusersystem/blob/main/custom-backend/src/db.js"
click node_custom_schema "https://github.com/noorthistime/fosseeusersystem/blob/main/custom-backend/src/migrations.js"
click node_appwrite_routes "https://github.com/noorthistime/fosseeusersystem/blob/main/appwrite-backend/src/server.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_browser,node_mock,node_seed,node_user toneBlue
class node_custom_routes,node_custom_auth,node_custom_db,node_custom_schema toneAmber
class node_appwrite_routes toneMint
class node_postgres,node_local_files,node_aw_auth,node_aw_database,node_aw_storage toneRose
```

## Components

### Browser Demo

- [Browser Client](https://github.com/noorthistime/fosseeusersystem/blob/main/index.html): `index.html`
- [Mock API](https://github.com/noorthistime/fosseeusersystem/blob/main/mock-api.js): `mock-api.js`
- [Seed Data](https://github.com/noorthistime/fosseeusersystem/blob/main/seed-data.json): `seed-data.json`

### Custom Backend

- [Auth & File Routes](https://github.com/noorthistime/fosseeusersystem/blob/main/custom-backend/src/server.js): `custom-backend/src/server.js`
- [Auth Middleware](https://github.com/noorthistime/fosseeusersystem/blob/main/custom-backend/src/middlewares.js): `custom-backend/src/middlewares.js`
- [Database Pool](https://github.com/noorthistime/fosseeusersystem/blob/main/custom-backend/src/db.js): `custom-backend/src/db.js`
- [SQL Schema](https://github.com/noorthistime/fosseeusersystem/blob/main/custom-backend/src/migrations.js): `custom-backend/src/migrations.js`

### Appwrite Adapter

- [Auth & File Routes](https://github.com/noorthistime/fosseeusersystem/blob/main/appwrite-backend/src/server.js): `appwrite-backend/src/server.js`

### Persistence Services

- **PostgreSQL**
- **Local File Storage**
- **Appwrite Auth**
- **Appwrite Database**
- **Appwrite Storage**

### Other components

- **User**

## Connections

- User → Browser Client: uses (evidence: `README.md`)
- Browser Client → Mock API: intercepts fetch (evidence: `mock-api.js`)
- Mock API → Seed Data: loads (evidence: `mock-api.js`)
- Browser Client → Auth & File Routes: calls API (evidence: `README.md`)
- Browser Client → Auth & File Routes: calls API (evidence: `README.md`)
- Auth & File Routes → Auth Middleware: guards routes (evidence: `custom-backend/src/server.js`)
- Auth & File Routes → Database Pool: queries (evidence: `custom-backend/src/server.js`)
- Auth Middleware → PostgreSQL: checks revocation (evidence: `README.md`)
- Database Pool → PostgreSQL: connects (evidence: `custom-backend/src/db.js`)
- SQL Schema → PostgreSQL: creates tables (evidence: `custom-backend/src/migrations.js`)
- Auth & File Routes → Local File Storage: streams downloads (evidence: `custom-backend/src/server.js`)
- Auth & File Routes → Appwrite Auth: creates sessions (evidence: `appwrite-backend/src/server.js`)
- Auth & File Routes → Appwrite Auth: revokes sessions (evidence: `appwrite-backend/src/server.js`)
- Auth & File Routes → Appwrite Database: reads profiles (evidence: `appwrite-backend/src/server.js`)
- Auth & File Routes → Appwrite Database: lists files (evidence: `appwrite-backend/src/server.js`)
- Auth & File Routes → Appwrite Storage: downloads files (evidence: `appwrite-backend/src/server.js`)
