A REST API backend for a personal journaling application built with Spring Boot and MongoDB Atlas. Users can create accounts and manage journal entries scoped to their profile.
- Java 17
- Spring Boot
- Spring Data MongoDB
- MongoDB Atlas
- Lombok
src/main/java/com/example/yashjournal/
├── controller/
│ ├── UserController.java
│ └── JournalEntryController_v2.java
├── services/
│ ├── UserService.java
│ └── JournalEntryService.java
├── repository/
│ ├── UserRepo.java
│ └── JournalEntryRepo.java
└── entity/
├── User.java
└── JournalEntry.java
- Java 17+
- Maven
- A MongoDB Atlas account with a cluster ready
This project requires a MongoDB connection string. Do not commit your credentials.
Copy the example config and fill in your values:
cp src/main/resources/application.properties.example src/main/resources/application.properties
Then edit application.properties:
spring.data.mongodb.uri=mongodb+srv://<username>:<password>@<cluster>.mongodb.net/<dbname>
spring.application.name=yashjournal
mvn spring-boot:run
The server starts on http://localhost:8080.
| Method | Endpoint | Description |
|---|---|---|
| GET | /users | Get all users |
| POST | /users | Create a new user |
| GET | /users/{username} | Get user by username |
| PUT | /users/{username} | Update user by username |
| DELETE | /users/{username} | Delete user by username |
{
"username": "boss",
"password": "1234"
}| Method | Endpoint | Description |
|---|---|---|
| GET | /journal | Get all entries (all users) |
| GET | /journal/{username} | Get all entries for a user |
| POST | /journal/{username} | Create entry for a user |
| PUT | /journal/{id} | Update entry by ID |
| DELETE | /journal/{id} | Delete entry by ID |
{
"title": "Day 1",
"content": "Today was a good day."
}| Field | Type | Notes |
|---|---|---|
| user_id | String | Auto-generated by MongoDB |
| username | String | Unique, required |
| password | String | Required |
| journalEntries | List | @DBRef to journal_entries collection |
| Field | Type | Notes |
|---|---|---|
| id | String | Auto-generated by MongoDB |
| title | String | Required |
| content | String | Optional |
When a journal entry is created via POST /journal/{username}, the entry is first saved to the journal_entries collection. Its generated ID is then pushed into the corresponding user's journalEntries array in the users collection using a @DBRef reference. This means MongoDB stores a reference (not a copy) of the entry inside the user document.
application.propertiesis gitignored — never commit your Atlas credentials- Passwords are stored as plain text — this is a learning project, not production ready
- No authentication layer is implemented yet