A backend for a book-focused social media platform. Users can share reviews, create reading lists, and connect with other readers. This system supports core functionality for a community of book enthusiasts.
Deployed frontend: https://book-fellow-frontend-react.pages.dev/
Demo account:
- Email: [email protected]
- Password: readingisfun
Create an .env
file in the root directory of the project and add the following environment variables:
SPRING_PROFILES_ACTIVE=dev
POSTGRES_DB=<database_name>
POSTGRES_USER=<database_user>
POSTGRES_PASSWORD=<database_user_password>
DEV_SERVER_PORT=8080
DEV_DATASOURCE_URL=jdbc:postgresql://localhost:5432/<database_name>
DEV_DATASOURCE_USERNAME=<database_user>
DEV_DATASOURCE_PASSWORD=<database_user_password>
JWT_SECRET=<jwt_secret_key>
-
Initialize the PostgreSQL database:
docker compose up -d
-
Build and run the application:
./gradlew build ./gradlew bootRun
-
[Optional] Prune the database:
docker compose down -v
The application setup includes an initial admin user with credentials:
username: [email protected]
password: adminpassword
Base URL:
http://localhost:8080/api/v1
The following endpoints are available post-deployment:
- Sign Up:
/auth/signup
- Sign In:
/auth/signin
- Refresh Token:
/auth/refresh
- Sample Admin Endpoint:
/admin
(requires 'ADMIN' role) - Sample User Endpoint:
/user
(requires 'USER' role)
Use the JWT token returned by the /auth/signin
endpoint to access the
/admin
and /user
endpoints.
Authenticate by providing the JWT obtained from /auth/signin. Refresh tokens can be acquired via /auth/refresh.
Endpoints for authentication services:
-
POST
/auth/signup
: Register a new user.{ "firstName": "<firstName>", "lastName": "<lastName>", "email": "<email>", "password": "<password>" }
-
POST
/auth/signin
: Login and receive an access token.{ "email": "<email>", "password": "<password>" }
Response:
{ "token": "<token>", "refreshToken": "<refreshToken>" }
-
POST
/auth/refresh
: Refresh an access token.{ "token": "<refreshToken>" }
Response:
{ "token": "<token>", "refreshToken": "<refreshToken>" }
Access the OpenAPI documentation at:
http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config`
For unit testing, run the following command:
./gradlew test
For API testing, a Postman collection is provided: Postman Collection
Ensure that the following environment variables are set: Environment
Pre-request scripts are provided to automate the process of obtaining a JWT token and refreshing it.
This project is licensed under the MIT License.