A full-stack Note-Taking application using Node.js, Express, MongoDB, and a client-side interface with HTML/CSS/JavaScript. Each user can register, log in, and manage their own notes—including categories/tags for organizing notes better.
- Features
- Tech Stack
- Project Structure
- Setup and Installation
- API Documentation
- Usage Guide
- Running Tests
- License
- User Authentication: Create an account, log in, and manage personal note collections.
- Create / Read / Update / Delete (CRUD): Users can add new notes, update them, clone them, or delete them.
- Categories (Tags): Each note can be associated with multiple categories, making organization easy.
- Responsive Front-End: A simple, user-friendly interface that adapts to different screen sizes (desktop and mobile).
- RESTful API: All note operations are exposed via clean RESTful endpoints secured by JWT tokens.
- Error Handling: Ensures proper data is being given to the database, sending error codes when relevant.
- Node.js + Express: Back-end server and routing.
- MongoDB (with Mongoose): For data persistence.
- HTML/CSS/JavaScript: Front-end user interface.
- JWT: Token-based authentication.
- Swagger: (Optional) for API documentation.
- Jest + Supertest: Automated testing suite.
note-taking-app/
├── README.md # Project documentation
├── client # Front-end files
│ ├── public # Static assets (CSS, JS, images)
│ │ ├── css
│ │ │ └── styles.css # Main stylesheet
│ │ ├── js # Front-end scripts
│ │ │ ├── auth.js # Client-side auth helper (JWT handling)
│ │ │ ├── categories.js # Handles category management on the front-end
│ │ │ ├── index.js # Home page logic
│ │ │ ├── login.js # Login page logic
│ │ │ ├── notes.js # Note-taking page logic
│ │ │ └── register.js # Registration logic
│ │ └── images # Static images/icons
│ ├── index.html # Home page
│ ├── login.html # Login page
│ ├── notes.html # Notes interface
│ └── register.html # Registration form
└── server # Back-end API
├── config
│ └── db.js # Database connection setup
├── controllers # API request handlers
│ ├── authController.js # User authentication logic
│ ├── noteController.js # Note CRUD operations
│ └── categoryController.js # Category CRUD operations
├── middlewares
│ └── authMiddleware.js # JWT verification middleware
├── models # Database models (MongoDB/Mongoose)
│ ├── User.js # User schema
│ ├── Note.js # Note schema
│ └── Category.js # Category schema
├── routes # API routes
│ ├── authRoute.js # Routes for authentication (/api/auth)
│ ├── noteRoute.js # Routes for notes (/api/notes)
│ └── categoryRoute.js # Routes for categories (/api/notes/categories)
├── tests # Automated tests (only for development)
│ ├── authController.test.js # Tests for auth functionality
│ ├── noteController.test.js # Tests for notes
│ └── categoryController.test.js # Tests for categories
├── .env # Environment variables (ignored in production)
├── package.json # Dependencies and scripts
└── server.js # Main Express server entry point
- Node.js (v14 or later recommended)
- MongoDB installed locally or an online MongoDB service (e.g., MongoDB Atlas).
Create a .env file (in the project root) with the following keys:
MONGO_URI=<YourMongoURI>
JWT_SECRET=<YourSecretKey>
JWT_EXPIRES_IN=1h
NODE_ENV=development
PORT=5000
TEST_MONGO_URI=<YourMongoURIForTests>MONGO_URI: The connection string for your MongoDB database.JWT_SECRET: A random secret key used for JWT signing.JWT_EXPIRES_IN: Token expiration, e.g."1h"or"2d".PORT: The port the server runs on (default 5000).TEST_MONGO_URI: A separate database for running tests (only required if running tests).
-
Clone the repository:
git clone https://github.com/sjkd23/note-app.git
-
Navigate to the project folder:
cd note-taking-app -
Navigate to the server folder:
cd server -
Install dependencies:
npm install
-
Create your
.envfile as described above. -
Start the server:
npm start
-
Set your front-end API URL in
client/public/js/config.js:// config.js const CONFIG = { API_URL: "http://localhost:5000" // or your deployed server URL };
-
Open the front-end in your browser: Open index.html in your browser (located in client/public)
If you have Swagger set up, you can open:
GET /api-docsto see the interactive docs. Otherwise, you can check the routes below:
- Auth
POST /api/auth/registerPOST /api/auth/login
- Notes
GET /api/notesPOST /api/notesGET /api/notes/:idPUT /api/notes/:idDELETE /api/notes/:id
- Categories
POST /api/notes/categoriesGET /api/notes/categoriesGET /api/notes/categories/:idPUT /api/notes/categories/:idDELETE /api/notes/categories/:id
These endpoints require a valid JWT in the Authorization header (except for /register and /login).
- Register a new user at
POST /api/auth/registerwith{ username, email, password }. - Login at
POST /api/auth/loginwith{ email, password }. On success, you’ll get a JWTtoken.
- Create a note:
POST /api/noteswith{ title, content, categories (optional) }. - View all notes:
GET /api/notes. - Update a note:
PUT /api/notes/:id. - Delete a note:
DELETE /api/notes/:id. - Clone: You can also clone a note from the front-end UI if implemented.
- Create a category:
POST /api/notes/categorieswith{ name }. - View all categories:
GET /api/notes/categories. - Update a category:
PUT /api/notes/categories/:id. - Delete a category:
DELETE /api/notes/categories/:id.
-
Ensure your
.envincludesTEST_MONGO_URI. -
Then run:
npm test -
This will spin up a test environment, connect to
TEST_MONGO_URI, and run the controllers’ tests.
This project is licensed under the MIT License—feel free to modify or distribute. Check the LICENSE file (if you create one) for full details.