This is a full-stack photo-sharing web application inspired by Unsplash. It features a Java Spring Boot backend with a RESTful API and a React frontend. This project is designed to showcase a modern, scalable, and well-documented application, perfect for a developer portfolio.
- User Authentication: Secure user registration and login using JWT authentication.
- Image Management: Upload, view, and manage your photos.
- Image Collections: Create and manage collections of photos.
- Social Features: Follow other users.
- Search: Powerful search functionality to discover photos.
- API Documentation: Interactive API documentation powered by Swagger UI.
- Java 17
- Spring Boot 3
- Spring Data MongoDB: For database interaction.
- Spring Security: For authentication and authorization with JWT.
- Azure Blob Storage: For storing and managing image files.
- SpringDoc (Swagger UI): For API documentation.
- Lombok: To reduce boilerplate code.
- Gradle: As the build tool.
- React
- React Router
- (Other frontend libraries...)
The backend is organized into the following key packages:
- Controllers: Handle incoming HTTP requests and delegate to services.
- Models: Define the data structures of the application (Entities, DTOs, and Requests).
- Services: Contain the business logic of the application.
- Repositories: Provide an abstraction over the database.
- Exceptions: Custom exceptions for handling specific error scenarios.
The API is documented using Swagger UI. Once you run the application, you can access the interactive API documentation at http://localhost:8080/swagger-ui.html.
| Method | Endpoint | Description |
|---|---|---|
POST |
/register |
Register a new user. |
POST |
/authenticate |
Authenticate a user and receive a JWT. |
GET |
/me |
Check if the session token is valid. |
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Get all images. |
GET |
/latest |
Get all images, sorted by the latest. |
GET |
/{id} |
Get a specific image by its ID. |
POST |
/ |
Upload a new image. |
GET |
/search?query={query} |
Search for images. |
GET |
/profile/{username} |
Get all images uploaded by a user. |
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Get all collections. |
POST |
/ |
Create a new collection. |
POST |
/{collectionId}/images |
Add an image to a collection. |
PATCH |
/{id} |
Update a collection's details. |
DELETE |
/{id} |
Delete a collection. |
DELETE |
/{id}/images/{imageId} |
Remove an image from a collection. |
| Method | Endpoint | Description |
|---|---|---|
POST |
/ |
Create a new profile. |
GET |
/ |
Get all profiles. |
GET |
/{username} |
Get a profile by username. |
PUT |
/{username}/update |
Update a profile. |
POST |
/follow |
Follow a user. |
To get a local copy up and running, follow these simple steps.
- Java JDK 17 or later
- Gradle 7.x or later
- MongoDB instance (local or cloud)
- Azure Storage Account
- Clone the repo
git clone https://github.com/your_username/your_repository.git
- Navigate to the project directory
cd unsplash_server - Configure the application
Open
src/main/resources/application.propertiesand update the following properties with your credentials:# MongoDB Configuration spring.data.mongodb.uri=mongodb://localhost:27017/your_db_name # JWT Secret jwt.secret=your_jwt_secret # Azure Storage Configuration azure.storage.connection-string=your_azure_storage_connection_string azure.storage.container-name=your_azure_container_name
- Run the application
The application will be available at
./gradlew bootRun
http://localhost:8080.
Distributed under the MIT License. See LICENSE for more information.