How oscarhelmet/tradle works
Project Type and Purpose
• This is a full-stack web application combining:
– A React/TypeScript single-page frontend
– A Node.js/Express REST API backend
– A MongoDB database
– An external AI service (Google Gemini) for image analysis and insights
• Its goal is to let users register, log trades (manually or via AI image extraction), view analytics, and receive AI-powered reflections.
File Structure
• Top-level separation:
– “src” folder: frontend React app (components, pages, context, services/api)
– “server” folder: backend Express app (routes, services/gemini, models, middleware, config)
– “public” folder: static assets (index.html, manifest, robots.txt)
• Backend organizes code by concern:
– config/db.js for Mongo connection
– models/*.js for Mongoose schemas
– routes/*.js for REST endpoints
– services/gemini.js for AI API integration
– middleware/auth.js for JWT auth, upload.js for file handling
• Frontend organizes by feature:
– pages/ for routes (analysis, auth, journal, reflection, settings, dashboard)
– components/ for UI elements (charts, modals, layout, ui primitives)
– services/api/ApiService.ts for HTTP calls
– services/gemini/GeminiService.ts for any direct AI invocations (though these now go via backend)
– context/AuthContext.tsx for global auth state
Relationships and Data Flows
• User → Browser UI: input/trade management
• Browser → API: REST calls (login, register, CRUD trades, request analysis)
• API → MongoDB: queries and updates
• API → Gemini: image analysis, insight generation
• API → Browser: JSON responses with data or AI reflections
Architectural Patterns
• Monolithic backend following MVC-style separation (models, routes/controllers, services)
• Feature-driven frontend structure
• Separation of concerns: UI vs. API vs. data layer vs. external AI
• Stateless JWT authentication
• Service abstraction for AI integration
• Responsive, componentized UI with Tailwind CSS