How aymmaann/lunex works
Project type and purpose
• The client folder contains a React (Vite) single‑page application for browsing coins, viewing history, managing a wallet, and chatting with an AI assistant (FinBot).
• The server folder contains a Node.js/Express REST API that handles authentication, coin data persistence, analysis, and integration with Google Cloud services.
File structure
• Top‑level:
• client/ – React SPA (Vite)
• server/ – Express API
• client/src: organized by components, pages, services (api calls, auth, crypto analysis), context, assets.
• server: follows MVC-like separation:
• controllers/ – map HTTP routes to business logic
• services/ – core crypto data fetching/analysis logic
• handlers/ – specialized functions (e.g., cryptoAnalysisHandler)
• models/ – data schemas for Datastore (userModel, coinModel)
• middleware/ – auth checks (JWT/OAuth)
• routes/router.js – express routing
• utils/ – cloud config, export functions
README for additional insights
• Uses Google Cloud (Datastore, BigQuery, Storage, Run, Scheduler, Secret Manager)
• External APIs: CoinGecko, Google Gemini
• OAuth for user authentication
• Scheduled jobs to refresh crypto values every 5 minutes
a. Main components:
• Frontend: React SPA (Vite)
• Backend API: Node.js/Express (hosted in Cloud Run)
• Datastore: Google Cloud Datastore for users & saved/invested cryptos
• BigQuery: analytics on exported data
• Cloud Storage: intermediate storage of exported JSON/CSV
• Cloud Scheduler: triggers export/refresh jobs
• External Services: CoinGecko API, Google Gemini API, OAuth (Google)
b. Relationships & interactions:
1. User → React SPA → calls Express endpoints (via VITE_API_URL)
2. Express → authenticates user via OAuth → stores user in Datastore
3. React SPA → fetches market data from Express → Express → CoinGecko
4. React SPA → triggers FinBot chat → Express → Gemini API → returns response
5. Cloud Scheduler → invokes Express endpoint → refreshes prices in Datastore
6. Export service in Express → dumps Datastore → Cloud Storage → BigQuery load
7. React SPA → fetches analytics queries (optionally via Express or directly BigQuery)
c. Architectural patterns & principles:
• Frontend: single‑page application, component‑based design, context for global state, separation of concerns (services for API calls)
• Backend: layered architecture (router → controller → service → model), stateless services in Cloud Run, JWT/OAuth middleware
• Cloud Integration: serverless services for scalability, event‑driven pipeline (Scheduler → Cloud Run → Storage → BigQuery)
d. Key technologies & libraries:
• Frontend: React, Vite, Tailwind, Context API, Axios/fetch for REST, Google OAuth JS SDK, Gemini client
• Backend: Node.js, Express, @google-cloud/datastore, dotenv, jsonwebtoken, cross‑service utilities
• Cloud: Cloud Run, Datastore, BigQuery, Cloud Storage, Secret Manager, Scheduler