# sohelrana1304/cyber-note architecture

> Architecture diagram of the GitHub repository sohelrana1304/cyber-note, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sohelrana1304/cyber-note
- Repository: https://github.com/sohelrana1304/cyber-note

## Overview

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: [`frontend/src/components/MainScreen.js`](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/components/MainScreen.js) (Shared UI), [`frontend/src/actions/userActions.js`](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/actions/userActions.js) (User actions), [`frontend/src/actions/notesActions.js`](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/actions/notesActions.js) (Note actions), [`backend/src/server.js`](https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/server.js) (API server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Backend"]
  node_server["API server<br/>express bootstrap<br/>[server.js]"]
  node_db[("Mongo connect<br/>db config<br/>[db.js]")]
  node_user_routes["User routes<br/>route layer<br/>[userRoutes.js]"]
  node_note_routes["Note routes<br/>route layer<br/>[noteRoutes.js]"]
  node_user_controller["User controller<br/>auth controller<br/>[userController.js]"]
  node_note_controller["Note controller<br/>notes controller<br/>[noteController.js]"]
  node_auth_middleware["Auth guard<br/>jwt middleware<br/>[authMiddleware.js]"]
  node_token_util["Token util<br/>jwt helper<br/>[generateToken.js]"]
  node_user_model["User model<br/>mongoose model<br/>[userModel.js]"]
  node_note_model["Note model<br/>mongoose model<br/>[noteModel.js]"]
end

subgraph group_frontend["Frontend"]
  node_app_root["React app<br/>ui bootstrap<br/>[index.js]"]
  node_app_shell["App shell<br/>routing shell<br/>[App.js]"]
  node_store["Redux store<br/>state setup<br/>[store.js]"]
  node_user_actions["User actions<br/>redux async<br/>[userActions.js]"]
  node_note_actions["Note actions<br/>redux async<br/>[notesActions.js]"]
  node_user_reducers["User reducer<br/>redux reducer<br/>[userReducers.js]"]
  node_note_reducers["Note reducer<br/>redux reducer<br/>[notesReducers.js]"]
  node_base_url["API base<br/>client config<br/>[BaseURL.js]"]
  node_landing["Landing page<br/>screen<br/>[LandingPage.js]"]
  node_login["Login screen<br/>[LoginScreen.js]"]
  node_register["Register screen<br/>[RegisterScreen.js]"]
  node_my_notes["My notes<br/>screen<br/>[MyNotes.js]"]
  node_create_note["Create note<br/>screen<br/>[CreateNote.js]"]
  node_single_note["Single note<br/>screen<br/>[SingleNote.js]"]
  node_profile["Profile screen<br/>[ProfileScreen.js]"]
  node_shared_ui["Shared UI<br/>components<br/>[MainScreen.js]"]
end

node_server -->|"connects"| node_db
node_server -->|"mounts"| node_user_routes
node_server -->|"mounts"| node_note_routes
node_user_routes -->|"delegates"| node_user_controller
node_note_routes -->|"delegates"| node_note_controller
node_note_routes -->|"protects"| node_auth_middleware
node_user_controller -->|"reads/writes"| node_user_model
node_user_controller -->|"issues"| node_token_util
node_note_controller -->|"reads/writes"| node_note_model
node_note_controller -->|"references"| node_user_model
node_app_root -->|"mounts"| node_app_shell
node_app_shell -->|"uses"| node_store
node_store -->|"combines"| node_user_reducers
node_store -->|"combines"| node_note_reducers
node_user_actions -->|"calls"| node_base_url
node_note_actions -->|"calls"| node_base_url
node_user_actions -->|"dispatches"| node_user_reducers
node_note_actions -->|"dispatches"| node_note_reducers
node_landing -->|"navigates"| node_login
node_landing -->|"navigates"| node_register
node_login -->|"uses"| node_user_actions
node_register -->|"uses"| node_user_actions
node_my_notes -->|"uses"| node_note_actions
node_create_note -->|"uses"| node_note_actions
node_single_note -->|"uses"| node_note_actions
node_profile -->|"uses"| node_user_actions
node_shared_ui -->|"wraps"| node_landing
node_shared_ui -->|"wraps"| node_login
node_shared_ui -->|"wraps"| node_register
node_shared_ui -->|"wraps"| node_my_notes
node_shared_ui -->|"wraps"| node_create_note
node_shared_ui -->|"wraps"| node_single_note
node_shared_ui -->|"wraps"| node_profile

click node_server "https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/server.js"
click node_db "https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/config/db.js"
click node_user_routes "https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/routes/userRoutes.js"
click node_note_routes "https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/routes/noteRoutes.js"
click node_user_controller "https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/controllers/userController.js"
click node_note_controller "https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/controllers/noteController.js"
click node_auth_middleware "https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/middleware/authMiddleware.js"
click node_token_util "https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/utils/generateToken.js"
click node_user_model "https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/model/userModel.js"
click node_note_model "https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/model/noteModel.js"
click node_app_root "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/index.js"
click node_app_shell "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/App.js"
click node_store "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/store.js"
click node_user_actions "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/actions/userActions.js"
click node_note_actions "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/actions/notesActions.js"
click node_user_reducers "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/reducers/userReducers.js"
click node_note_reducers "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/reducers/notesReducers.js"
click node_base_url "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/helper/BaseURL.js"
click node_landing "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/screens/LandingPage/LandingPage.js"
click node_login "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/screens/LoginScreen/LoginScreen.js"
click node_register "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/screens/RegisterScreen/RegisterScreen.js"
click node_my_notes "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/screens/MyNotes/MyNotes.js"
click node_create_note "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/screens/CreateNote/CreateNote.js"
click node_single_note "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/screens/SingleNote/SingleNote.js"
click node_profile "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/screens/ProfileScreen/ProfileScreen.js"
click node_shared_ui "https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/components/MainScreen.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_db,node_user_routes,node_note_routes,node_user_controller,node_note_controller,node_auth_middleware,node_token_util,node_user_model,node_note_model toneBlue
class node_app_root,node_app_shell,node_store,node_user_actions,node_note_actions,node_user_reducers,node_note_reducers,node_base_url,node_landing,node_login,node_register,node_my_notes,node_create_note,node_single_note,node_profile,node_shared_ui toneAmber
```

## Components

### Backend

Node/Express API, auth, persistence, and routes

- [API server](https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/server.js): express bootstrap · Starts the backend, wires middleware, routes, and database connection. · `backend/src/server.js`
- [Mongo connect](https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/config/db.js): db config · Creates the MongoDB connection used by the backend. · `backend/src/config/db.js`
- [User routes](https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/routes/userRoutes.js): route layer · Defines registration and login endpoints. · `backend/src/routes/userRoutes.js`
- [Note routes](https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/routes/noteRoutes.js): route layer · Defines note CRUD and protected note endpoints. · `backend/src/routes/noteRoutes.js`
- [User controller](https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/controllers/userController.js): auth controller · Handles user signup, login, and identity-related flows. · `backend/src/controllers/userController.js`
- [Note controller](https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/controllers/noteController.js): notes controller · Handles note CRUD and retrieval logic. · `backend/src/controllers/noteController.js`
- [Auth guard](https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/middleware/authMiddleware.js): jwt middleware · Validates JWTs before protected note operations. · `backend/src/middleware/authMiddleware.js`
- [Token util](https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/utils/generateToken.js): jwt helper · Creates signed JWTs after successful authentication. · `backend/src/utils/generateToken.js`
- [User model](https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/model/userModel.js): mongoose model · Defines user records stored in MongoDB. · `backend/src/model/userModel.js`
- [Note model](https://github.com/sohelrana1304/cyber-note/blob/main/backend/src/model/noteModel.js): mongoose model · Defines note records stored in MongoDB. · `backend/src/model/noteModel.js`

### Frontend

React client, Redux state, and screens

- [React app](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/index.js): ui bootstrap · Browser entrypoint that mounts the client application. · `frontend/src/index.js`
- [App shell](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/App.js): routing shell · Top-level client composition and route wiring. · `frontend/src/App.js`
- [Redux store](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/store.js): state setup · Configures client state management for user and notes data. · `frontend/src/store.js`
- [User actions](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/actions/userActions.js): redux async · Calls the backend for auth and profile-related flows. · `frontend/src/actions/userActions.js`
- [Note actions](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/actions/notesActions.js): redux async · Calls the backend for note CRUD and retrieval flows. · `frontend/src/actions/notesActions.js`
- [User reducer](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/reducers/userReducers.js): redux reducer · Stores authentication and user state transitions. · `frontend/src/reducers/userReducers.js`
- [Note reducer](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/reducers/notesReducers.js): redux reducer · Stores note collection and note detail state. · `frontend/src/reducers/notesReducers.js`
- [API base](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/helper/BaseURL.js): client config · Centralizes the backend API endpoint used by client requests. · `frontend/src/helper/BaseURL.js`
- [Landing page](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/screens/LandingPage/LandingPage.js): screen · Public entry screen for the app. · `frontend/src/screens/LandingPage/LandingPage.js`
- [Login screen](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/screens/LoginScreen/LoginScreen.js): screen · Authenticates existing users. · `frontend/src/screens/LoginScreen/LoginScreen.js`
- [Register screen](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/screens/RegisterScreen/RegisterScreen.js): screen · Creates new user accounts. · `frontend/src/screens/RegisterScreen/RegisterScreen.js`
- [My notes](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/screens/MyNotes/MyNotes.js): screen · Lists and manages the current user's notes. · `frontend/src/screens/MyNotes/MyNotes.js`
- [Create note](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/screens/CreateNote/CreateNote.js): screen · Composes a new note. · `frontend/src/screens/CreateNote/CreateNote.js`
- [Single note](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/screens/SingleNote/SingleNote.js): screen · Shows one note in detail. · `frontend/src/screens/SingleNote/SingleNote.js`
- [Profile screen](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/screens/ProfileScreen/ProfileScreen.js): screen · Shows the signed-in user's profile information. · `frontend/src/screens/ProfileScreen/ProfileScreen.js`
- [Shared UI](https://github.com/sohelrana1304/cyber-note/blob/main/frontend/src/components/MainScreen.js): components · Common layout and status components used across screens. · `frontend/src/components/MainScreen.js`

## Connections

- 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.
