-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from bounswe/mobile-posts2
Merge mobile posts branch into main mobile branch
- Loading branch information
Showing
82 changed files
with
5,303 additions
and
2,361 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Architecture | ||
|
||
Fanatic consists of three main parts, namely ```./fanatic-backend```, ```./frontend``` and ```./mobile``` that contain the respective codebase for backend, | ||
frontend and mobile modules. | ||
|
||
## Development | ||
|
||
To build and start the app locally, run: | ||
|
||
``` | ||
cd bounswe2024group8/application | ||
docker-compose up --build | ||
``` | ||
|
||
The script above builds and runs the images on the local Docker client to allow developers to develop and test the application simultaneously. If everything goes as intended, the application should be accessible on: | ||
|
||
``` | ||
http://localhost:3000 | ||
``` | ||
|
||
## Deployment | ||
|
||
Google Cloud Run is our choice of platform to deploy containers for this project. We deploy our project with the following steps: | ||
|
||
1. Run a postgres instance in the Cloud App and create a database | ||
|
||
2. To deploy backend, use the URL from 1. and run: | ||
|
||
``` | ||
cd bounswe2024group8/application/fanatic-backend | ||
gcloud run deploy | ||
``` | ||
|
||
3. To deploy frontend, use the URL from 2. and run: | ||
|
||
``` | ||
cd bounswe2024group8/application/frontend | ||
gcloud run deploy | ||
``` | ||
|
||
|
||
If everything goes as intended, the backend should be accessible at: | ||
|
||
``` | ||
https://fanatic-backend-bjbpof6jaq-oa.a.run.app/ | ||
``` | ||
|
||
Frontend should be accessible at: | ||
|
||
``` | ||
https://frontend-bjbpof6jaq-oa.a.run.app/ | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...anatic-backend/src/main/java/com/example/fanaticbackend/controller/CommentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.example.fanaticbackend.controller; | ||
|
||
import com.example.fanaticbackend.model.User; | ||
import com.example.fanaticbackend.payload.CommentResponse; | ||
import com.example.fanaticbackend.service.CommentService; | ||
import com.example.fanaticbackend.service.CommunityService; | ||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.FieldDefaults; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.security.core.userdetails.UserDetails; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/comments") | ||
@RequiredArgsConstructor | ||
@FieldDefaults(level = AccessLevel.PRIVATE) | ||
public class CommentController { | ||
|
||
final CommentService commentService; | ||
|
||
|
||
@GetMapping("/post/{postId}") | ||
public ResponseEntity<List<CommentResponse>> getComments( | ||
@AuthenticationPrincipal UserDetails userDetails, | ||
@PathVariable Long postId) { | ||
|
||
List<CommentResponse> comments = commentService.getCommentsByPostId((User) userDetails, postId); | ||
|
||
if (comments.isEmpty()) { | ||
return ResponseEntity.notFound().build(); | ||
} | ||
|
||
return ResponseEntity.ok(comments); | ||
|
||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...atic-backend/src/main/java/com/example/fanaticbackend/controller/CommunityController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.example.fanaticbackend.controller; | ||
|
||
import com.example.fanaticbackend.model.Community; | ||
import com.example.fanaticbackend.service.CommunityService; | ||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.FieldDefaults; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/communities") | ||
@RequiredArgsConstructor | ||
@FieldDefaults(level = AccessLevel.PRIVATE) | ||
public class CommunityController { | ||
|
||
final CommunityService communityService; | ||
|
||
|
||
@GetMapping("{communityName}") | ||
public ResponseEntity<Community> getCommunityByName( | ||
@PathVariable String communityName | ||
) { | ||
|
||
Community community = communityService.findCommunityByTeamElseThrow(communityName); | ||
|
||
return ResponseEntity.ok(community); | ||
} | ||
|
||
|
||
@PostMapping("") | ||
public ResponseEntity<Boolean> createAll() { | ||
|
||
communityService.createAllCommunities(); | ||
|
||
return ResponseEntity.ok(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.