This project is a TypeScript, OOP-focused “Simple Notes Management System” implemented as an interactive command-line application. It demonstrates core object-oriented concepts (classes, inheritance, composition/aggregation/association patterns, and generics) through the app’s domain models and services.
The CLI supports:
- User signup and login
- Selecting or creating note books
- Selecting, creating, updating, and previewing notes
- OOP domain models:
User(withagevalidation)Admin(extendsUser)NoteBook(stores notes)Note(implementsINoteand providespreview())- Generic
Storage<T>(in-memory collection)
- In-memory “database” + in-memory session state
- CLI workflow driven by
@clack/prompts(select/text/password/confirm prompts) - Note preview formatting (shows the first 50 characters of content)
- TypeScript (compiled with
tsc) - Node.js with ES Modules (
"type": "module",module: "nodenext") @clack/prompts(interactive CLI prompts)chalk(terminal styling)- Node.js
crypto.randomUUID()(IDs)
src/index.ts: CLI entrypoint and main interactive flowsrc/database.ts: in-memory seeded data + session getters/setterssrc/Models/User.tsAdmin.tsNoteBook.ts(also definesINoteand the internalNoteimplementation)Storage.ts
src/Services/auth.service.ts: signup/login logicnote.service.ts: note book/note operations
src/util/action.enms.ts: enums used by the CLItypes.ts:TSessiontype
Project diagram assets in the repo root:
UML.jpgUML.drawioFlow Chart.drawio
- Node.js and npm
npm install- None (the codebase does not use
process.envor.env).
- Build:
npm run build
- Start the CLI:
npm run start:js
npm run devThis runs the TypeScript compiler in watch mode and re-runs Node on the compiled dist/index.js.
npm run start:ts currently runs npx -w tsc (TypeScript compilation only) and does not start the CLI process.
When you start the app, you will see:
- Signup / Login / Exit
- After login, you manage note books and notes:
- Select a note book (or choose Create new NoteBook)
- Select a note (or choose Create new Note)
- Choose an action:
- Update Note (enter title and/or content)
- Preview Note (prints a formatted preview)
- Exit
User.agemust be between 18 and 60 (inclusive). Invalid values throw an error.- Signup:
- Prevents duplicate emails
- Creates a new user
- Automatically creates a notebook named
mainfor the new user
- Login:
- Requires matching email and password
- Note preview:
- Displays content truncated to the first 50 characters, followed by
" ..."
- Displays content truncated to the first 50 characters, followed by
On startup, src/database.ts seeds:
- Admin user:
omar@admin.com/admin
- Regular users:
ahmed@example.com/123456sara@example.com/abcdef
- Note books:
- For
ahmed@example.com:Work Notes,Personal Notes - For
sara@example.com:Ideas
- For
- Notes are also pre-created under those notebooks.
Because everything is in-memory, any changes you make exist only for the current run.
From package.json:
build:npx tscstart:js:node ./dist/index.jsstart:ts:npx -w tscdev:concurrently "tsc -w" "node --watch ./dist/index.js" --kill-others
- In-memory data layer:
src/database.tsusesStorage<T>to store users and tracks the current session (user,noteBook,note) for the CLI. - Services layer:
AuthServicehandles signup/login and session initializationNoteServicehandles selecting/creating note books, creating/updating notes, and generating previews
- Domain models:
NoteBookowns its notes internally (_notes)Notereferences itsauthor(User) andnoteBookfor association-style modeling
- This project is for education purposes only.