How oxilonx/aetheric works
Project Type and Purpose
• This is a full-stack e-commerce style application.
• Frontend: React (Vite) single-page application.
• Backend: Node.js + Express REST API, with user and product management.
• Data store: relational database (configured in backend/config/database.sql) and local file storage (backend/uploads).
File-Structure Analysis
• Top Level
• backend/ – Express app, MVC-style controllers, routes, middleware, config, utils, file uploads.
• frontend/ – Vite-powered React app, organized into pages, components (UI, local, utility), contexts, assets.
• Backend Patterns
• controllers/ ↔ routes/ implements REST endpoints (users, products)
• middleware/ for JWT auth (authToken.js) and role checking (isAdmin.js)
• config/ for DB connection (db.js + SQL schema)
• utils/ for token generation and SKU logic
• Frontend Patterns
• src/pages/ – route targets: Home, Cart, Profile, Register
• src/components/ – divided into localComponents (feature widgets), ui (visual primitives), utilityComponents (e.g. SkeletonGrid, token handler)
• src/contexts/ – global state (AuthContextProvider, ProdsContextProvider)
• API calls centralized in utilityComponents or lib/utils.js
1. Web Client (React SPA)
– UI Components, Context Providers
– HTTP(S) client for REST calls, handles JWT in Authorization header
2. API Gateway / Backend (Express)
– Routes → Controllers → Business Logic
– Middleware for authentication & authorization
– Utility modules (tokenHelpers, skuGenerator)
3. Database
– User and Product tables (configured via database.sql)
4. File Storage
– Local filesystem at /uploads/products for product images
5. (Optional) External Services
– Email/SMS providers, payment gateways, etc.
b. Relationships & Data Flows
• Browser →(HTTP REST: GET/POST/PUT/DELETE)→ API
• API →(SQL queries)→ Database
• API →(read/write)→ File Storage
• Authentication
• Login/Register: SPA → POST /users → API → tokenHelpers → returns JWT
• Protected calls: React reads JWT from context → sends in Authorization header → authToken middleware validates
• Admin flows: isAdmin middleware grants access to product-management endpoints
c. Architectural Patterns & Principles
• Backend: MVC-style separation (routes/controllers/utils)
• Frontend: Component-based UI + Context API for state management
• Token-based stateless authentication (JWT)
• Single source of truth for API base URL and token handling in utility modules
d. Key Technologies
• Frontend: React, Vite, Context API, JSX, CSS modules (index.css)
• Backend: Node.js, Express, MySQL/PostgreSQL (via db.js), JWT
• Build & lint: ESLint (frontend), Vite config, package.json scripts