##LazyLoading ##Timing of post ##RouterDOm lazyloading ##Tailwind as styling library
Blog-Site:-(https://daily-bloggers.onrender.com/)
This document provides a comprehensive guide to the full-stack blog application, detailing its features, functionality, and architecture. The application is built to allow users to create, view, edit, and comment on blog posts. The app is designed with a responsive user interface, robust authentication, and secure data handling.
- Signup and Login: Users can sign up and log in to the application. The signup form includes fields for username, email, and password. Authentication is handled securely, ensuring only registered users can log in.
- Session Management: The application uses session cookies to maintain user login status, ensuring that users remain authenticated across different pages until they log out. 0
- Create Posts: Authenticated users can create new blog posts. The post creation form includes fields for the blog title and content. Posts are stored in the database and displayed in the blog list.
- View Posts: Users can view a list of all blog posts. Each post displays the title, content, author name, and profession, along with a timestamp indicating when the post was created.
- Edit Posts: Only the author of a post can edit their content. A modal prompts the user to confirm the edit before submission. The edit page includes fallbacks for loading, submitting, and navigating to ensure a smooth user experience.
- Delete Posts: Authors can delete their posts. A confirmation modal with a loading indicator appears before the post is permanently deleted from the database.
- Add Comments: Users can add comments to any blog post. The comment section is displayed in a side dialog that opens when the "Comments" button is clicked. After submitting a comment, it is saved to the database and immediately rendered in the comment list.
- View Comments: All comments related to a blog post are displayed in the comment section, showing the username of the commenter, the content of the comment, and the time it was posted.
- Responsive Design: The application is fully responsive, ensuring it works seamlessly on different devices and screen sizes. This includes mobile, tablet, and desktop views.
- Navigation Bar: A sticky side navigation bar is present, displaying the logo at the top, navigation buttons at the bottom, and the logged-in user's username at the very bottom.
- Blog Navigation: Users can navigate between blog posts using "Previous" and "Next" buttons within the
BlogModal
. This allows for easy browsing through posts.
- Strict Input Validation: The application enforces strict input validation using schema validation tools. This ensures that only properly formatted and safe data is submitted to the backend.
- Error Handling: Comprehensive error handling is implemented throughout the application. Users are informed of any issues, such as failed submissions or network errors, with appropriate feedback messages.
- Global State Management: The application uses a state management library to manage global states, such as the current logged-in user's username. States are persisted in local storage to maintain them across sessions.
- Dynamic State Updates: The application efficiently handles state updates, ensuring that UI components are updated in real-time without requiring a page refresh.
-
Sign-In Process
- Sign-In Page: The application begins with the Sign-In page, where users are prompted to enter their username and password.
- Authentication: After entering the credentials, the application verifies them against the stored user data. If the credentials are correct, the user is granted access to the dashboard. If incorrect, an error message is displayed, prompting the user to try again.
- Redirect: Authenticated users are redirected to the main dashboard, where they can view and manage their blog posts.
-
Sign-Up Process
- Sign-Up Page: If a user does not have an account, they can navigate to the Sign-Up page via a link on the Sign-In page.
- Sign-Up Form: The Sign-Up form requires the user to provide the following information:
- Username: A unique identifier for the user.
- Email: The user’s email address for communication and account recovery.
- Password: A secure password that the user will use to log in.
- Confirm Password: A field to re-enter the password, ensuring the user’s input is accurate.
- Account Creation: Upon submitting the form, the application checks for any validation errors (e.g., password mismatch, existing username). If all inputs are valid, the user’s data is stored in the database, and the account is created.
- Automatic Sign-In: After successful account creation, the user is automatically signed in and redirected to the main dashboard.
-
Dashboard Access
- Blog List: Once signed in, the user is presented with the dashboard, which includes a list of all blog posts. Here, users can view posts, create new ones, or edit their own posts.
- Profile Management: The user’s username is displayed in the navigation bar, with options to manage their profile or log out.
-
Creating a Blog Post
- Post Form: Users can create a new blog post by clicking the “Create Post” button. The form includes fields for:
- Title: The title of the blog post.
- Content: The main body of the post.
- Submission: After filling in the details, the user submits the form. The new post is saved in the database and immediately displayed in the blog list with the author’s name.
- Post Form: Users can create a new blog post by clicking the “Create Post” button. The form includes fields for:
-
Editing a Blog Post
- Edit Option: Only the author of a post can edit it. The “Edit” button appears next to each of their posts.
- Edit Form: The edit form pre-fills with the existing title and content, allowing the user to make changes.
- Confirmation Modal: Upon clicking the “Save” button, a confirmation modal appears to prevent accidental edits. If confirmed, the updated post is saved, and the changes are reflected immediately.
-
Commenting on a Blog Post
- View Comments: Each blog post has a “Comments” button that opens a side dialog, displaying existing comments and a field to add new ones.
- Add Comment: Users can write a comment in the input field. After submitting, the comment is saved to the database and immediately rendered in the comment list, formatted as
username: {comment}
.
-
Logging Out
- Logout Option: Users can log out of the application by clicking the “Logout” button in the navigation bar. This ends the session and redirects the user back to the Sign-In page, ensuring the security of their account.
- Sign-Up Flow: New users are guided through a simple and intuitive sign-up process. Helpful validation messages and tooltips ensure that users can create an account without confusion.
- User Dashboard: Once logged in, users are directed to a dashboard where they can view, create, and manage their blog posts.
- Loading Indicators: The application provides clear feedback during loading states, such as when fetching data, submitting forms, or navigating between pages. This ensures users are aware of ongoing processes.
- Confirmation Modals: Before performing critical actions like editing or deleting posts, users are prompted with confirmation modals. This helps prevent accidental changes and gives users control over their actions.
- User-Friendly Error Messages: If an error occurs, the application displays user-friendly messages explaining the issue and suggesting possible actions the user can take.
- Fallback Mechanisms: In case of unexpected failures, fallback mechanisms are in place to guide users back to a stable state, minimizing disruption and enhancing reliability.
-
Frontend:
- React: A JavaScript library for building user interfaces, used for creating components and managing the state of the application.
- Tailwind CSS: A utility-first CSS framework for designing the application's UI with customizable, responsive, and modern styles.
- Recoil: A state management library for React, used for managing global state and synchronizing user data across components.
- date-fns: A JavaScript library for handling and formatting dates, used to display time-related information.
- Radix UI: A set of low-level UI primitives for building accessible design systems, used here for components like dialogs.
-
Backend:
- Express.js: A web application framework for Node.js, used to create RESTful APIs for handling CRUD operations and managing blog posts and comments.
- MongoDB: A NoSQL database for storing user data, blog posts, and comments, providing flexible data models and scalability.
- Mongoose: An ODM (Object Data Modeling) library for MongoDB and Node.js, used to interact with the MongoDB database and define data schemas.
-
Authentication:
- JWT (JSON Web Tokens): A token-based authentication mechanism used for securely transmitting information between parties and managing user sessions.
-
Deployment:
- Render: A cloud platform for deploying web applications and services, used for hosting the backend API.
-
Development Tools:
- Axios: A promise-based HTTP client for making API requests from the frontend to the backend.
- ESLint: A static code analysis tool for identifying and fixing problems in JavaScript code, used for maintaining code quality.
- Prettier: A code formatter that ensures consistent styling and formatting of code.
-
Version Control:
- Git: A version control system for tracking changes in the codebase, used in conjunction with platforms like GitHub for managing the source code.
-
Other:
- LocalStorage: A web storage API for storing user data locally in the browser, used for persisting user state like the username across sessions.
This full-stack blog application is designed to provide a seamless, interactive, and secure platform for users to create and share their blog posts. With its robust feature set and thoughtful design, the application serves as a solid foundation for future enhancements and scaling.