How hxni786/hxnix-social-media-app works
Purpose and topology
HXNIX is a mobile social-feed system: an Expo/React Native client consumes a Node/Express REST API backed by MySQL. The app supports authentication-oriented UI plus post listing, detail, creation, and deletion. Production mobile builds can target a configured remote API; local devices require a LAN-accessible backend.
Entry points and navigation
• Expo Router bootstraps the client and route shell through frontend/app/_layout.js and the feed landing route frontend/app/index.js.
• Post detail is a dynamic file route at frontend/app/post/[id].js.
• The server process starts from backend/server.js, exposing health and API endpoints, conventionally on port 5000.
Client application layer
• Screen-level behavior is organized in frontend/src/pages/FeedScreen.js, frontend/src/pages/PostDetailScreen.js, and authentication screens under frontend/src/pages/.
• Shared authenticated-user state is centralized in frontend/src/context/AuthContext.js, separating session concerns from route/UI composition.
• Reusable feed presentation is primarily frontend/src/components/ui/PostCard.js; app-wide visual framing is frontend/src/components/layout/AppHeader.js.
• API host selection is a client boundary in frontend/src/config.js; it must resolve to an address reachable from the device.
Client-to-server data flow
• Screens invoke the post transport abstraction in frontend/src/services/postService.js.
• Requests cross an HTTP/JSON REST boundary to the Express server. Main read flow is feed/detail screen → post service → GET /api/posts or GET /api/posts/:id → rendered state.
• Mutation flow is client create/delete action → post service → server controller/model → MySQL; feed state is refreshed after deletion rather than relying on realtime push infrastructure.
Express API and request pipeline
• backend/server.js assembles Express, database initialization, route mounting, health checking, and global error handling.
• Post endpoints are declared in backend/routes/postRoutes.js and handled in backend/controllers/postController.js, keeping HTTP route definitions separate from application operations.
• Authentication endpoints are isolated in backend/routes/authRoutes.js; backend/middleware/authMiddleware.js is the authorization boundary for protected operations.
• Unhandled failures are normalized by backend/middleware/errorHandler.js.
Persistence and domain model
• MySQL connectivity/configuration is established in backend/config/db.js, driven by backend environment variables (DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME).
• backend/models/Post.js owns post persistence and initial-data seeding when the posts table is empty. Posts include title, body, and user association per the API contract.
• backend/models/User.js represents the user persistence domain used by the authentication route family.
• Database availability is a hard server-side infrastructure dependency; the health endpoint provides a lightweight operational check.
Material runtime and deployment boundaries
• Mobile runtime: React Native under Expo SDK 54, configured by frontend/app.json; EAS build configuration is frontend/eas.json.
• Backend runtime: Node.js 18+ with Express; MySQL 8+ is the relational store.
• The client and API are independently deployable. Client configuration determines the API origin, while backend secrets and DB connectivity remain server-side in backend/.env.
Main entry points: server.js Express server · FeedScreen.js Feed and detail screens · postService.js Post service · postRoutes.js Post routes
Components 19
Expo Mobile Client
- Expo Router shell · Bootstraps route composition.
frontend/app/_layout.js - Feed route
frontend/app/index.js - Post detail route
frontend/app/post/[id].js - Feed and detail screens
frontend/src/pages/FeedScreen.js - Authentication screens
- Auth session state
frontend/src/context/AuthContext.js - Post card
frontend/src/components/ui/PostCard.js - API origin config · Must resolve to a device-reachable API address.
frontend/src/config.js - Post service
frontend/src/services/postService.js
Express API
- Express server · Assembles database initialization, routes, health checks, and error handling.
backend/server.js - Post routes · GET /api/posts and /api/posts/:id plus post mutations.
backend/routes/postRoutes.js - Post controller
backend/controllers/postController.js - Auth routes
backend/routes/authRoutes.js - Authorization middleware · Protects authorized operations.
backend/middleware/authMiddleware.js - Global error handler · Normalizes unhandled failures.
backend/middleware/errorHandler.js
Persistence
- MySQL connection · Uses server-side DB environment variables.
backend/config/db.js - Post model · Persists posts and seeds an empty posts table.
backend/models/Post.js - User model
backend/models/User.js - MySQL 8+
Connections 20
- Expo Router shell → Feed route: mounts
- Expo Router shell → Post detail route: mounts
- Feed route → Feed and detail screens: renders
- Post detail route → Feed and detail screens: renders detail
- Authentication screens → Auth session state: uses session
- Feed and detail screens → Post card: renders posts
- Feed and detail screens → Post service: loads and mutates posts
- Post service → API origin config: resolves origin
- Post service → Express server: HTTP/JSON REST
- Express server → Post routes: mounts
- Express server → Auth routes: mounts
- Express server → Global error handler: uses
- Express server → MySQL connection: initializes
- Post routes → Authorization middleware: authorizes protected actions
- Post routes → Post controller: dispatches
- Post controller → Post model: reads and writes
- Auth routes → User model: uses
- MySQL connection → MySQL 8+: connects
- Post model → MySQL 8+: persists posts
- User model → MySQL 8+: persists users