# mario-sh/thesocialnetwork architecture

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

- Interactive diagram: https://gitdiagram.com/mario-sh/thesocialnetwork
- Repository: https://github.com/mario-sh/thesocialnetwork

## Overview

TheSocialNetwork is a PHP/MySQL social network whose main flow is user authentication followed by feed and social interactions through AJAX endpoints. Separate branches cover friend requests, profile management, polling-based chat, and the moderator/admin back office. The README documents the frontend-to-API and API-to-MySQL architecture; sampled endpoint code confirms token validation and several domain operations. Some UI/API links and unsampled features are therefore shown only where documented, not inferred from naming.

Main entry points: [`api/auth_check.php`](https://github.com/mario-sh/thesocialnetwork/blob/main/api/auth_check.php) (Token validation), [`database/schema.sql`](https://github.com/mario-sh/thesocialnetwork/blob/main/database/schema.sql) (MySQL database), [`api/auth`](https://github.com/mario-sh/thesocialnetwork/tree/main/api/auth) (Authentication), [`vues/back-office`](https://github.com/mario-sh/thesocialnetwork/tree/main/vues/back-office) (Back-office pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_client_pages["Client pages"]
  node_browser_helpers["Browser API helpers<br/>[utils.js]"]
  node_auth_ui["Sign-in and recovery<br/>[login.html]"]
  node_feed_ui["Feed interface<br/>[accueil.html]"]
  node_friends_ui["Friends interface<br/>[amis.html]"]
  node_profile_ui["Profile interface<br/>[profil.html]"]
  node_chat_ui["Chat interface<br/>[chat.html]"]
end

subgraph group_social["Social features"]
  node_posts_api["Posts and reactions"]
  node_comments_api["Comments"]
  node_friends_api["Friend requests"]
  node_profile_api["Profile updates<br/>[update_profile.php]"]
  node_chat_api["Messaging"]
end

subgraph group_platform["API and data"]
  node_auth_api["Authentication"]
  node_auth_guard["Token validation<br/>[auth_check.php]"]
  node_api_config["API configuration<br/>[config.example.php]"]
  node_database[("MySQL database<br/>[schema.sql]")]
end

subgraph group_admin["Administration"]
  node_admin_ui["Back-office pages"]
  node_admin_auth["Admin sign-in<br/>[login_admin.php]"]
  node_admin_stats["Dashboard statistics<br/>[get_stats.php]"]
  node_admin_users["User management<br/>[manage_users.php]"]
  node_admin_posts["Post moderation<br/>[manage_posts.php]"]
end

node_visitor(("Visitor or member"))

node_visitor -->|"opens"| node_auth_ui
node_auth_ui -->|"submits credentials"| node_auth_api
node_auth_api -->|"stores and checks tokens"| node_database
node_auth_api -->|"returns token"| node_auth_ui
node_client_pages -->|"uses API helpers"| node_browser_helpers
node_browser_helpers -->|"sends AJAX requests"| node_auth_api
node_feed_ui -->|"loads and changes posts"| node_posts_api
node_feed_ui -->|"loads and adds comments"| node_comments_api
node_friends_ui -->|"manages invitations"| node_friends_api
node_profile_ui -->|"updates profile"| node_profile_api
node_chat_ui -->|"polls and sends"| node_chat_api
node_admin_ui -->|"authenticates"| node_admin_auth
node_admin_ui -->|"loads dashboard"| node_admin_stats
node_admin_ui -->|"manages users"| node_admin_users
node_admin_ui -->|"moderates posts"| node_admin_posts
node_posts_api -->|"requires token check"| node_auth_guard
node_comments_api -->|"requires token check"| node_auth_guard
node_friends_api -->|"requires token check"| node_auth_guard
node_profile_api -->|"requires token check"| node_auth_guard
node_chat_api -->|"requires token check"| node_auth_guard
node_admin_stats -->|"requires token check"| node_auth_guard
node_admin_users -->|"requires token check"| node_auth_guard
node_admin_posts -->|"requires token check"| node_auth_guard
node_auth_guard -->|"validates token against"| node_database
node_posts_api -->|"reads and writes"| node_database
node_friends_api -->|"reads and writes"| node_database
node_profile_api -->|"updates profile"| node_database
node_chat_api -->|"reads and writes messages"| node_database
node_admin_stats -->|"queries statistics"| node_database
node_admin_users -->|"reads and changes users"| node_database
node_admin_posts -->|"manages publications"| node_database
node_auth_api -.->|"protects later requests"| node_auth_guard
node_api_config -->|"configures connection"| node_database

click node_client_pages "https://github.com/mario-sh/thesocialnetwork/tree/main/vues/clients"
click node_browser_helpers "https://github.com/mario-sh/thesocialnetwork/blob/main/assets/js/utils.js"
click node_auth_ui "https://github.com/mario-sh/thesocialnetwork/blob/main/vues/clients/login.html"
click node_auth_api "https://github.com/mario-sh/thesocialnetwork/tree/main/api/auth"
click node_auth_guard "https://github.com/mario-sh/thesocialnetwork/blob/main/api/auth_check.php"
click node_feed_ui "https://github.com/mario-sh/thesocialnetwork/blob/main/vues/clients/accueil.html"
click node_posts_api "https://github.com/mario-sh/thesocialnetwork/tree/main/api/posts"
click node_comments_api "https://github.com/mario-sh/thesocialnetwork/tree/main/api/posts"
click node_friends_ui "https://github.com/mario-sh/thesocialnetwork/blob/main/vues/clients/amis.html"
click node_friends_api "https://github.com/mario-sh/thesocialnetwork/tree/main/api/friends"
click node_profile_ui "https://github.com/mario-sh/thesocialnetwork/blob/main/vues/clients/profil.html"
click node_profile_api "https://github.com/mario-sh/thesocialnetwork/blob/main/api/profile/update_profile.php"
click node_chat_ui "https://github.com/mario-sh/thesocialnetwork/blob/main/vues/clients/chat.html"
click node_chat_api "https://github.com/mario-sh/thesocialnetwork/tree/main/api/chat"
click node_admin_ui "https://github.com/mario-sh/thesocialnetwork/tree/main/vues/back-office"
click node_admin_auth "https://github.com/mario-sh/thesocialnetwork/blob/main/api/admin/login_admin.php"
click node_admin_stats "https://github.com/mario-sh/thesocialnetwork/blob/main/api/admin/get_stats.php"
click node_admin_users "https://github.com/mario-sh/thesocialnetwork/blob/main/api/admin/manage_users.php"
click node_admin_posts "https://github.com/mario-sh/thesocialnetwork/blob/main/api/admin/manage_posts.php"
click node_api_config "https://github.com/mario-sh/thesocialnetwork/blob/main/api/config.example.php"
click node_database "https://github.com/mario-sh/thesocialnetwork/blob/main/database/schema.sql"

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_client_pages,node_browser_helpers,node_auth_ui,node_feed_ui,node_friends_ui,node_profile_ui,node_chat_ui toneBlue
class node_posts_api,node_comments_api,node_friends_api,node_profile_api,node_chat_api toneAmber
class node_auth_api,node_auth_guard,node_api_config,node_database toneMint
class node_admin_ui,node_admin_auth,node_admin_stats,node_admin_users,node_admin_posts toneRose
class node_visitor toneIndigo
```

## Components

### Client experience

- [Client pages](https://github.com/mario-sh/thesocialnetwork/tree/main/vues/clients): `vues/clients`
- [Browser API helpers](https://github.com/mario-sh/thesocialnetwork/blob/main/assets/js/utils.js): `assets/js/utils.js`
- [Sign-in and recovery](https://github.com/mario-sh/thesocialnetwork/blob/main/vues/clients/login.html): `vues/clients/login.html`
- [Feed interface](https://github.com/mario-sh/thesocialnetwork/blob/main/vues/clients/accueil.html): `vues/clients/accueil.html`
- [Friends interface](https://github.com/mario-sh/thesocialnetwork/blob/main/vues/clients/amis.html): `vues/clients/amis.html`
- [Profile interface](https://github.com/mario-sh/thesocialnetwork/blob/main/vues/clients/profil.html): `vues/clients/profil.html`
- [Chat interface](https://github.com/mario-sh/thesocialnetwork/blob/main/vues/clients/chat.html): `vues/clients/chat.html`

### Social features

- [Posts and reactions](https://github.com/mario-sh/thesocialnetwork/tree/main/api/posts): `api/posts`
- [Comments](https://github.com/mario-sh/thesocialnetwork/tree/main/api/posts): `api/posts`
- [Friend requests](https://github.com/mario-sh/thesocialnetwork/tree/main/api/friends): `api/friends`
- [Profile updates](https://github.com/mario-sh/thesocialnetwork/blob/main/api/profile/update_profile.php): `api/profile/update_profile.php`
- [Messaging](https://github.com/mario-sh/thesocialnetwork/tree/main/api/chat): `api/chat`

### API and data

- [Authentication](https://github.com/mario-sh/thesocialnetwork/tree/main/api/auth): `api/auth`
- [Token validation](https://github.com/mario-sh/thesocialnetwork/blob/main/api/auth_check.php): `api/auth_check.php`
- [API configuration](https://github.com/mario-sh/thesocialnetwork/blob/main/api/config.example.php): `api/config.example.php`
- [MySQL database](https://github.com/mario-sh/thesocialnetwork/blob/main/database/schema.sql): `database/schema.sql`

### Administration

- [Back-office pages](https://github.com/mario-sh/thesocialnetwork/tree/main/vues/back-office): `vues/back-office`
- [Admin sign-in](https://github.com/mario-sh/thesocialnetwork/blob/main/api/admin/login_admin.php): `api/admin/login_admin.php`
- [Dashboard statistics](https://github.com/mario-sh/thesocialnetwork/blob/main/api/admin/get_stats.php): `api/admin/get_stats.php`
- [User management](https://github.com/mario-sh/thesocialnetwork/blob/main/api/admin/manage_users.php): `api/admin/manage_users.php`
- [Post moderation](https://github.com/mario-sh/thesocialnetwork/blob/main/api/admin/manage_posts.php): `api/admin/manage_posts.php`

### Other components

- **Visitor or member**

## Connections

- Visitor or member → Sign-in and recovery: opens (evidence: `README.md`)
- Sign-in and recovery → Authentication: submits credentials (evidence: `README.md`)
- Authentication → MySQL database: stores and checks tokens (evidence: `README.md`)
- Authentication → Sign-in and recovery: returns token (evidence: `README.md`)
- Client pages → Browser API helpers: uses API helpers (evidence: `README.md`)
- Browser API helpers → Authentication: sends AJAX requests (evidence: `README.md`)
- Feed interface → Posts and reactions: loads and changes posts (evidence: `README.md`)
- Feed interface → Comments: loads and adds comments (evidence: `README.md`)
- Friends interface → Friend requests: manages invitations (evidence: `README.md`)
- Profile interface → Profile updates: updates profile (evidence: `README.md`)
- Chat interface → Messaging: polls and sends (evidence: `README.md`)
- Back-office pages → Admin sign-in: authenticates (evidence: `README.md`)
- Back-office pages → Dashboard statistics: loads dashboard (evidence: `README.md`)
- Back-office pages → User management: manages users (evidence: `README.md`)
- Back-office pages → Post moderation: moderates posts (evidence: `README.md`)
- Posts and reactions → Token validation: requires token check (evidence: `api/posts/get_posts.php`)
- Comments → Token validation: requires token check (evidence: `api/posts/add_comment.php`)
- Friend requests → Token validation: requires token check (evidence: `api/friends/get_friends.php`)
- Profile updates → Token validation: requires token check (evidence: `api/profile/update_profile.php`)
- Messaging → Token validation: requires token check (evidence: `api/chat/get_messages.php`)
- Dashboard statistics → Token validation: requires token check (evidence: `api/admin/get_stats.php`)
- User management → Token validation: requires token check (evidence: `api/admin/manage_users.php`)
- Post moderation → Token validation: requires token check (evidence: `api/admin/manage_posts.php`)
- Token validation → MySQL database: validates token against (evidence: `api/auth_check.php`)
- Posts and reactions → MySQL database: reads and writes (evidence: `api/posts/get_posts.php`)
- Friend requests → MySQL database: reads and writes (evidence: `api/friends/get_friends.php`)
- Profile updates → MySQL database: updates profile (evidence: `api/profile/update_profile.php`)
- Messaging → MySQL database: reads and writes messages (evidence: `api/chat/get_messages.php`)
- Dashboard statistics → MySQL database: queries statistics (evidence: `api/admin/get_stats.php`)
- User management → MySQL database: reads and changes users (evidence: `api/admin/manage_users.php`)
- Post moderation → MySQL database: manages publications (evidence: `README.md`)
- Authentication → Token validation: protects later requests (evidence: `README.md`)
- API configuration → MySQL database: configures connection (evidence: `README.md`)
