How mehedi-bit/journey-with-quran works
1. Overall shape
This is a two-tier application: a React + TypeScript SPA in frontend-v2/ and an Express + Node.js API in backend/, with MongoDB/Mongoose as the persistent store. The product mixes a community journaling/social layer with Quran study content.
2. Frontend boundary
The frontend is a Vite-based client app (main.tsx, App.tsx) organized as routed page components under src/components/pages. It is the primary user-facing boundary for authentication, profile management, posts, users, and Quran/tafsir/hadith browsing.
3. Frontend state model
Client state is centralized with small “atom” stores in src/atoms/ (authAtom, userAtom, postsAtom, feedAtom, currentPostAtom). That suggests the app shares auth/session state, current user data, and post/feed data across many pages without prop-drilling.
4. Frontend feature clusters
The UI is split into clear domains:
- components/auth for login/signup/logout/profile update
- components/post for creating, viewing, commenting, and post menus
- components/user and components/suggestedUser for profile/social interactions
- components/surah, components/tafsir, components/Hadith for Quran study content
- components/common for global layout and modals like navbar, sidebar, theme switcher, report popup, welcome modal
5. Frontend UI foundation
There is a reusable UI toolkit under src/components/ui/ and a theme provider. This implies a design-system style setup, likely with modal/dialog, tabs, sheet, dropdown, form, and input primitives reused across pages. The frontend also includes usePreviewImage, indicating image upload/preview UX for profile or post media.
6. Backend entry and routing
The backend is structured conventionally around server.js as the entrypoint, routes/ for HTTP endpoints, controllers/ for request logic, middlewares/ for auth protection, and models/ for Mongoose schemas. connectDB.js establishes the MongoDB connection before the API serves traffic.
7. Backend domain model
The visible database model boundary is small and focused: userModel.js and postModel.js. That means the backend’s persistent core is the social layer—accounts, profiles, follows, posts, comments/replies, and associated metadata—rather than Quran content storage.
8. Authentication and authorization
Auth is cookie/JWT-based. generateTokenAndSetCookie.js issues auth tokens, and protectRoute.js guards protected endpoints. So the request path is: client submits credentials or session-changing actions → backend validates → sets token cookie → protected controllers read the authenticated user context.
9. Social data flows
The README’s “atomic updates” and “auto propagation” show that profile changes and follow/unfollow actions are treated as cross-document operations. In architecture terms, this means a user update may cascade to many posts/comments, and follow relationships likely touch multiple user records or arrays, with MongoDB transactions used to keep those writes consistent.
10. Content and external-service considerations
The frontend contains dedicated Quran/tafsir/hadith views, but the backend tree does not show models/routes for those domains. That suggests those experiences are either client-side/static or sourced externally, while the backend remains centered on social journaling. Environment variables mention Cloudinary, so image upload/storage is part of the backend’s infrastructure boundary even though its integration code is not shown here.
11. Deployment/tooling boundary
The frontend has Vite, Tailwind, and a vercel.json, so it is likely deployed independently from the backend. The backend uses environment-based configuration (.env.example) and is designed for local development with separate frontend/backend servers.
12. Diagram takeaway
For an architecture diagram, model:
- a browser SPA with shared atom-based client state
- an Express API with auth, user, and post controllers
- a MongoDB/Mongoose persistence layer
- Cloudinary as an external media service
- a content browsing frontend for Quran/tafsir/hadith that sits alongside the community journaling features rather than inside the backend domain.
Main entry points: pages Pages · main.tsx App shell · routes Routes · post Posts UI
Components 22
Frontend SPA
React + TypeScript client app and its feature domains
- App shell · Top-level SPA bootstrapping and route composition
frontend-v2/src/main.tsx - Pages · Primary routed screens for auth, social, and Quran study views
frontend-v2/src/components/pages - Atoms · Shared atom stores for auth, user, feed, and post state
frontend-v2/src/atoms - Auth UI · Login, signup, logout, and profile update UI
frontend-v2/src/components/auth - Posts UI · Post creation, viewing, commenting, and menus
frontend-v2/src/components/post - Users UI · Profile headers, user controls, and post/reply tabs
frontend-v2/src/components/user - Suggestions · Suggested user modal and follow entry points
frontend-v2/src/components/suggestedUser - Quran views · Surah, tafsir, and hadith browsing UI
frontend-v2/src/components/surah - Layout UI · Navbar, sidebar, modals, theme switcher, and app-wide chrome
frontend-v2/src/components/common - UI kit · Reusable primitive components for forms, dialogs, inputs, tabs, and sheets
frontend-v2/src/components/ui - Theme · Theme provider used by the client shell
frontend-v2/src/components/theme-provider.tsx - Image preview · Client-side image preview helper for uploads
frontend-v2/src/hooks/usePreviewImage.ts
Backend API
Express + Node.js service, auth, controllers, and MongoDB models
- Server · API bootstrap and server startup
backend/server.js - Routes · User and post endpoint definitions
backend/routes - User ctrl · User profile, auth, and social action controllers
backend/controllers/userController.js - Post ctrl · Post and comment controller logic
backend/controllers/postController.js - Protect route · Authenticated-request guard for protected endpoints
backend/middlewares/protectRoute.js - Models · Persistent user and post schemas
backend/models - DB connect · MongoDB connection setup before serving requests
backend/db/connectDB.js - Token helper · Creates auth tokens and sets session cookies
backend/utils/helpers/generateTokenAndSetCookie.js
External Services
Persistent store and media hosting boundary
- MongoDB · Primary persistent store for users and posts
- Cloudinary · External image storage and upload boundary
Connections 23
- App shell → Pages: renders · App shell mounts the routed page layer
- App shell → Atoms: shares state · Pages consume shared atom stores
- App shell → Layout UI: uses chrome · Global layout and modal components wrap the app
- Pages → Auth UI: auth screens · Auth-related pages use the auth component cluster
- Pages → Posts UI: social screens · Post and comment pages compose post widgets
- Pages → Users UI: profile screens · User pages use profile components
- Pages → Suggestions: discovery · Suggested users pages use discovery components
- Pages → Quran views: study screens · Quran study pages compose surah, tafsir, and hadith views
- Layout UI → UI kit: built on · Shell components reuse the shared UI primitive kit
- Layout UI → Theme: theme · Theme provider supports global appearance switching
- Posts UI → Image preview: uploads · Post and profile flows can preview selected images
- Server → Routes: mounts · Server exposes API routes
- Server → DB connect: connects · Server initializes MongoDB connection
- Routes → User ctrl: user endpoints · User routes delegate to user controller handlers
- Routes → Post ctrl: post endpoints · Post routes delegate to post controller handlers
- Routes → Protect route: protects · Protected endpoints use auth middleware
- User ctrl → Token helper: issues token · Auth flows generate session cookies
- User ctrl → Models: reads/writes · User operations persist through Mongoose models
- Post ctrl → Models: reads/writes · Post and comment operations persist through Mongoose models
- Models → MongoDB: stores · Mongoose schemas persist to MongoDB
- App shell → Server: API calls · SPA talks to the Express backend
- Posts UI → Cloudinary: media upload · Image-bearing post flows rely on external media storage
- Users UI → Cloudinary: avatar upload · Profile image flows can use external media storage