How kunal-rathore-111/neptune works
1. Overall shape
Neptune is a three-runtime monorepo: a React/Vite frontend, an Express backend API, and a separate Hono-based AI microservice. Shared code lives in packages/* so the client and server can reuse UI primitives, validation schemas, icons, and utility functions.
2. User-facing client
apps/web/client is the browser app. It is a routed SPA with pages for landing, docs, auth, dashboard, profiles, shared content, and legal content. The UI is built from reusable components and custom hooks, with TanStack Query-style data hooks wrapping the service layer.
3. Client state and data access
The client does not talk to the database directly. It uses an api/axiosInstance.ts plus dedicated service modules for each feature area: sign-in/out, content CRUD, profile fetch, sharing, password reset, OTP, chat, and Magic Fill. A small Redux slice in store/uiSlice.ts appears to manage local UI state such as drawers or layout toggles.
4. Backend API as the application orchestrator
apps/web/server is the main business-logic layer. It exposes routes for authentication, user account management, bookmark/content CRUD, sharing, OTP flows, and AI-related actions. Controllers delegate to service modules, which in turn handle persistence, hashing, session/auth logic, and external service calls.
5. Auth and account boundary
The server contains dedicated middlewares for sign-up/sign-in validation, auth protection, account operations, password reset, and OTP verification. Supporting libs include session handling, hashing, request IDs, and rate limiting. This indicates that identity, password updates, and account deletion are enforced on the server side rather than in the client.
6. Bookmark/content subsystem
The core domain is saved content management. Server-side contentController, contentService, and embeddingService handle bookmark creation, editing, deletion, and retrieval. Validation is centralized through shared Zod schemas in packages/validator, so both input shape and domain rules are consistent across layers.
7. Sharing subsystem
Public access is separated from authenticated management. There are distinct controllers/services for content sharing and user profile sharing, likely backed by share hashes or links. The client has pages for shared content and shared profiles, which consume these public endpoints without needing full authentication.
8. AI and “Magic Fill” flow
AI functionality is split out of the main backend into apps/aiServer. The main server calls this service for AI-assisted features such as chat, embeddings, and Magic Fill. The AI service itself has controllers/routes for chat, embedding generation, and URL-based metadata filling.
9. AI service responsibilities
The AI server is a thin stateless microservice that likely does two things: fetches or scrapes source content from URLs and invokes external models for generation. Its code references Cheerio for HTML scraping and external model integration through Google GenAI and Groq. This keeps LLM/network-heavy logic out of the main application server.
10. Persistence layer
Database access is centralized in packages/database, which contains Drizzle ORM configuration, schema definitions, and migration history. The application server is the only layer that should touch PostgreSQL directly. That creates a clear boundary: client → API → database, with AI calls routed separately through the AI service.
11. Shared packages
The monorepo packages are important architectural building blocks:
- packages/ui: reusable design-system-style React components
- packages/icons: shared icon set
- packages/libs: common utilities and category helpers
- packages/validator: shared Zod schemas
- packages/typescript-config and packages/eslint-config: standardization across workspaces
These reduce duplication and keep feature code thin.
12. Deployment and environment split
Each runtime has its own deployment config and environment file: client, server, and AI server are separated for independent hosting. The repo also includes GitHub Actions workflows and Dockerfiles, which suggests each service can be built and deployed independently rather than as a single monolith.
13. Primary request flows
The main flow is: browser app submits auth/content actions to the Express server; the server validates, stores, and serves data from PostgreSQL; AI-assisted actions are forwarded to the AI microservice; the AI microservice calls external model providers and scraping utilities; results flow back through the server to the UI. Public sharing bypasses most authentication but still reads from the same backend domain model.
14. Architecture takeaway
This is not a simple frontend/backend split; it is a modular monorepo with a clear separation between product UI, core application API, and AI-specific processing. The strongest diagram boundaries are: browser client, main API server, AI microservice, PostgreSQL, and external LLM providers.
Main entry points: indexRoute.ts Routes · contentService.ts Services · aiController.ts AI Ctrl · MainContentArea.tsx UI Components
Components 23
Web Client
React/Vite SPA for product UI
- App Shell · Client routing and top-level app composition
apps/web/client/src/App.tsx - Pages · Landing, docs, auth, dashboard, profile, shared, and legal screens
apps/web/client/src/Pages/Dashboard.tsx - API Services · Axios-backed feature services for auth, content, sharing, chat, and Magic Fill
apps/web/client/src/services/fetchDataService.ts - Query Hooks · React Query-style hooks wrapping service calls and mutations
apps/web/client/src/hooks/react-query-hooks/useDashboardFetch.ts - UI Store · Local UI state such as layout and drawers
apps/web/client/src/store/uiSlice.ts - UI Components · Reusable page, dashboard, profile, landing, and legal components
apps/web/client/src/components/dashboard/MainContentArea.tsx
Main API
Express application server and business logic
- Routes · Request surface for sign-in, user, content, sharing, OTP, and AI
apps/web/server/src/routes/indexRoute.ts - Middlewares · Auth, validation, rate limiting, request IDs, and error handling
apps/web/server/src/middlewares/authMiddleware.ts - User Ctrl · Sign, account, email, OTP, and reset-password controllers
apps/web/server/src/controllers/user/signController.ts - Content Ctrl · Bookmark/content management entrypoint
apps/web/server/src/controllers/content/contentController.ts - Share Ctrl · Controllers for shared content and shared profiles
apps/web/server/src/controllers/share/contentShareController.ts - AI Ctrl · Server-side gateway for chat, embeddings, and Magic Fill
apps/web/server/src/controllers/ai/aiController.ts - Services · Content, embedding, share, and account service layer
apps/web/server/src/services/content/contentService.ts - Server Libs · Sessions, hashing, env config, and rate limiting
apps/web/server/src/libs/sessions.ts
AI Service
Hono-based microservice for AI-assisted features
- AI Routes · Chat, embedding, and Magic Fill endpoints
apps/aiServer/src/routes/chat.ts - AI Controllers · Chat, embedding, and Magic Fill handlers
apps/aiServer/src/controller/chatController.ts - AI Models · Embedding prompts, Groq integration, and URL content processing
apps/aiServer/src/models/groqModels.ts
Shared Packages
Reusable code shared across runtimes
- Validator · Shared Zod schemas for content, account, chat, and OTP validation
packages/validator/src/index.ts - UI Kit · Shared design-system components used by the client
packages/ui/src/index.tsx - Icons · Shared icon set for navigation, content, auth, and actions
packages/icons/src/index.tsx - Shared Utils · Common categories and utility helpers
packages/libs/src/index.ts
Connections 28
- App Shell → Pages: renders · App shell routes into page-level views
- Pages → UI Components: composes · Pages are built from reusable feature components
- Pages → Query Hooks: reads data via · Pages rely on query hooks for server state
- Query Hooks → API Services: calls · Hooks wrap the service layer
- API Services → Routes: requests · Client services talk to the Express API
- UI Store → UI Components: drives · UI state influences layout and drawers
- UI Components → UI Kit: uses · Client components reuse shared UI primitives
- UI Components → Icons: uses · Client components reuse shared icons
- API Services → Validator: adheres to · Request payloads follow shared schemas
- Routes → Middlewares: passes through · Requests are filtered by validation and auth middleware
- Routes → User Ctrl: dispatches to · Auth and account routes map to user controllers
- Routes → Content Ctrl: dispatches to · Content routes map to content controllers
- Routes → Share Ctrl: dispatches to · Share routes expose public content/profile access
- Routes → AI Ctrl: dispatches to · AI-related actions route through the AI controller
- User Ctrl → Services: delegates · Controllers hand off persistence and auth work
- Content Ctrl → Services: delegates · Bookmark CRUD is implemented in services
- Share Ctrl → Services: delegates · Share links and public views use service logic
- AI Ctrl → Services: orchestrates · AI actions are coordinated from the server layer
- Services → DB Client: persists via · Business logic writes and reads through the database client
- DB Client → Schema: uses · Database access is grounded in the shared schema
- Services → Validator: validates with · Server enforces shared input and domain rules
- Middlewares → Server Libs: depends on · Middleware relies on sessions, hashing, limits, and env config
- AI Ctrl → AI Routes: calls service · Main API forwards AI work to the microservice
- AI Routes → AI Controllers: invokes · Routes connect to AI request handlers
- AI Controllers → AI Models: uses · Controllers rely on model, embedding, and scraping logic
- AI Models → Validator: shares schemas · AI request shapes align with shared validation
- AI Ctrl → AI Routes: forwards to · AI requests are routed out of the main API
- AI Models → Routes: responds to · AI results flow back through the main application