How pranabbhardwaj137/nirvaanai works
Main Components Identification
• Frontend Client: Represented in the "src" folder. This includes the core React application (App.tsx, main.tsx), individual pages (e.g., Home, Login, ProfilePage, etc.), components (e.g., Chatbot, MoodAssessment, Notifications), and context for managing authentication state.
• Backend Server: Found in the "server" directory with server.js managing API endpoints that likely interact with the database and third-party services.
• Database: As specified in the README (MongoDB with Mongoose) that stores user data, recommendations, forum posts, and happiness scores.
• External Services: Such as the Open AI API for chatbot support and any third-party integrations for stress relief (tailored recommendations for songs, movies, books).
Relationships and Interactions
• The Frontend communicates with the Backend through RESTful API calls. For example, after the user signs in or interacts with the chatbot, the data flows from components (e.g., Chatbot.tsx, MoodAssessment) to the server.
• The Backend, running on Node.js with Express, handles these requests, performs business logic, and interacts with the MongoDB database for read/write operations.
• Environmental configurations (like your OpenAI API key) are managed at the root with a .env file, influencing server behavior when integrating external services.
• There is a clear separation of authentication layers, as seen by the context/AuthContext.tsx being included in both the root "context" and "src/context" folders, indicating the use of context API for managing auth state on the client side.
Architectural Patterns and Design Principles
• MVC / Component-Based Architecture: The frontend uses React.js’s componentization (individual components, pages, and context) to manage UI and state.
• Separation of Concerns: The project extensively separates presentation (React JSX components) from backend logic (Express server) and further separates middleware/logic from static assets (public, imgs).
• API-driven Communication: The client makes HTTP requests to the server which in turn interacts with the database.
• Use of modern tooling: Vite for project bundling, Tailwind CSS for styling, and TypeScript for type safety, as evidenced by the tsconfig files.
Technologies, Frameworks, and Libraries
• Frontend: React.js (SPA components, pages), Vite (build tool), Tailwind CSS (styling), TypeScript.
• Backend: Node.js, Express.js, and possibly supporting libraries like nodemon for development.
• Database: MongoDB using Mongoose ODM.
• External: Open AI API integration for chatbot features.
• Tooling: ESLint (eslint.config.js) for linting rules, PostCSS for CSS transformations, and environment configuration.