Markdown Note Taking App allows users to create notes in Markdown format and convert these notes to HTML format. The application also offers features such as file uploading and attaching files to notes. This application is developed using Spring Boot and integrated with PostgreSQL database.
- User Management: Users can be created, viewed, and deleted.
- Note Management: Notes can be created, viewed, and deleted.
- Markdown to HTML Conversion: Converts Markdown content to HTML.
- File Upload and Management: Add files to notes and manage files.
- Backend: Spring Boot
- For building the RESTful API and handling backend logic.
- Database: PostgreSQL
- To store and manage data securely and efficiently.
- Markdown Processing: CommonMark
- For converting Markdown content into HTML format.
- File Upload: MultipartFile
- To handle file uploads in your Spring Boot application.
- Object Mapping & Simplification: Lombok
- To reduce boilerplate code with annotations.
- Object-DTO Conversion: ModelMapper
- For mapping between your entity classes and DTOs efficiently.
-
Clone the Project:
git clone https://github.com/your_username/markdown-note-taking-app.git cd markdown-note-taking-app
-
Database Settings:
Create your PostgreSQL database and edit the src/main/resources/application.properties file accordingly:
spring.datasource.url=jdbc:postgresql://localhost:5432/markdown_app
spring.datasource.username=postgres
spring.datasource.password=your_password
- Configure and Run the Project:
mvn clean install
mvn spring-boot:run
This section explains how to use the project's API endpoints.
1. User Operations (UserController)
-
URL:
/user
-
Method:
POST
-
Description: Creates a new user.
-
Request Body:
<UserDTO>
-
Example Request:
curl -X POST http://localhost:8080/user -H "Content-Type: application/json" -d "{\"username\":\"OmerF\", \"email\":\"[email protected]\", \"password\":\"your_password\"}"
- Successful Response:
- Status:
200 OK
- Body:
{ "username": "OmerF", "email": "[email protected]", "password": "your_password" }
- URL:
/user
- Method:
GET
- Description: Retrieves all users registered in the system.
- Example Request:
curl -X GET "http://localhost:8080/user"
- Successful Response:
- Status:
200 OK
- Body:
<List<ResponseUserDTO>>
[ { "username": "OmerF", "createdAt": "YYYY-MM-DDTHH:MM:SSZ" } { "username": "user2", "createdAt": "YYYY-MM-DDTHH:MM:SSZ" } ]
- URL:
/user/{id}
- Method:
GET
- URL Parameter: 'id'
- Description: Retrieves a user by ID.
- Example Request:
curl -X GET "http://localhost:8080/user/1"
- Successful Response:
- Status:
200 OK
- Body:
<ResponseUserDTO>
{ "username": "OmerF", "createdAt": "YYYY-MM-DDTHH:MM:SSZ" }
- URL:
/user/{id}
- Method:
DELETE
- URL Parameter: 'id'
- Description: Deletes a user by ID.
- Example Request:
curl -X DELETE http://localhost:8080/user/1
- Successful Response:
- Status:
200 OK
- Body:
<ResponseUserDTO>
"User deleted!"
- Error State (User Not Found)
- Status:
404 Not Found
"User not found!"
- Error State (Wrong ID type)
- Status:
400 Bad Request
"There is no such user has this id!"
2. Note Operations (NoteController)
-
URL:
/notes
-
Method:
POST
-
Description: Adds a new note.
-
Request Body:
<NoteDTO>
-
Example Request:
curl -X POST http://localhost:8080/notes -H "Content-Type: application/json" -d '{"title":"Note Title", "content":"Markdown content will be here.", "userId":1}'
- Successful Response:
- Status:
200 OK
- Body:
{ "username" : "Username of the user with ID 1", "title" : "Note Title", "createdAt" : "2024-08-30T19:34:51.3570971", "updatedAt" : "2024-08-30T19:34:51.3570971" }
- Error State:
- Status:
500 Internal Server Error
- Body:
{ "timestamp" : "2024-08-30T16:39:07.205+00:00", "status" : 500, "error" : "Internal Server Error", "path" : "/notes" }
- URL:
/notes/{id}
- Method:
GET
- URL Parameter: 'id'
- Description: Retrieves a note by ID.
- Example Request:
curl -X GET "http://localhost:8080/notes/1"
- Successful Response: (When no file is attached to the note.)
- Status:
200 OK
- Body:
<Note>
{ "id" : 1, "title" : "Note Title", "content" : "Markdown content will be here.", "createdAt" : "2024-08-29T20:22:52.663821", "updatedAt" : "2024-08-29T20:22:52.663821", "file" : null }
- Successful Response: (When a file is attached to the note.)
- Status:
200 OK
- Body:
<Note>
{ "id" : 1, "title" : "Note Title", "content" : "Markdown content will be here.", "createdAt" : "2024-08-29T20:22:52.663821", "updatedAt" : "2024-08-29T20:22:52.663821", "file" : { "id" : 1, "fileName" : "dailytasks.txt", "filePath" : "C:\\..\\dailytasks.txt", "fileType" : "text/plain", "uploadedAt" : "2024-08-29T20:22:52.649713" } }
- Error State (Note Not Found)
- Status:
404 Not Found
- Body:
{ "timestamp" : "2024-08-30T22:09:10.117+00:00", "status" : 500, "error" : "Internal Server Error", "path" : "/notes/1" }
- Error State (Wrong ID type)
- Status:
400 Bad Request
{ "timestamp" : "2024-08-30T22:09:25.017+00:00", "status" : 400, "error" : "Bad Request", "path" : "/notes/1a" }
- URL:
/notes/user/{userId}
- Method:
GET
- URL Parameter: 'userId'
- Description: Retrieves all notes of a user by user ID.
- Example Request:
curl -X GET "http://localhost:8080/notes/user/1"
- Successful Response: (When files are attached to notes.)
- Status:
200 OK
- Body:
<List<Note>>
[ { "id" : 9, "title" : "routine", "content" : "Markdown note 1", "createdAt" : "2024-08-28T17:09:39.106826", "updatedAt" : "2024-08-28T17:38:52.354705", "file" : { "id" : 14, "fileName" : "dailytasks.txt", "filePath" : "C:\\..\\dailytasks.txt", "fileType" : "text/plain", "uploadedAt" : "2024-08-28T17:38:52.286481" } }, { "id" : 13, "title" : "meeting", "content" : "Markdown note 2", "createdAt" : "2024-08-29T19:44:15.221622", "updatedAt" : "2024-08-29T19:44:15.221622", "file" : null }, { "id" : 10, "title" : "project", "content" : "Markdown note 3", "createdAt" : "2024-08-28T17:38:52.343281", "updatedAt" : "2024-08-29T19:44:15.234142", "file" : { "id" : 17, "fileName" : "dailytasks.txt", "filePath" : "C:\\..\\codeexample.txt", "fileType" : "text/plain", "uploadedAt" : "2024-08-29T19:44:15.129561" } } ]
- Error State (Note Not Found)
- Status:
200 OK
- Body:
[]
- Error State (Wrong ID type)
- Status:
400 Bad Request
{ "timestamp" : "2024-08-30T22:09:25.017+00:00", "status" : 400, "error" : "Bad Request", "path" : "/notes/user/1a" }
- URL:
/notes/{id}
- Method:
DELETE
- URL Parameter: 'id'
- Description: Deletes a note by ID.
- Example Request:
curl -X DELETE http://localhost:8080/notes/1
- Successful Response:
- Status:
200 OK
"Note deleted"
- Error State (Note Not Found)
- Status:
404 Not Found
"Note not found"
- Error State (Wrong ID type)
- Status:
400 Bad Request
{ "timestamp" : "2024-08-30T22:44:10.670+00:00", "status" : 400, "error" : "Bad Request", "path" : "/notes/1a" }
- URL:
/notes/content/{id}
- Method:
GET
- URL Parameter: 'id'
- Description: Converts the markdown content of the note to HTML and returns it.
- Example Request:
curl -X GET http://localhost:8080/notes/content/1
- Successful Response:
- Status:
200 OK
- Body:
HTML content
<p>Content in Markdown markup language</p>
- Error State (Empty Note Content)
- Status:
200 OK
""
- Error State (Note Not Found)
- Status:
500 Internal Server Error
{ "timestamp" : "2024-08-30T22:54:25.807+00:00", "status" : 500, "error" : "Internal Server Error", "path" : "/notes/content/130" }
File Operations (FileController)
- URL:
/files
- Method:
POST
- Request Parameters:
file
filePath
noteId
- Description: Allows uploading a file to a specified path and note ID. Only
txt
orword
files must be used. - Example Request:
curl -X POST http://localhost:8080/files -H "Content-Type: multipart/form-data" -F "file=@/path/to/your/meeting.txt" -F "filePath=path/to/your/meeting.txt" -F "noteId=14"
- Successful Response:
- Status:
200 OK
- Body: 'FileDTO'
{ "fileName" : "meeting.txt", "filePath" : "path/to/your/meeting.txt", "noteId" : 14 }
- Error State
- Status:
415 Unsupported Media Type
""
- URL:
/files/{id}
- Method:
GET
- URL Parameter: 'id'
- Description: Retrieves the relevant file according to the ID.
- Example Request:
curl -X GET "http://localhost:8080/files/1"
- Successful Response:
- Status:
200 OK
- Body:
<FileDTO>
{ "fileName" : "meeting.txt", "filePath" : "path/to/your/meeting.txt", "noteId" : 14 }
- Error State (File Not Found)
- Status:
500 Internal Server Error
{ "timestamp" : "2024-08-30T22:54:25.807+00:00", "status" : 500, "error" : "Internal Server Error", "path" : "/files/230" }
- Error State (Wrong ID type)
- Status:
400 Bad Request
{ "timestamp" : "2024-08-30T22:44:10.670+00:00", "status" : 400, "error" : "Bad Request", "path" : "/files/1a" }
- URL:
/files/{id}
- Method:
DELETE
- URL Parameter: 'id'
- Description: Deletes the relevant file according to the ID.
- Example Request:
curl -X DELETE http://localhost:8080/files/1
- Successful Response:
- Status:
200 OK
"File successfully deleted"
- Error State (File Not Found)
- Status:
500 Internal Server Error
{ "timestamp" : "2024-08-30T22:54:25.807+00:00", "status" : 500, "error" : "Internal Server Error", "path" : "/files/230" }
- Error State (Wrong ID type)
- Status:
400 Bad Request
{ "timestamp" : "2024-08-30T22:44:10.670+00:00", "status" : 400, "error" : "Bad Request", "path" : "/files/1a" }