# kyldpr/cloudspacephv1 architecture

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

- Interactive diagram: https://gitdiagram.com/kyldpr/cloudspacephv1
- Repository: https://github.com/kyldpr/cloudspacephv1

## Overview

1. This repository is a small PHP application with a file-backed API layer rather than a traditional database-backed backend. The core runtime is PHP, likely served through Apache, with `.htaccess` handling routing and/or access rules.

2. There are two visible UI entry points at the repo root: `login.php` and `dashboard.php`. These appear to be the main browser-facing pages, while the business logic lives under `api/` and is consumed by those pages.

3. Authentication is separated into its own boundary:
   - `auth-api.php` is the main auth endpoint.
   - `api/jwt-helper.php` suggests token creation/validation via JWT.
   - `.env` likely stores secrets or environment-specific configuration.
   This indicates session/auth state is probably token-based rather than database session-driven.

4. User profile data is stored in `api/profiles/users/*.json`. Each user has a dedicated JSON file, and there is also a `logs/` subfolder for per-user activity or audit records. This means profile reads/writes are file operations, not SQL queries.

5. The forum subsystem is under `api/forums/` and is split into multiple responsibilities:
   - `forums-api.php` for post/comment operations.
   - `image.php` for image-related handling.
   - `post/` for forum post records.
   - `commnents/` for comment records and indexes.
   This is the main domain area of the app.

6. Forum storage is normalized through multiple JSON views of the same data. Posts live in `api/forums/post/post_*.json`, while comments are stored both by post and by participant:
   - `api/forums/commnents/post_*.json`
   - `api/forums/commnents/by_author/*.json`
   - `api/forums/commnents/by_commenter/*.json`
   This suggests the application builds lookup indexes on disk to support different query patterns.

7. Images are handled separately from structured JSON data. The presence of `api/forums/images/` and top-level `storage/images/` indicates uploaded media is persisted as files, with metadata or references likely stored in the JSON records for posts/comments.

8. The data flow is likely:
   user logs in through `login.php` → auth endpoint issues/validates a token via `auth-api.php` and `jwt-helper.php` → `dashboard.php` uses that token to call profile/forum APIs → APIs read/write JSON files under `api/profiles/` and `api/forums/` → image uploads are written to image directories and referenced from JSON.

9. The repository structure implies a clear boundary between presentation and persistence, but persistence is unconventional: it is filesystem-based and organized by entity type and secondary indexes. Any architecture diagram should show JSON file collections as the primary datastore, not an external DB service.

10. The main external dependency implied by the tree is Apache/PHP, with server configuration in `.htaccess`. There are no signs of frameworks, message queues, or third-party services in the tree, so the system is essentially a self-contained PHP monolith with modular API endpoints and file storage.

Main entry points: [`api/forums/forums-api.php`](https://github.com/kyldpr/cloudspacephv1/blob/main/api/forums/forums-api.php) (Forums API), [`auth-api.php`](https://github.com/kyldpr/cloudspacephv1/blob/main/auth-api.php) (Auth API), [`.htaccess`](https://github.com/kyldpr/cloudspacephv1/blob/main/.htaccess) (Apache rules), [`dashboard.php`](https://github.com/kyldpr/cloudspacephv1/blob/main/dashboard.php) (Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_login_php["Login<br/>UI entry<br/>[login.php]"]
  node_dashboard_php["Dashboard<br/>UI entry<br/>[dashboard.php]"]
end

subgraph group_api["API"]
  node_auth_api["Auth API<br/>auth endpoint<br/>[auth-api.php]"]
  node_jwt_helper["JWT helper<br/>token helper<br/>[jwt-helper.php]"]
  node_forums_api["Forums API<br/>domain API<br/>[forums-api.php]"]
  node_image_api["Image API<br/>media endpoint<br/>[image.php]"]
end

subgraph group_storage["Storage"]
  node_profiles_store[("User profiles<br/>file datastore")]
  node_profile_logs[("Profile logs<br/>audit store")]
  node_forum_posts[("Forum posts<br/>post store")]
  node_forum_comments[("Forum comments<br/>comment store")]
  node_comments_by_author[("By author<br/>comment index")]
  node_comments_by_commenter[("By commenter<br/>comment index")]
  node_forum_images[("Forum images<br/>media store")]
  node_storage_images[("Images<br/>media store")]
end

subgraph group_config["Config"]
  node_htaccess["Apache rules<br/>server config<br/>[.htaccess]"]
  node_env["Secrets<br/>env config<br/>[.env]"]
end

node_htaccess -->|"routes to"| node_login_php
node_htaccess -->|"routes to"| node_dashboard_php
node_htaccess -->|"routes to"| node_auth_api
node_htaccess -->|"routes to"| node_forums_api
node_login_php -->|"authenticates via"| node_auth_api
node_dashboard_php -->|"validates token"| node_auth_api
node_dashboard_php -->|"uses"| node_forums_api
node_dashboard_php -->|"loads profile"| node_profiles_store
node_auth_api -->|"uses"| node_jwt_helper
node_auth_api -->|"reads secrets"| node_env
node_forums_api -->|"reads/writes"| node_forum_posts
node_forums_api -->|"reads/writes"| node_forum_comments
node_forums_api -->|"stores media"| node_forum_images
node_image_api -->|"serves/uploads"| node_forum_images
node_image_api -->|"stores media"| node_storage_images
node_profiles_store -->|"tracks"| node_profile_logs
node_forum_comments -->|"indexed by"| node_comments_by_author
node_forum_comments -->|"indexed by"| node_comments_by_commenter

click node_login_php "https://github.com/kyldpr/cloudspacephv1/blob/main/login.php"
click node_dashboard_php "https://github.com/kyldpr/cloudspacephv1/blob/main/dashboard.php"
click node_htaccess "https://github.com/kyldpr/cloudspacephv1/blob/main/.htaccess"
click node_env "https://github.com/kyldpr/cloudspacephv1/blob/main/.env"
click node_auth_api "https://github.com/kyldpr/cloudspacephv1/blob/main/auth-api.php"
click node_jwt_helper "https://github.com/kyldpr/cloudspacephv1/blob/main/api/jwt-helper.php"
click node_forums_api "https://github.com/kyldpr/cloudspacephv1/blob/main/api/forums/forums-api.php"
click node_image_api "https://github.com/kyldpr/cloudspacephv1/blob/main/api/forums/image.php"
click node_profiles_store "https://github.com/kyldpr/cloudspacephv1/tree/main/api/profiles/users"
click node_profile_logs "https://github.com/kyldpr/cloudspacephv1/tree/main/api/profiles/users/logs"
click node_forum_posts "https://github.com/kyldpr/cloudspacephv1/tree/main/api/forums/post"
click node_forum_comments "https://github.com/kyldpr/cloudspacephv1/tree/main/api/forums/commnents"
click node_comments_by_author "https://github.com/kyldpr/cloudspacephv1/tree/main/api/forums/commnents/by_author"
click node_comments_by_commenter "https://github.com/kyldpr/cloudspacephv1/tree/main/api/forums/commnents/by_commenter"
click node_forum_images "https://github.com/kyldpr/cloudspacephv1/tree/main/api/forums/images"
click node_storage_images "https://github.com/kyldpr/cloudspacephv1/tree/main/storage/images"

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_login_php,node_dashboard_php toneBlue
class node_auth_api,node_jwt_helper,node_forums_api,node_image_api toneAmber
class node_profiles_store,node_profile_logs,node_forum_posts,node_forum_comments,node_comments_by_author,node_comments_by_commenter,node_forum_images,node_storage_images toneMint
class node_htaccess,node_env toneRose
```

## Components

### Presentation

Browser entry points and request routing

- [Login](https://github.com/kyldpr/cloudspacephv1/blob/main/login.php): UI entry · Browser login page · `login.php`
- [Dashboard](https://github.com/kyldpr/cloudspacephv1/blob/main/dashboard.php): UI entry · Authenticated browser view · `dashboard.php`

### API

Authentication, profile, and forum endpoints

- [Auth API](https://github.com/kyldpr/cloudspacephv1/blob/main/auth-api.php): auth endpoint · Issues and validates login tokens · `auth-api.php`
- [JWT helper](https://github.com/kyldpr/cloudspacephv1/blob/main/api/jwt-helper.php): token helper · JWT encode and decode logic · `api/jwt-helper.php`
- [Forums API](https://github.com/kyldpr/cloudspacephv1/blob/main/api/forums/forums-api.php): domain API · Posts, comments, and forum workflows · `api/forums/forums-api.php`
- [Image API](https://github.com/kyldpr/cloudspacephv1/blob/main/api/forums/image.php): media endpoint · Forum image handling · `api/forums/image.php`

### Storage

Filesystem-backed JSON and image persistence

- [User profiles](https://github.com/kyldpr/cloudspacephv1/tree/main/api/profiles/users): file datastore · Per-user profile JSON records · `api/profiles/users`
- [Profile logs](https://github.com/kyldpr/cloudspacephv1/tree/main/api/profiles/users/logs): audit store · Per-user activity logs · `api/profiles/users/logs`
- [Forum posts](https://github.com/kyldpr/cloudspacephv1/tree/main/api/forums/post): post store · Post JSON records by post id · `api/forums/post`
- [Forum comments](https://github.com/kyldpr/cloudspacephv1/tree/main/api/forums/commnents): comment store · Comment JSON records and indexes · `api/forums/commnents`
- [By author](https://github.com/kyldpr/cloudspacephv1/tree/main/api/forums/commnents/by_author): comment index · Comment lookup indexed by author · `api/forums/commnents/by_author`
- [By commenter](https://github.com/kyldpr/cloudspacephv1/tree/main/api/forums/commnents/by_commenter): comment index · Comment lookup indexed by commenter · `api/forums/commnents/by_commenter`
- [Forum images](https://github.com/kyldpr/cloudspacephv1/tree/main/api/forums/images): media store · Uploaded forum image files · `api/forums/images`
- [Images](https://github.com/kyldpr/cloudspacephv1/tree/main/storage/images): media store · Top-level image storage · `storage/images`

### Config

Runtime and server configuration

- [Apache rules](https://github.com/kyldpr/cloudspacephv1/blob/main/.htaccess): server config · Routing and access rules · `.htaccess`
- [Secrets](https://github.com/kyldpr/cloudspacephv1/blob/main/.env): env config · Environment configuration and secrets · `.env`

## Connections

- Apache rules → Login: routes to · Server routes browser traffic to the login page
- Apache rules → Dashboard: routes to · Server routes browser traffic to the dashboard
- Apache rules → Auth API: routes to · Server exposes the auth endpoint
- Apache rules → Forums API: routes to · Server exposes the forum API
- Login → Auth API: authenticates via · Login page submits credentials to auth
- Dashboard → Auth API: validates token · Dashboard depends on token-backed auth
- Dashboard → Forums API: uses · Dashboard reads and writes forum data
- Dashboard → User profiles: loads profile · Dashboard reads user profile state
- Auth API → JWT helper: uses · Auth endpoint delegates token work to JWT helper
- Auth API → Secrets: reads secrets · Auth endpoint depends on environment configuration
- Forums API → Forum posts: reads/writes · Forum API persists posts as JSON files
- Forums API → Forum comments: reads/writes · Forum API persists comments and indexes
- Forums API → Forum images: stores media · Forum API manages uploaded forum images
- Image API → Forum images: serves/uploads · Image endpoint works with forum image files
- Image API → Images: stores media · Image handling also writes to shared image storage
- User profiles → Profile logs: tracks · Profile records have per-user activity logs
- Forum comments → By author: indexed by · Comment records are mirrored by author
- Forum comments → By commenter: indexed by · Comment records are mirrored by commenter
