How iamkrisshk/bodhiki works
1. Repo shape
- This is a two-part application: a Node/Express backend under backend/ and a React frontend under frontend/.
- The root package.json suggests the repo is organized as a workspace-style project, but the actual runtime boundary is still clearly split between client and server.
2. Backend entry and server boundary
- backend/backend.js and backend/app.js appear to separate process startup from Express app configuration.
- backend/config/db.js is the database connection layer, so the backend is responsible for persistence and API exposure, not just static serving.
3. Backend API surface
- Routes are grouped by domain in backend/routes/:
- authRoutes.js for authentication
- userRoutes.js for user/profile operations
- discoverRoutes.js for discovery/feed-related content
- actRoutes.js for activity/study actions
- Each route module maps to a controller in backend/ctrl/, keeping HTTP routing separate from business logic.
4. Backend domain logic
- Controllers implement the main backend behaviors:
- authCtrl.js handles sign-in/sign-up/session logic
- userCtrl.js handles user data
- discoverCtrl.js handles discovery/feed content
- actCtrl.js handles activity/study-related operations
- This suggests the backend is organized around application features rather than generic CRUD only.
5. Backend data model
- Domain models live in backend/models/:
- Users.js
- Posts.js
- Comments.js
- Likes.js
- Activity.js
- These indicate a social/content model with posts, reactions, comments, and user activity tracking.
- The presence of separate models for likes/comments suggests content relationships are first-class rather than embedded in a single document/table.
6. Backend middleware
- backend/mare/authMare.js is the auth guard layer, likely protecting private routes and validating tokens/sessions.
- backend/mare/errorHandler.js is centralized error middleware, which means request failures are normalized in one place before returning API responses.
7. Frontend app shell
- React app structure lives under frontend/src/, with top-level composition in:
- src/main.jsx
- src/index.js
- src/app/app.jsx
- src/app/protRoutes.jsx
- Routing is segmented by layout and access type, implying a client-side SPA with protected/private areas.
8. Frontend layout and route boundaries
- Layouts are split into authLayout.jsx, dashboardLayout.jsx, and publicLayout.jsx.
- This indicates three distinct UI zones:
- unauthenticated/auth flow
- logged-in dashboard experience
- public-facing content
- protRoutes.jsx suggests route protection is enforced on the client as well, not only on the backend.
9. Frontend feature modules
- The features/ folder is the main business UI layer:
- auth/ contains Login.jsx, Register.jsx, authAPI.js
- feed/ contains feed, post creation, discovery cards, and feed/discover APIs
- activity/ contains studyAPI.js
- services/apiClient.js is the shared HTTP client
- This shows a feature-sliced frontend architecture where UI components, API calls, and local helpers stay close together.
10. Primary data flow
- User interaction starts in React pages/components, then goes through feature API modules like authAPI.js, feedAPI.js, discoverAPI.js, and studyAPI.js.
- Those modules use services/apiClient.js to call backend routes.
- The backend routes dispatch to controllers, which read/write domain models, then return data to the frontend for rendering.
11. Feed and discovery subsystem
- The feed area is more than a single list: it includes posting, card rendering, normalization helpers (norm.js), and a discovery hook (useDiscover.js).
- This suggests the app has a content surface where posts can be created, normalized into UI-friendly shape, and surfaced through discovery logic.
12. Activity / study subsystem
- The presence of study.jsx, zenGarden.jsx, studyAPI.js, and sound assets under public/sounds/ points to a focused “study mode” or wellness/ambient experience.
- That part of the UI is likely independent from the feed, but still authenticated and backed by the Activity model and actRoutes.
13. Static assets and presentation
- Global styling is centralized in src/styles/global.css and src/styles/theme.js.
- frontend/public/sounds/ contains MP3 assets used by a UI experience, likely the zen/study mode.
- Navbar.jsx and shared layout components imply common chrome around the routed pages.
14. How to draw the architecture
- Draw two main boundaries: React client and Express API server.
- Inside the client, show layouts + routed pages feeding into feature modules, which call a shared API client.
- Inside the server, show routes → controllers → models/db, with auth middleware guarding protected endpoints and error middleware handling failures centrally.
Main entry points: app.js Express app · pages Pages · apiClient.js API client · models Domain models
Components 25
Backend
Express API server, domain logic, and persistence
- Server start · Bootstraps the backend process
backend/backend.js - Express app · Wires middleware and routes
backend/app.js - Database · Database connection layer
backend/config/db.js - Auth routes · Authentication endpoints
backend/routes/authRoutes.js - User routes · User and profile endpoints
backend/routes/userRoutes.js - Discover routes · Discovery and feed endpoints
backend/routes/discoverRoutes.js - Activity routes · Study and activity endpoints
backend/routes/actRoutes.js - Auth ctrl · Sign-in, sign-up, session logic
backend/ctrl/authCtrl.js - User ctrl · User data operations
backend/ctrl/userCtrl.js - Discover ctrl · Discovery and content assembly
backend/ctrl/discoverCtrl.js - Activity ctrl · Study and activity operations
backend/ctrl/actCtrl.js - Auth guard · Protects private routes
backend/mare/authMare.js - Error handler · Centralized API error handling
backend/mare/errorHandler.js - Domain models · Users, posts, comments, likes, activity data
backend/models
Frontend
React SPA, layouts, and feature modules
- App boot · Client entry and render setup
frontend/src/main.jsx - App shell · Top-level client composition
frontend/src/app/app.jsx - Protected routes · Client-side route access control
frontend/src/app/protRoutes.jsx - Layouts · Public, auth, and dashboard chrome
frontend/src/layouts - Navbar · Shared navigation component
frontend/src/comp/Navbar.jsx - Auth feature · Login and registration UI plus auth API
frontend/src/features/auth - Feed feature · Feed, posting, discovery, and normalization
frontend/src/features/feed - Study feature · Study mode UI and activity API
frontend/src/features/activity - API client · Shared client for backend calls
frontend/src/features/services/apiClient.js - Pages · Landing and dashboard screens
frontend/src/pages - Theme styles · Global styling and theme tokens
frontend/src/styles
Connections 31
- Server start → Express app: starts · Process entry loads the Express app
- Express app → Auth guard: uses · Protects private routes
- Express app → Error handler: uses · Normalizes failures
- Express app → Auth routes: mounts · Registers auth endpoints
- Express app → User routes: mounts · Registers user endpoints
- Express app → Discover routes: mounts · Registers discover endpoints
- Express app → Activity routes: mounts · Registers activity endpoints
- Auth routes → Auth ctrl: dispatches · Routes delegate to auth controller
- User routes → User ctrl: dispatches · Routes delegate to user controller
- Discover routes → Discover ctrl: dispatches · Routes delegate to discover controller
- Activity routes → Activity ctrl: dispatches · Routes delegate to activity controller
- Auth ctrl → Domain models: reads/writes · Uses persistence for auth state
- User ctrl → Domain models: reads/writes · Uses user data models
- Discover ctrl → Domain models: reads/writes · Fetches content and relationships
- Activity ctrl → Domain models: reads/writes · Stores activity data
- Express app → Database: connects · Initializes database access
- App boot → App shell: renders · Bootstraps the SPA
- App shell → Protected routes: guards · Wraps protected client routes
- App shell → Layouts: composes · Selects layout boundaries
- Layouts → Navbar: includes · Shared chrome across views
- Protected routes → Pages: routes to · Maps navigation to screens
- Pages → Auth feature: uses · Auth screens depend on auth feature
- Pages → Feed feature: uses · Feed-related screens depend on feed feature
- Pages → Study feature: uses · Study screens depend on activity feature
- Auth feature → API client: calls · Uses shared HTTP client
- Feed feature → API client: calls · Uses shared HTTP client
- Study feature → API client: calls · Uses shared HTTP client
- Auth feature → Theme styles: styles · Consumes shared theme and global CSS
- Feed feature → Theme styles: styles · Consumes shared theme and global CSS
- Study feature → Theme styles: styles · Consumes shared theme and global CSS
- API client → Express app: requests · Client API traffic targets backend endpoints