How mourya2044/indipostcollectv2 works
1. Overall shape
- This is a two-tier monorepo: a React/Vite frontend in frontend/ and an Express/Node backend in backend/.
- The frontend is a thin presentation layer; most business rules, persistence, auth, AI calls, payments, and media handling happen in the backend.
2. Frontend application boundary
- The frontend is organized around route-level pages in src/pages/ and reusable UI in src/components/.
- AppRoutes.jsx and main.jsx define the client-side navigation shell.
- src/lib/axios.js, src/queries/, and src/store/useAuthStore.js show the main client data layer: Axios for API calls, React Query for server state, and Zustand for auth/session state.
3. Backend API structure
- The backend follows a classic modular MVC-ish split:
- routes/ exposes HTTP endpoints,
- controllers/ handle request/response logic,
- services/ contain business logic,
- models/ define Mongoose schemas,
- lib/ holds shared initializers and third-party clients,
- middlewares/ enforce request guards.
- src/index.js is the server entry point and likely wires Express, logging, middleware, routes, and DB startup together.
4. Persistence and domain model
- MongoDB is the primary datastore via Mongoose (lib/db.js).
- The model set shows the core business domains:
- identity/auth: user, token, verification
- catalog/commerce: stamp, order, cart-related flow
- content/community: post, comment
- events: event, eventRegistration
- AI chat history: aichatsession, archieved_messaged
- This suggests the backend is stateful across users, collectibles, orders, and AI conversations.
5. Authentication and account lifecycle
- Auth is a dedicated subsystem with auth.routes.js, auth.controller.js, and auth.middleware.js.
- The README indicates JWT-based auth with secure cookies, plus email verification and reset flows.
- Supporting utilities like sendEmail.js and sendResetEmail.js, along with token and verification models, imply OTP/verification and password recovery are first-class workflows.
6. Media and profile assets
- lib/cloudinary.js indicates Cloudinary is the external storage boundary for uploaded images.
- This likely covers user avatars and stamp images, which are central to the product.
- The frontend has a ProfilePhotoSelector and pages that depend on image-centric workflows, reinforcing Cloudinary as the media pipeline.
7. AI subsystem
- AI is isolated into its own route/controller/service stack: ai.routes.js, ai.controller.js, ai.service.js, and lib/ai.js.
- The tests (aichat.test.js, funcalling.test.js, multimodal.test.js, systemconfig.test.js) show three AI capabilities:
- conversational chat,
- function/tool calling,
- multimodal image understanding.
- The README and file names indicate LangChain/OpenRouter-backed LLM orchestration, with schema validation for structured outputs.
8. AI stamp recognition flow
- The main AI product feature is stamp recognition from uploaded images with optional text clues.
- The likely data path is: frontend upload/input → backend AI endpoint → vision model inference → structured stamp metadata/story returned to the client.
- The returned data includes catalog-like fields such as title, country, year, condition, thematic tags, and narrative text, which feeds the collector experience and possibly stamp detail pages.
9. Marketplace, cart, order, and Stripe
- Commerce is split across cart, order, and stripe routes/controllers.
- Stripe is the payment boundary; backend handles checkout/payment lifecycle, while the frontend has dedicated CartPage, CheckoutPage, and payment outcome pages.
- order.model.js suggests server-side order persistence and post-payment tracking rather than a purely client-managed cart.
10. Community, posts, and social content
- The community subsystem uses post, comment, and frontend community components/pages.
- This likely supports a social feed for collectors, post creation, and discussion around stamps or collection items.
- src/queries/postsQuery.js suggests server state for posts is normalized and fetched through a dedicated API slice.
11. Events and admin management
- Events are a separate domain with event.routes.js, event.controller.js, event.model.js, and eventRegistration.model.js.
- The frontend has EventsPage plus admin-oriented components for EventManagement.
- There is also StampsManagement in the admin UI, implying privileged CRUD views for catalog and event operations.
12. User dashboard and profile surfaces
- ProfilePage is composed from dedicated subviews for posts, orders, and events.
- This shows the user dashboard is an aggregation layer over multiple backend domains rather than a standalone data source.
- The frontend also includes layout components like AuthLayout and ProfileLayout, which separate public, auth, and account-management navigation.
13. Operational and deployment boundaries
- nginx.conf suggests production traffic may be served through Nginx as a reverse proxy and/or SPA host.
- .github/workflows/deploy.yml indicates CI/CD automation, and frontend/vercel.json shows the frontend has explicit Vercel deployment configuration.
- The deployment boundary therefore spans at least frontend hosting plus backend API hosting, with environment variables required for MongoDB, JWT, Cloudinary, OpenRouter, Stripe, and email.
14. What an architecture diagram should emphasize
- Draw the system as a React client calling an Express API.
- Inside the backend, show distinct service lines for auth, AI, commerce/payment, community/posts, events, and profile/media.
- Show MongoDB as the central persistence layer, Cloudinary as the image asset store, Stripe as the payment processor, and the LLM provider/OpenRouter as the AI external dependency.
Main entry points: routes API routes · pages Pages · models Mongo models · lib Backend lib
Components 22
Frontend
React/Vite client and presentation layer
- App shell · Bootstraps the SPA and client-side navigation
frontend/src/main.jsx - Routes · Defines top-level client routes and layout composition
frontend/src/AppRoutes.jsx - Pages · Home, marketplace, community, profile, auth, events, AI, and payment screens
frontend/src/pages - UI components · Reusable components for navigation, community, stamps, profile, admin, and forms
frontend/src/components - Client data · Axios client, query layer, and auth/session store
frontend/src/lib/axios.js
Backend
Express API, business logic, and persistence
- Server entry · Starts the API server and wires middleware, routes, and startup initialization
backend/src/index.js - API routes · Public endpoint boundaries for auth, AI, stamps, posts, cart, orders, events, and payments
backend/src/routes - Auth stack · Login, signup, verification, reset, and session protection
backend/src/routes/auth.routes.js - AI stack · Chat, tool calling, multimodal stamp recognition, and structured AI responses
backend/src/routes/ai.routes.js - Commerce · Cart, order persistence, and Stripe-backed checkout flow
backend/src/routes/cart.routes.js - Content · Posts, comments, and stamp catalog endpoints
backend/src/routes/post.routes.js - Events · Event CRUD and registration management
backend/src/routes/event.routes.js - Mongo models · Users, tokens, verification, stamps, posts, comments, orders, events, registrations, and AI chat history
backend/src/models - Core services · Reusable service layer, especially AI inference and response shaping
backend/src/services/ai.service.js - Backend lib · MongoDB, Cloudinary, and AI client initialization
backend/src/lib - Middleware · Auth and request protection for protected endpoints
backend/src/middlewares/auth.middleware.js - Email utils · Verification and password reset email helpers
backend/src/utils/sendEmail.js
External services
Third-party systems used by the app
- MongoDB · Primary persistence for users, content, commerce, events, and AI chats
- Cloudinary · Image upload and profile/stamp asset storage
- Stripe · Checkout and payment processing boundary
- LLM provider · External model access for chat and stamp recognition
- Email service · Sends verification and reset messages
Connections 28
- App shell → Routes: mounts · SPA bootstrap hands off to route configuration
- Routes → Pages: renders · Routes select the active page view
- Pages → UI components: composes · Pages reuse shared interface components
- Pages → Client data: fetches via · Pages load and mutate server state through client data helpers
- Client data → Server entry: calls API · Client issues HTTP requests to the Express backend
- Server entry → API routes: registers · Server mounts the route modules
- API routes → Auth stack: exposes · Auth endpoints are one major API surface
- API routes → AI stack: exposes · AI endpoints handle chat and stamp recognition
- API routes → Commerce: exposes · Cart, order, and payment endpoints
- API routes → Content: exposes · Posts, comments, and stamp catalog endpoints
- API routes → Events: exposes · Event and registration endpoints
- API routes → Middleware: protects with · Protected routes apply auth guards
- Auth stack → Mongo models: reads/writes · User, token, and verification persistence
- Auth stack → Email utils: sends emails · Verification and reset flows trigger outbound email helpers
- AI stack → Core services: delegates to · AI route/controller logic uses the AI service layer
- AI stack → Mongo models: stores chats · Conversation sessions and archived messages are persisted
- Commerce → Mongo models: reads/writes · Cart and order state is stored server-side
- Commerce → Stripe: charges via · Payments are processed through Stripe
- Content → Mongo models: reads/writes · Posts, comments, and stamps persist in MongoDB schemas
- Events → Mongo models: reads/writes · Events and registrations are persisted
- Backend lib → MongoDB: connects to · Database initializer connects the API to MongoDB
- Backend lib → Cloudinary: uploads to · Image assets are stored in Cloudinary
- Backend lib → LLM provider: integrates with · AI client wraps the external model provider
- Email utils → Email service: delivers via · Account lifecycle emails go through the mail provider
- Mongo models → MongoDB: persists in · All core domain data lives in MongoDB
- Pages → Cloudinary: uploads images · Profile/photo and stamp image workflows depend on media storage
- Pages → Stripe: checkout redirect · Payment pages coordinate with the Stripe checkout flow
- Pages → LLM provider: AI results · AI assistant and stamp recognition consume AI-backed responses