How premjithx86/umamicircle works
1. Repository shape
- This is a three-part monorepo:
- a Node/Express backend at the root,
- a public React user app in umami-frontend,
- a React admin dashboard in umami-admin.
- The three apps share one backend API and one MongoDB data layer, but the two frontends are deployed/run independently.
2. Backend entry and request pipeline
- server.js is the runtime entry point and boots the Express app from src/app.js.
- The backend is organized in the usual boundary layers:
- src/config for environment, MongoDB, and Firebase setup,
- src/middleware for auth, admin auth, moderation, and upload handling,
- src/routes for feature-specific HTTP endpoints,
- src/services for non-trivial business logic,
- src/models for Mongoose schemas.
3. Primary backend domains
- The API is split by business area rather than by UI:
- postRoutes, recipeRoutes, commentRoutes, socialRoutes
- messagingRoutes, notificationRoutes
- aiRoutes, uploadRoutes
- userRoutes, adminRoutes
- This suggests the backend is the central orchestration layer for content creation, social interactions, messaging, moderation, and AI features.
4. Data model boundary
- MongoDB/Mongoose is the main persistence layer.
- The model set shows the core domain objects:
- social/content: User, Post, Recipe, Comment, Report
- communication: Conversation, Message, Notification
- admin/safety: Admin, AuditLog, BlockedSession, ModerationCache
- AI usage tracking: AIChatHistory, AIChatUsage
- The presence of these models indicates the backend keeps both product data and operational/security state.
5. Authentication and authorization
- The project uses Firebase Authentication on the client side, with backend middleware (auth.js, adminAuth.js) enforcing access control.
- User-facing routes are protected separately from admin-only routes.
- This creates a clear split between:
- authenticated community actions in the public app,
- privileged moderation/management actions in the admin app.
6. Content safety and moderation flow
- Moderation is a first-class subsystem, not an afterthought.
- textModerationMiddleware and services/moderationService.js handle text safety, while the README also references external moderation providers for image/text screening.
- ModerationCache, Report, BlockedSession, and AuditLog show that moderation is persisted, reviewable, and auditable.
- Likely flow: user-generated content enters via content routes, is checked/screened, then stored and/or queued for admin review if needed.
7. AI subsystem
- aiRoutes and services/aiService.js implement “UmamiBot,” the cooking assistant.
- The README says it is powered by a Groq-hosted Llama model, with additional food-detection support from Hugging Face.
- AIChatHistory and AIChatUsage imply the backend tracks conversation state and usage limits/analytics.
- This is a distinct backend capability with its own persistence and quota/telemetry concerns.
8. Real-time messaging and notifications
- Messaging is handled by messagingRoutes plus services/messagingService.js, with Socket.io listed in the stack and a frontend socket.js client.
- The data model (Conversation, Message) indicates a conversation-based chat system rather than simple one-off messages.
- Notifications are a separate subsystem (notificationRoutes, notificationService, Notification model), likely fed by social actions, messaging, and moderation events.
9. Media upload path
- uploadMiddleware.js and uploadRoutes define a dedicated media ingestion boundary.
- The README references Cloudinary, so the architecture likely routes image uploads through the backend and stores/transforms media externally rather than in the app server.
- This is important for food photography, which is a core product concern.
10. Public frontend structure
- umami-frontend is a Vite/React app built around feature pages:
- feed/explore/profile/search/settings
- post and recipe creation/detail views
- chat, notifications, AI chat, auth flows
- It uses contexts for auth and theme, a route protection layer (ProtectedRoute), and a dedicated API client in src/services/api.js.
- The frontend is the primary consumer of the public API and real-time socket connection.
11. Admin dashboard structure
- umami-admin is a separate React/Vite app for operations and moderation.
- Its pages focus on admin workflows: dashboard, user management, reports, moderation queue, activity logs, login.
- AdminContext and adminService.js suggest the dashboard authenticates independently and calls admin endpoints only.
- This separation keeps high-privilege workflows isolated from the consumer UI.
12. Cross-cutting services and operational boundaries
- auditService.js, notificationService.js, messagingService.js, and moderationService.js show the backend favors service-layer encapsulation for side effects and multi-step workflows.
- The architecture is centered on:
- React clients → Express routes → service layer → Mongoose models/external services
- plus real-time Socket.io events for chat/notifications.
- For an architecture diagram, the key boundaries are: public app, admin app, API server, MongoDB, Firebase auth, Cloudinary storage, AI/moderation providers, and Socket.io real-time channel.
Main entry points: umami-frontend User app · app.js Express app · services Services · routes Routes
Components 21
Backend
Express API, services, and data models
- server.js · Boots the backend runtime
server.js - Express app · Wires middleware and routes
src/app.js - Config · MongoDB, Firebase, and environment setup
src/config - Middleware · Auth, admin auth, moderation, and uploads
src/middleware - Routes · Feature endpoints for content, chat, AI, and admin
src/routes - Services · Side effects and multi-step workflows
src/services - Models · Core domain and operational schemas
src/models
Public app
React user-facing client
- User app · Public feed, content, chat, and AI experience
umami-frontend - Pages · Home, explore, profiles, content, chat, and settings
umami-frontend/src/pages - API client · Calls the shared backend API
umami-frontend/src/services/api.js - Socket client · Receives chat and notification events
umami-frontend/src/services/socket.js - Auth context · User session and protected routes
umami-frontend/src/context/AuthContext.jsx
Admin app
React moderation and operations client
- Admin app · Moderation and operations dashboard
umami-admin - Admin pages · Dashboard, users, reports, queue, and logs
umami-admin/src/pages - Admin API · Calls privileged admin endpoints
umami-admin/src/services/adminService.js - Admin context · Admin session and access state
umami-admin/src/context/AdminContext.jsx
External systems
Datastores, auth, media, AI, and realtime services
- MongoDB · Primary persistence for users, content, chat, and moderation
- Firebase Auth · Client-side authentication foundation
- Cloudinary · Image upload and transformation backend
- AI providers · Groq Llama and Hugging Face support
- Socket.io · Pushes chat and notification events
Connections 23
- server.js → Express app: starts · Runtime entry launches the Express application
- Express app → Config: loads · Initializes environment, database, and auth config
- Express app → Middleware: applies · Installs request guards and upload handling
- Express app → Routes: mounts · Registers feature-specific HTTP endpoints
- Routes → Services: delegates · Routes hand off complex workflows to services
- Services → Models: reads/writes · Services persist and query domain state
- Config → MongoDB: connects · MongoDB is the primary data store
- Config → Firebase Auth: configures · Firebase supports client authentication
- Middleware → Firebase Auth: verifies · Auth middleware validates identity tokens
- Middleware → Cloudinary: uploads · Media ingestion is routed to external storage
- Services → AI providers: calls · AI and moderation services use external models/providers
- Services → Socket.io: emits · Messaging and notifications push realtime events
- User app → Pages: contains · User-facing features are organized as pages
- User app → API client: uses · Frontend reads and writes through the shared API
- User app → Socket client: subscribes · Frontend listens for realtime updates
- User app → Auth context: wraps · Public app manages authenticated user state
- Auth context → Firebase Auth: authenticates · Client session is based on Firebase auth
- API client → Routes: calls · User app talks to public backend endpoints
- Admin app → Admin pages: contains · Admin workflows are page-based
- Admin app → Admin API: uses · Dashboard talks to admin endpoints through a service layer
- Admin app → Admin context: wraps · Admin session and permissions are centralized in context
- Admin API → Routes: calls · Admin dashboard reaches privileged backend routes
- Admin context → Firebase Auth: authenticates · Admin access depends on the shared auth foundation