How aniketmishra31/digi-diary works
Project type and purpose
• Digi Diary is a full-stack web application (MERN stack) that lets authenticated users write, edit, delete, and browse private diary entries online.
• The front end is built in React (components under src/components), and the back end is an Express/Node.js API connecting to MongoDB.
File structure
• Top-level files:
– package.json / package-lock.json: front-end dependencies and build scripts
– README.md: project description
• public/: React’s static assets and index.html (SPA entry point)
• src/: React application source
– src/.env: environment variables (e.g., REACT_APP_API_URL, JWT secret)
– src/index.js + src/App.js: application bootstrap and routing (React Router)
– src/components/: UI components covering authentication (Login, Signup, AuthNavbar), navigation (Navbar, Footer), diary CRUD pages (Create, Update, PostsList, Post), static pages (About, Help, Contact, Cover), and user profile.
(Note: Although the back-end code is not present here, the README confirms an Express/Node API and a MongoDB database.)
README for additional insights
• Confirms use of JWT for auth and MongoDB for data persistence
• Mentions Express.js for RESTful API development
• Highlights client-server communication via JSON over HTTP
a. Main components:
1. React Front End (SPA)
2. Node.js/Express Back End (REST API)
3. MongoDB Database
4. Authentication Service (JWT issuance & validation)
5. (Optional) Hosting/CDN for front end and cloud provider for database
b. Relationships and interactions:
• The React SPA issues HTTPS requests (GET/POST/PUT/DELETE) to Express endpoints (e.g., /api/auth, /api/diaries).
• On login/signup, the back end verifies credentials against MongoDB, issues a JWT, and returns it to the client.
• For protected routes, the SPA includes the JWT in the Authorization header. The Express middleware validates the token before granting access.
• CRUD operations go through the Express controllers, which read/write diary documents in MongoDB.
c. Architectural patterns and design principles:
• SPA architecture (separation of concerns between UI and data layer)
• RESTful API design on the server
• Token-based stateless authentication (JWT)
• Component-based UI in React
d. Relevant technologies:
• React & React Router for front end
• Express.js & Node.js for back end
• Mongoose or MongoDB driver for data modeling/persistence
• JSON Web Tokens (jsonwebtoken) for auth
• Fetch or Axios for HTTP requests
Essential detail checklist
• Front-end: index.html → App.js (Router) → key page components
• Back-end: route layers → auth middleware → controller logic → database operations
• Auth flow: sign-up, login, token storage, token validation on subsequent requests
• Data flow for CRUD operations: create, read (list & single), update, delete
• Environment boundaries: client vs. server vs. database vs. external (e.g., cloud database)