SnapSort is a full-stack application developed using Java Spring and Next.js. It provides a platform for users to organize and sort their photos.
- Java Spring
- Next.js
- Ant Design (antd)
- Axios
- Formik
- NextAuth.js
- React
- Styled Components
- TypeScript
- Yup
- User authentication and registration
- Uploading and managing photos
- Organizing photos into albums
- Adding tags to photos for categorization
- Sorting and filtering photos based on various criteria
Before setting up the project, make sure you have the following prerequisites installed:
- Node.js
- Java (version 17)
- MySQL
- Maven
- Build the backend application. Open a terminal and navigate to the root directory of the backend project. Run the following command:
mvn clean install
Note: The build may fail initially, but we will set up the necessary configurations next.
-
Download and install MySQL or set up a MySQL database locally using Docker.
-
Set up a username and password for the MySQL database.
-
Create a MySQL database named "snap-sort".
-
Open IntelliJ IDEA and go to Run > Edit Configurations.
-
In the "SnapSortApplication" configuration, under the "Environment variables" section, add the following environment variables:
db_password=<your MySQL password>;
db_port=<port the database runs at>;
db_username=<your MySQL username>;
db_name=snap-sort;
jwt_secret=<secret jwt key>
For example:
db_password=123;db_port=3306;db_username=root;db_name=snap-sort;jwt_secret=somesecretkeygenerated
- Build and run the application. It should start at port 8080.
-
Navigate to the frontend directory in a terminal:
cd frontend
-
Install the frontend dependencies:
npm install
-
Create a
.env
file in the frontend directory. -
In the
.env
file, add the following environment variables:
NEXTAUTH_URL="http://localhost:3000/"
NEXTAUTH_SECRET="<generated secret>"
- Start the frontend development server:
npm run dev
The application should start at port 3000.
Make sure to replace , , and with your actual database credentials. Also, replace with the appropriate values for the JWT secret and NextAuth secret.
-
/backend: Contains the Java Spring backend code
-
/frontend: Contains the Next.js frontend code
SnapSort is licensed under the MIT License
API References
PUT /api/albums/{albumId}/rename
Parameter | Type | Description |
---|---|---|
albumId |
integer |
Required. ID of the album to rename |
name |
string |
Required. New name for the album |
POST /photos/upload
Parameter | Type | Description |
---|---|---|
file |
file |
Required. The photo file to be uploaded |
description |
string |
Description of the photo (optional) |
GET /photos/{id}/thumbnail
Retrieves the thumbnail of a photo with the specified id.
Parameter | Type | Description |
---|---|---|
id |
integer |
Required. ID of the photo |
GET /photos/{id}
Retrieves a photo with the specified id.
Parameter | Type | Description |
---|---|---|
id |
integer |
Required. ID of the photo |
POST /photos/{photoId}/tags/{tagId}
Adds a tag with tagId to a photo with photoId.
Parameter | Type | Description |
---|---|---|
photoId |
integer |
Required. ID of the photo |
tagId |
integer |
Required. ID of the tag to be added to photoo |
POST /photos/upload/multiple
Uploads multiple photos with an album and tags.
Parameter | Type | Description |
---|---|---|
files |
array |
Required. Array of photo files to be uploaded |
tags |
string |
Tags to be added to the photos (comma-separated) |
albumId |
integer |
ID of the album to add the photos to |
DELETE /photos/{id}
Deletes a photo with the specified id.
Parameter | Type | Description |
---|---|---|
id |
integer |
Required. ID of the photo to delete |
POST /photos/{photoId}/tags
Changes the tags for a photo with the specified photoId.
Parameter | Type | Description |
---|---|---|
photoId |
integer |
Required. ID of the photo to change tags |
POST /api/albums/{albumId}/photos/{photoId}
Saves a photo with photoId to an album with albumId.
Parameter | Type | Description |
---|---|---|
albumId |
integer |
Required. ID of the album to save the photo |
photoId |
integer |
Required. ID of the photo to be saved to album |
GET /photos/thumbnails
Retrieves all the thumbnails of photos belonging to the logged user.
GET /photos/album/{albumId}/thumbnails
Retrieves all the thumbnails of photos in an album with the specified albumId.
Parameter | Type | Description |
---|---|---|
albumId |
integer |
Required. ID of the album |
POST /tags/create
Retrieves all the thumbnails of photos in an album with the specified albumId.
Parameter | Type | Description |
---|---|---|
name |
string |
Required. Name of the new tag |
GET /tags/all
Retrieves all the tags of the logged user.
DELETE /tags/{tagId}
Deletes a tag with the specified tagId and its connections.
Parameter | Type | Description |
---|---|---|
tagId |
integer |
Required. ID of the tag to delete |