How justteshi/menta-social-app works
Project Type & Purpose
• This project is a full-stack social media application that allows users to register, log in, create posts, comment, and like content.
• The backend is built using Apollo Server with GraphQL and uses MongoDB (with Mongoose) as its data store. Authentication (via JsonWebToken and BcryptJS) is a central feature.
• The frontend is a React application (with components like NavBar, PostCard, PostForm, etc.) that interacts with the backend via GraphQL.
Main Components
• Client (Frontend) – This is located in the "client" directory.
• Contains React components, routing (pages like Home, Login, Register, Profile, Cocktail/Posts pages), context for authentication, and utility files such as hooks and GraphQL utility functions.
• GraphQL API Server (Backend) – The root-level index.js is the entry point.
• Uses Apollo Server to manage GraphQL queries/mutations.
• The "graphql" directory contains type definitions and resolvers (separated for posts, comments, and users).
• Models & Utilities – In the "models" directory are Mongoose schemas (User.js, Post.js) that represent how data is stored in MongoDB.
• The "util" directory contains authentication checks and validation logic.
• External Services – MongoDB Atlas is used as the external database service.
• Infrastructure Components: Although not explicitly shown, environment configuration and server setup should also be highlighted (ports, dependency injection, etc.).
Relationships and Interactions
• An authentication flow, showing that login/registration in the client triggers backend processes using JsonWebToken and Bcrypt for security.
• Data flows within the GraphQL server—for example, how resolvers (posts.js, users.js, comments.js) interact with the models and utilities (authentication and validators).
Architectural Patterns & Design Principles
• Separation of concerns: the project clearly separates the frontend (React) from the backend (GraphQL API).
• MVC/MVP patterns on the backend: GraphQL resolvers serve as controllers that manage interactions between the HTTP layer and Mongoose models.
• Use of a context provider in the client (ApolloProvider, context/auth) to manage state, possibly implying a clear mapping between UI components and API data.
• Security best practices using token-based authentication and proper validation.
• Clear labels for each component (e.g., “React Client”, “Apollo Server / GraphQL Layer”, “Mongoose Models (MongoDB)”).
○ Presentation layer (frontend UI)
○ API layer (GraphQL server and resolvers)
○ Data persistence layer (MongoDB)
○ Shared utility modules (authentication, validation)
• Optionally, include ancillary processes such as the build/deploy process (e.g., package.json usage in both client and server directories) if needed for completeness.