How sohelrana1304/cyber-note works
1. Overall shape
This is a classic MERN split into two deployable parts: a Node/Express backend under backend/ and a React client under frontend/. The backend owns authentication, note persistence, and API endpoints; the frontend owns routing, state management, and UI.
2. Backend runtime and entrypoint
The backend starts from backend/src/server.js, which is the API bootstrap. It wires the Express app, connects to MongoDB through backend/src/config/db.js, and mounts the route modules for users and notes. Environment configuration is externalized via .env with PORT, MONGODB_URI, and JWT_SECRET.
3. Backend data layer
Persistence is MongoDB, with Mongoose-style models in backend/src/model/userModel.js and backend/src/model/noteModel.js. This is the main storage boundary: user records and notes live in the database, while controller logic transforms HTTP requests into model operations.
4. Backend request flow
HTTP requests enter route files in backend/src/routes/userRoutes.js and backend/src/routes/noteRoutes.js, pass through middleware when needed, and then land in controllers (userController.js, noteController.js). Controllers encapsulate CRUD and auth behavior, keeping route definitions thin.
5. Authentication boundary
Authentication is JWT-based. backend/src/utils/generateToken.js creates tokens after login/signup, and backend/src/middleware/authMiddleware.js protects note-related endpoints by validating the token before allowing access. This is the main security boundary between anonymous and authenticated use.
6. Backend domain responsibilities
The backend supports two main domains: users and notes. User endpoints handle registration/login/profile-style identity flows, while note endpoints handle create/read/update/delete and likely filtering/search. The readme’s search feature implies note retrieval is not just raw list loading but includes query-based lookup by title/body.
7. Frontend runtime and application structure
The frontend is a React app rooted at frontend/src/index.js and frontend/src/App.js. It is organized by concern: screens/ for page-level views, components/ for shared UI, actions/ and reducers/ for Redux logic, constants/ for action types, and store.js for the Redux store setup.
8. Frontend state and API flow
The client uses Redux to manage asynchronous user and note state. frontend/src/actions/userActions.js and notesActions.js call the backend API, dispatch state transitions defined in the reducers, and feed data back into screens like login, register, notes list, and single note views. frontend/src/helper/BaseURL.js centralizes the backend base endpoint.
9. Frontend screen-level boundaries
The UI is split into explicit screens: LandingPage, LoginScreen, RegisterScreen, MyNotes, CreateNote, SingleNote, and ProfileScreen. This indicates a route-oriented user experience where each screen corresponds to a major app task rather than a generic SPA shell.
10. Shared UI and layout
Reusable presentation pieces live in components/, including Header, Footer, Loading, ErrorMessage, and MainScreen. These provide the common app frame and state feedback around the screen content. Styling is split between global CSS and screen-specific CSS files.
11. External dependencies and operational notes
The only explicit external systems are MongoDB for persistence and the JWT secret for token signing. The app is designed to run locally with separate install/start commands for server and client, and it also has a deployed live URL on Render, which suggests the backend and frontend may be hosted together or coordinated in production.
12. Helpful diagram boundaries
An accurate architecture diagram should show: browser → React UI → Redux/actions → Express API → auth middleware → controllers → Mongoose models → MongoDB, with JWT returned from the backend and reused by the client on protected note operations. The Postman collection at the repo root is a supporting artifact for API testing, not part of runtime flow.
Main entry points: MainScreen.js Shared UI · userActions.js User actions · notesActions.js Note actions · server.js API server
Components 26
Backend
Node/Express API, auth, persistence, and routes
- API server · Starts the backend, wires middleware, routes, and database connection.
backend/src/server.js - Mongo connect · Creates the MongoDB connection used by the backend.
backend/src/config/db.js - User routes · Defines registration and login endpoints.
backend/src/routes/userRoutes.js - Note routes · Defines note CRUD and protected note endpoints.
backend/src/routes/noteRoutes.js - User controller · Handles user signup, login, and identity-related flows.
backend/src/controllers/userController.js - Note controller · Handles note CRUD and retrieval logic.
backend/src/controllers/noteController.js - Auth guard · Validates JWTs before protected note operations.
backend/src/middleware/authMiddleware.js - Token util · Creates signed JWTs after successful authentication.
backend/src/utils/generateToken.js - User model · Defines user records stored in MongoDB.
backend/src/model/userModel.js - Note model · Defines note records stored in MongoDB.
backend/src/model/noteModel.js
Frontend
React client, Redux state, and screens
- React app · Browser entrypoint that mounts the client application.
frontend/src/index.js - App shell · Top-level client composition and route wiring.
frontend/src/App.js - Redux store · Configures client state management for user and notes data.
frontend/src/store.js - User actions · Calls the backend for auth and profile-related flows.
frontend/src/actions/userActions.js - Note actions · Calls the backend for note CRUD and retrieval flows.
frontend/src/actions/notesActions.js - User reducer · Stores authentication and user state transitions.
frontend/src/reducers/userReducers.js - Note reducer · Stores note collection and note detail state.
frontend/src/reducers/notesReducers.js - API base · Centralizes the backend API endpoint used by client requests.
frontend/src/helper/BaseURL.js - Landing page · Public entry screen for the app.
frontend/src/screens/LandingPage/LandingPage.js - Login screen · Authenticates existing users.
frontend/src/screens/LoginScreen/LoginScreen.js - Register screen · Creates new user accounts.
frontend/src/screens/RegisterScreen/RegisterScreen.js - My notes · Lists and manages the current user's notes.
frontend/src/screens/MyNotes/MyNotes.js - Create note · Composes a new note.
frontend/src/screens/CreateNote/CreateNote.js - Single note · Shows one note in detail.
frontend/src/screens/SingleNote/SingleNote.js - Profile screen · Shows the signed-in user's profile information.
frontend/src/screens/ProfileScreen/ProfileScreen.js - Shared UI · Common layout and status components used across screens.
frontend/src/components/MainScreen.js
Connections 33
- API server → Mongo connect: connects · Initializes the MongoDB connection at startup.
- API server → User routes: mounts · Registers user-related API routes.
- API server → Note routes: mounts · Registers note-related API routes.
- User routes → User controller: delegates · Hands off user requests to controller logic.
- Note routes → Note controller: delegates · Hands off note requests to controller logic.
- Note routes → Auth guard: protects · Validates JWTs on secured note endpoints.
- User controller → User model: reads/writes · Persists and fetches user records.
- User controller → Token util: issues · Creates JWTs after successful auth.
- Note controller → Note model: reads/writes · Persists and fetches note records.
- Note controller → User model: references · Associates notes with user identity.
- React app → App shell: mounts · Bootstraps the client application tree.
- App shell → Redux store: uses · Connects routing/UI to the Redux store.
- Redux store → User reducer: combines · Includes user state management.
- Redux store → Note reducer: combines · Includes note state management.
- User actions → API base: calls · Targets the backend API endpoint.
- Note actions → API base: calls · Targets the backend API endpoint.
- User actions → User reducer: dispatches · Updates auth and profile state.
- Note actions → Note reducer: dispatches · Updates note state.
- Landing page → Login screen: navigates · Directs users toward authentication.
- Landing page → Register screen: navigates · Directs users toward account creation.
- Login screen → User actions: uses · Submits login requests through Redux.
- Register screen → User actions: uses · Submits registration requests through Redux.
- My notes → Note actions: uses · Loads and mutates note data.
- Create note → Note actions: uses · Creates new notes through Redux.
- Single note → Note actions: uses · Fetches a single note and updates it.
- Profile screen → User actions: uses · Reads signed-in user state and profile data.
- Shared UI → Landing page: wraps · Provides common layout and feedback.
- Shared UI → Login screen: wraps · Provides common layout and feedback.
- Shared UI → Register screen: wraps · Provides common layout and feedback.
- Shared UI → My notes: wraps · Provides common layout and feedback.
- Shared UI → Create note: wraps · Provides common layout and feedback.
- Shared UI → Single note: wraps · Provides common layout and feedback.
- Shared UI → Profile screen: wraps · Provides common layout and feedback.