# rjoserivera/austral_collector architecture

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

- Interactive diagram: https://gitdiagram.com/rjoserivera/austral_collector
- Repository: https://github.com/rjoserivera/austral_collector

## Overview

1. **Overall shape**
   - Austral Collector is a split architecture: a **React/Vite single-page frontend** in `src/` and a **PHP REST-style backend** in `api/`.
   - The backend persists to **MySQL via PDO** and stores user-uploaded media under `uploads/`.

2. **Frontend presentation layer**
   - `src/main.jsx`, `src/App.jsx`, and `src/pages/` define the routed application shell and page-level views.
   - The main pages map to the product areas in the README: **home, miembros, perfil público, portafolio, galería, contacto, login, dashboard, and admin**.
   - `src/components/` holds reusable UI blocks such as banners, post modals, featured member cards, voting/ranking sections, videos, footer, and navigation.

3. **Frontend data consumption**
   - The React UI is mostly a **consumer of backend JSON endpoints** rather than a server-rendered app.
   - `src/config.js` likely centralizes environment/API configuration, while `src/hooks/useSyncStatus.jsx` and `src/utils/offlineSync.js` indicate the app tracks connectivity and queues sync work when offline.

4. **Public content API**
   - `api/public/` exposes read-only endpoints for the non-authenticated parts of the site:
     - `home_data.php`
     - `miembros_data.php`
     - `perfil_data.php`
     - `portafolio_data.php`
     - `galeria_data.php`
     - `contacto.php`
     - `identidad.php`
     - `get_hashtags.php`
   - These endpoints feed the landing page, community listings, profile pages, portfolio/gallery content, and contact/identity data.

5. **Authenticated user API**
   - `api/auth/` contains the actions for logged-in community members:
     - `login.php`
     - `jwt_helper.php`
     - `update_profile.php`
     - `editar_post.php`
     - `publicar_post.php`
     - `reordenar_posts.php`
     - `toggle_like.php`
     - `rate_profile.php`
     - `delete_rating.php`
     - `enviar_clave_temporal.php`
   - This is the main write path for profile updates, content creation/moderation actions, likes, and ratings.

6. **Admin subsystem**
   - `api/admin/` is the privileged back office boundary.
   - It includes authentication checks and management endpoints for:
     - `usuarios.php`
     - `publicaciones.php`
     - `eventos.php`
     - `videos.php`
     - `destacados.php`
     - `galeria_portafolio.php`
     - `identidad_admin.php`
     - operational reporting via `get_stats.php`, `get_activity_log.php`
     - admin messaging via `enviar_mensaje.php`
   - `src/pages/AdminPage.jsx` and `DashboardPage.jsx` likely consume this layer for moderation and analytics.

7. **Backend shared infrastructure**
   - `api/db.php` is the shared database connection/bootstrap used by all API groups.
   - `api/index.php` is the likely API entry point or landing endpoint, while `api/test_db.php` and `api/fix_logs.php` suggest maintenance/diagnostic utilities.
   - `api/events.php` and `api/figures.php` sit outside the folder namespaces and likely serve core domain data used across the site.

8. **Data and file storage boundaries**
   - The database holds structured entities such as users, profiles, posts, events, ratings, and activity logs.
   - Uploaded or generated media is stored separately in `uploads/eventos`, `uploads/posts`, and `uploads/profiles`, which means the architecture splits **metadata in MySQL** from **binary assets on disk**.
   - This is important for diagramming because most content flows involve both a database write and an asset upload/write.

9. **Authentication and trust model**
   - Authentication is JWT-based, with `login.php` issuing tokens and `jwt_helper.php` enforcing them for protected routes.
   - The backend has a clear trust boundary: **public endpoints require no token**, **auth endpoints require a user token**, and **admin endpoints require elevated verification** via `auth_check.php`.

10. **Offline/PWA behavior**
   - `dev-dist/` contains service worker artifacts, and the README mentions **vite-plugin-pwa** plus **IndexedDB**.
   - The app therefore supports a **progressive web app layer** with cached assets and local persistence for offline interaction, with `offlineSync.js` handling reconciliation when connectivity returns.

11. **Documentation as a separate artifact**
   - `docs/` is a standalone **Mintlify** documentation site, not part of runtime application flow.
   - It documents architecture, installation, API authentication, figures, and the admin panel, so it should be shown separately from the production data path.

12. **Runtime and deployment assumptions**
   - The stack targets **Node.js/Vite** for frontend development and **PHP 8 + Apache/MySQL** for backend execution, typically via **XAMPP** locally.
   - `index.html`, `vite.config.js`, `eslint.config.js`, and `package.json` define the frontend build/runtime toolchain, while `requirements.txt` appears ancillary and not central to the main app flow.

13. **Primary end-to-end flows**
   - **Public visitor flow:** browser loads React app → pages fetch public JSON from `api/public/*` and core endpoints → content renders without login.
   - **Member flow:** user logs in → JWT is stored/used by frontend → authenticated actions hit `api/auth/*` → DB and uploads are updated.
   - **Admin flow:** admin authenticates → frontend calls `api/admin/*` → moderation, reporting, and messaging operations are executed server-side.

Main entry points: [`src/App.jsx`](https://github.com/rjoserivera/austral_collector/blob/main/src/App.jsx) (App shell), [`api/admin`](https://github.com/rjoserivera/austral_collector/tree/main/api/admin) (Admin API), [`src/pages`](https://github.com/rjoserivera/austral_collector/tree/main/src/pages) (Pages), [`api/auth`](https://github.com/rjoserivera/austral_collector/tree/main/api/auth) (Member API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_main["Entry<br/>React boot<br/>[main.jsx]"]
  node_app["App shell<br/>Router shell<br/>[App.jsx]"]
  node_pages["Pages<br/>Views"]
  node_components["UI blocks<br/>Reusable UI"]
  node_config["Config<br/>[config.js]"]
  node_sync["Offline sync<br/>PWA sync<br/>[offlineSync.js]"]
  node_syncstatus["Sync status<br/>React hook<br/>[useSyncStatus.jsx]"]
  node_sw["Service worker<br/>PWA asset<br/>[sw.js]"]
  node_worker["Workbox<br/>PWA runtime"]
end

subgraph group_backend["Backend"]
  node_public_api["Public API<br/>Read-only endpoints"]
  node_auth_api["Member API<br/>JWT actions"]
  node_admin_api["Admin API<br/>Privileged admin"]
  node_db[("DB bootstrap<br/>PDO bootstrap<br/>[db.php]")]
  node_core_api["Core endpoints<br/>Domain API"]
  node_jwt["JWT helper<br/>Auth helper<br/>[jwt_helper.php]"]
  node_admincheck["Admin check<br/>Access control<br/>[auth_check.php]"]
  node_indexphp["API entry<br/>PHP entrypoint<br/>[index.php]"]
end

subgraph group_docs["Docs"]
  node_docs_site["Docs site<br/>Mintlify docs"]
end

subgraph group_storage["Storage"]
  node_uploads[("Uploads<br/>File storage")]
end

node_main -->|"mounts"| node_app
node_app -->|"routes"| node_pages
node_app -->|"composes"| node_components
node_app -->|"reads"| node_config
node_app -->|"tracks"| node_syncstatus
node_syncstatus -->|"delegates"| node_sync
node_pages -->|"fetches"| node_public_api
node_pages -->|"calls"| node_auth_api
node_pages -->|"calls"| node_admin_api
node_public_api -->|"queries"| node_db
node_auth_api -->|"validates"| node_jwt
node_auth_api -->|"writes"| node_db
node_auth_api -->|"stores media"| node_uploads
node_admin_api -->|"guards"| node_admincheck
node_admin_api -->|"manages"| node_db
node_admin_api -->|"manages media"| node_uploads
node_core_api -->|"uses"| node_db
node_core_api -->|"reads/writes"| node_uploads
node_indexphp -->|"dispatches"| node_core_api
node_docs_site -.->|"documents"| node_public_api
node_docs_site -.->|"documents"| node_admin_api
node_sw -->|"runs with"| node_worker
node_app -->|"installs"| node_sw

click node_main "https://github.com/rjoserivera/austral_collector/blob/main/src/main.jsx"
click node_app "https://github.com/rjoserivera/austral_collector/blob/main/src/App.jsx"
click node_pages "https://github.com/rjoserivera/austral_collector/tree/main/src/pages"
click node_components "https://github.com/rjoserivera/austral_collector/tree/main/src/components"
click node_config "https://github.com/rjoserivera/austral_collector/blob/main/src/config.js"
click node_sync "https://github.com/rjoserivera/austral_collector/blob/main/src/utils/offlineSync.js"
click node_syncstatus "https://github.com/rjoserivera/austral_collector/blob/main/src/hooks/useSyncStatus.jsx"
click node_public_api "https://github.com/rjoserivera/austral_collector/tree/main/api/public"
click node_auth_api "https://github.com/rjoserivera/austral_collector/tree/main/api/auth"
click node_admin_api "https://github.com/rjoserivera/austral_collector/tree/main/api/admin"
click node_db "https://github.com/rjoserivera/austral_collector/blob/main/api/db.php"
click node_core_api "https://github.com/rjoserivera/austral_collector/tree/main/api"
click node_jwt "https://github.com/rjoserivera/austral_collector/blob/main/api/auth/jwt_helper.php"
click node_admincheck "https://github.com/rjoserivera/austral_collector/blob/main/api/admin/auth_check.php"
click node_docs_site "https://github.com/rjoserivera/austral_collector/tree/main/docs"
click node_sw "https://github.com/rjoserivera/austral_collector/blob/main/dev-dist/sw.js"
click node_worker "https://github.com/rjoserivera/austral_collector/blob/main/dev-dist/workbox-137dedbd.js"
click node_indexphp "https://github.com/rjoserivera/austral_collector/blob/main/api/index.php"
click node_uploads "https://github.com/rjoserivera/austral_collector/tree/main/uploads"

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_main,node_app,node_pages,node_components,node_config,node_sync,node_syncstatus,node_sw,node_worker toneBlue
class node_public_api,node_auth_api,node_admin_api,node_db,node_core_api,node_jwt,node_admincheck,node_indexphp toneAmber
class node_docs_site toneMint
class node_uploads toneRose
```

## Components

### Frontend

React/Vite single-page app and client-side offline layer.

- [Entry](https://github.com/rjoserivera/austral_collector/blob/main/src/main.jsx): React boot · Bootstraps the SPA and mounts the app. · `src/main.jsx`
- [App shell](https://github.com/rjoserivera/austral_collector/blob/main/src/App.jsx): Router shell · Top-level application composition and routing. · `src/App.jsx`
- [Pages](https://github.com/rjoserivera/austral_collector/tree/main/src/pages): Views · Route-level pages for home, members, profile, portfolio, gallery, contact, login, dashboard, and admin. · `src/pages`
- [UI blocks](https://github.com/rjoserivera/austral_collector/tree/main/src/components): Reusable UI · Shared interface components such as banners, cards, modals, navigation, and content sections. · `src/components`
- [Config](https://github.com/rjoserivera/austral_collector/blob/main/src/config.js): Env/api config · Central frontend configuration for API endpoints and runtime settings. · `src/config.js`
- [Offline sync](https://github.com/rjoserivera/austral_collector/blob/main/src/utils/offlineSync.js): PWA sync · Tracks connectivity and reconciles queued client work when back online. · `src/utils/offlineSync.js`
- [Sync status](https://github.com/rjoserivera/austral_collector/blob/main/src/hooks/useSyncStatus.jsx): React hook · Hook exposing connectivity and synchronization state to the UI. · `src/hooks/useSyncStatus.jsx`
- [Service worker](https://github.com/rjoserivera/austral_collector/blob/main/dev-dist/sw.js): PWA asset · Cached runtime asset for offline support and installable behavior. · `dev-dist/sw.js`
- [Workbox](https://github.com/rjoserivera/austral_collector/blob/main/dev-dist/workbox-137dedbd.js): PWA runtime · Generated service worker runtime used by the offline bundle. · `dev-dist/workbox-137dedbd.js`

### Backend

PHP API surface split into public, member, and admin boundaries.

- [Public API](https://github.com/rjoserivera/austral_collector/tree/main/api/public): Read-only endpoints · Unauthenticated content endpoints for home, members, profile, portfolio, gallery, contact, and identity data. · `api/public`
- [Member API](https://github.com/rjoserivera/austral_collector/tree/main/api/auth): JWT actions · Authenticated endpoints for login, profile updates, posts, likes, and ratings. · `api/auth`
- [Admin API](https://github.com/rjoserivera/austral_collector/tree/main/api/admin): Privileged admin · Back-office endpoints for moderation, reporting, messaging, and administrative content management. · `api/admin`
- [DB bootstrap](https://github.com/rjoserivera/austral_collector/blob/main/api/db.php): PDO bootstrap · Shared database connection and backend bootstrap used by API handlers. · `api/db.php`
- [Core endpoints](https://github.com/rjoserivera/austral_collector/tree/main/api): Domain API · Cross-cutting domain endpoints for figures, events, and API entry/maintenance utilities. · `api`
- [JWT helper](https://github.com/rjoserivera/austral_collector/blob/main/api/auth/jwt_helper.php): Auth helper · Encodes and validates member tokens for protected API routes. · `api/auth/jwt_helper.php`
- [Admin check](https://github.com/rjoserivera/austral_collector/blob/main/api/admin/auth_check.php): Access control · Verifies elevated access before admin operations run. · `api/admin/auth_check.php`
- [API entry](https://github.com/rjoserivera/austral_collector/blob/main/api/index.php): PHP entrypoint · Top-level API entry or landing endpoint. · `api/index.php`

### Docs

Standalone Mintlify documentation site.

- [Docs site](https://github.com/rjoserivera/austral_collector/tree/main/docs): Mintlify docs · Standalone documentation site for architecture, installation, authentication, figures, and the admin panel. · `docs`

### Storage

Database and uploaded media assets.

- [Uploads](https://github.com/rjoserivera/austral_collector/tree/main/uploads): File storage · Filesystem storage for uploaded media and generated assets. · `uploads`

## Connections

- Entry → App shell: mounts · Application bootstrap renders the root app shell.
- App shell → Pages: routes · Top-level routing selects page views.
- App shell → UI blocks: composes · Pages are assembled from shared UI components.
- App shell → Config: reads · Frontend uses centralized API/runtime settings.
- App shell → Sync status: tracks · UI consumes sync state to reflect connectivity.
- Sync status → Offline sync: delegates · Hook wraps offline reconciliation logic.
- Pages → Public API: fetches · Public pages load read-only site content.
- Pages → Member API: calls · Member-facing pages invoke authenticated actions.
- Pages → Admin API: calls · Admin and dashboard views consume back-office endpoints.
- Public API → DB bootstrap: queries · Read-only endpoints read structured content from MySQL.
- Member API → JWT helper: validates · Protected member actions authenticate with JWTs.
- Member API → DB bootstrap: writes · Member actions update profiles, posts, likes, and ratings.
- Member API → Uploads: stores media · Post and profile actions may persist uploaded assets.
- Admin API → Admin check: guards · Admin routes enforce privileged access checks.
- Admin API → DB bootstrap: manages · Back-office actions operate on application data.
- Admin API → Uploads: manages media · Admin workflows can manage gallery and portfolio assets.
- Core endpoints → DB bootstrap: uses · Core domain endpoints also depend on the shared database bootstrap.
- Core endpoints → Uploads: reads/writes · Domain endpoints may access stored media assets.
- API entry → Core endpoints: dispatches · Top-level PHP entrypoint routes into API handlers.
- Docs site → Public API: documents · Docs describe the public and authenticated API surface.
- Docs site → Admin API: documents · Docs include the admin panel and operational workflow.
- Service worker → Workbox: runs with · Service worker runtime supports offline caching.
- App shell → Service worker: installs · Frontend registers the service worker for PWA behavior.
