Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justine-george/book-fellow-backend-spring
A social media platform designed for book enthusiasts, it allows users to write detailed reviews and track the reading activities of others in the community.
https://github.com/justine-george/book-fellow-backend-spring
bookclub bookfellow java liquibase social-network spring-boot springsecurity-jwt
Last synced: 24 days ago
JSON representation
A social media platform designed for book enthusiasts, it allows users to write detailed reviews and track the reading activities of others in the community.
- Host: GitHub
- URL: https://github.com/justine-george/book-fellow-backend-spring
- Owner: justine-george
- License: mit
- Created: 2023-12-28T20:57:07.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-07T23:05:02.000Z (5 months ago)
- Last Synced: 2024-11-08T17:14:55.609Z (3 months ago)
- Topics: bookclub, bookfellow, java, liquibase, social-network, spring-boot, springsecurity-jwt
- Language: Java
- Homepage: https://book-fellow-frontend-react.pages.dev/
- Size: 6.69 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Book Fellow App
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## Built With
- [Spring Boot 3](https://spring.io/projects/spring-boot)
- [Java 17](https://www.oracle.com/java/technologies/downloads/#java17)
- [Gradle](https://gradle.org/)
- [PostgreSQL 15](https://www.postgresql.org/)
- [Docker](https://www.docker.com/)
- [JWT](https://jwt.io/)
- [Lombok](https://projectlombok.org/)
- [Liquibase](https://www.liquibase.org/)## Development
Create an `.env` file in the root directory of the project and add the following environment variables:
```shell
SPRING_PROFILES_ACTIVE=dev
POSTGRES_DB=
POSTGRES_USER=
POSTGRES_PASSWORD=
DEV_SERVER_PORT=8080
DEV_DATASOURCE_URL=jdbc:postgresql://localhost:5432/
DEV_DATASOURCE_USERNAME=
DEV_DATASOURCE_PASSWORD=
JWT_SECRET=
```## Getting Started Locally
1. Initialize the PostgreSQL database:
```shell
docker compose up -d
```2. Build and run the application:
```shell
./gradlew build
./gradlew bootRun
```
3. [Optional] Prune the database:
```shell
docker compose down -v
```The application setup includes an initial admin user with credentials:
```text
username: [email protected]
password: adminpassword
```## API Quickstart
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.
## Detailed Authentication Workflow
Endpoints for authentication services:
- POST `/auth/signup`: Register a new user.
```json
{
"firstName": "",
"lastName": "",
"email": "",
"password": ""
}
```
- POST `/auth/signin`: Login and receive an access token.
```json
{
"email": "",
"password": ""
}
```
Response:
```json
{
"token": "",
"refreshToken": ""
}
```- POST `/auth/refresh`: Refresh an access token.
```json
{
"token": ""
}
```Response:
```json
{
"token": "",
"refreshToken": ""
}
```## API Reference
Access the OpenAPI documentation at:
```
http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config`
```## Testing
For unit testing, run the following command:
```shell
./gradlew test
```For API testing, a Postman collection is provided:
[Postman Collection](https://justinegeorge96.postman.co/workspace/abcd)Ensure that the following environment variables are set:
[Environment](https://justinegeorge96.postman.co/workspace/abcd)Pre-request scripts are provided to automate the process of obtaining a JWT token and refreshing it.
## License
This project is licensed under the [MIT License](LICENSE).