Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dieg0code/portfolio_01_player_profile
Monolithic API built with Golang, implements DevSecOps and best practices (like TDD), diagrams, static code analysis, vulnerability analysis and more.
https://github.com/dieg0code/portfolio_01_player_profile
aws cicd devsecops docker golang mermaid-diagrams snyk sonarqube tdd terraform
Last synced: 6 days ago
JSON representation
Monolithic API built with Golang, implements DevSecOps and best practices (like TDD), diagrams, static code analysis, vulnerability analysis and more.
- Host: GitHub
- URL: https://github.com/dieg0code/portfolio_01_player_profile
- Owner: Dieg0Code
- Created: 2024-07-17T00:41:24.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-08-07T05:41:30.000Z (3 months ago)
- Last Synced: 2024-08-08T00:11:28.535Z (3 months ago)
- Topics: aws, cicd, devsecops, docker, golang, mermaid-diagrams, snyk, sonarqube, tdd, terraform
- Language: Go
- Homepage:
- Size: 312 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Project 01 - Player Profile
## Description
The project consists of a REST API that exposes a database managing 3 entities:
- User
- PlayerProfile
- AchievementA User can have multiple PlayerProfiles, and a PlayerProfile can have multiple Achievements.
The relationship would be as follows:
```mermaid
---
title: DB Players
---erDiagram
USER {
int user_id PK
string username
string password
string email
int age
}PLAYERPROFILE {
int player_profile_id PK
string nickname
string avatar
int level
int experience
int points
int user_id FK
}ACHIEVEMENT {
int achievement_id PK
string name
string description
int player_profile_id FK
}USER ||--o{ PLAYERPROFILE : owns
PLAYERPROFILE ||--o{ ACHIEVEMENT : unlocks
```## Technologies
- Golang 1.22.1
- Gin Gonic
- Gorm
- PostgreSQL
- Docker
- Docker Compose
- Makefile
- GitHub Actions
- Terraform
- AWS
- Swagger
- SonarCloud
- SynkThe application consists of an API with respective endpoints for each entity. PostgreSQL is used as the database, and Docker Compose is used to set up both the database and the application. Deployment is handled via a GitHub Actions pipeline to an AWS environment using Terraform.
## Class Diagram
```mermaid
classDiagram
class User {
+int ID
+string Username
+string Password
+string Email
+int Age
+[]PlayerProfile Profiles
+CreateUser() error
+GetUser(id int) (User, error)
+UpdateUser() error
+DeleteUser() error
}class PlayerProfile {
+int ID
+string Nickname
+string Avatar
+int Level
+int Experience
+int Points
+int UserID
+User User
+[]Achievement Achievements
+CreateProfile() error
+GetProfile(id int) (PlayerProfile, error)
+UpdateProfile() error
+DeleteProfile() error
}class Achievement {
+int ID
+string Name
+string Description
+int PlayerProfileID
+PlayerProfile PlayerProfile
+CreateAchievement() error
+GetAchievement(id int) (Achievement, error)
+UpdateAchievement() error
+DeleteAchievement() error
}User "1" --o "*" PlayerProfile : has
PlayerProfile "1" --o "*" Achievement : unlocks
```## Endpoints
### User
- **GET /users**: Returns all users.
- **GET /users/{id}**: Returns a user by their id.
- **POST /users**: Creates a user.
- **PUT /users/{id}**: Updates a user by their id.### PlayerProfile
- **GET /player-profiles**: Returns all player profiles.
- **GET /player-profiles/{id}**: Returns a player profile by its id.
- **POST /player-profiles**: Creates a player profile.
- **PUT /player-profiles/{id}**: Updates a player profile by its id.### Achievement
- **GET /achievements**: Returns all achievements.
- **GET /achievements/{id}**: Returns an achievement by its id.
- **POST /achievements**: Creates an achievement.
- **PUT /achievements/{id}**: Updates an achievement by its id.```mermaid
sequenceDiagram
actor Client
participant Auth
participant User
participant PlayerProfile
participant AchievementClient->>Auth: POST /auth/login
Auth-->>Client: JWT TokenClient->>User: GET /api/v1/users
User-->>Client: Paginated list of usersClient->>User: POST /api/v1/users
User-->>Client: User createdClient->>PlayerProfile: GET /api/v1/player-profiles
PlayerProfile-->>Client: Paginated list of player profilesClient->>PlayerProfile: POST /api/v1/player-profiles
PlayerProfile-->>Client: Player profile createdClient->>Achievement: GET /api/v1/achievements
Achievement-->>Client: Paginated list of achievementsClient->>Achievement: POST /api/v1/achievements
Achievement-->>Client: Achievement createdClient->>Auth: POST /auth/logout
Auth-->>Client: Session closed
```## AWS Infrastructure
- **VPC**: For the internal virtual private network configuration of the application.
- **EC2**: For the creation of the virtual instance hosting the application.
- **RDS**: For the creation of the PostgreSQL database.
- **Security Groups**: For configuring the application’s inbound and outbound ports.
- **IAM**: For creating the necessary roles and permissions for the application.
- **S3**: For storing Terraform configuration files.## Architecture Diagram
```mermaid
graph TB
subgraph "GitHub"
A[Code Repository]
B[GitHub Actions]
endsubgraph "AWS Cloud"
subgraph "VPC"
C[EC2 Instance]
D[RDS PostgreSQL]
E[Security Groups]
end
F[IAM Roles]
G[S3 Bucket]
endsubgraph "Developer Environment"
H[Docker Compose]
I[Local PostgreSQL]
J[API Application]
endA -->|Trigger| B
B -->|Deploy| C
B -->|Configure| F
B -->|Store State| G
C -->|Connect| D
C -->|Uses| E
C -->|Access| F
H -->|Local Development| I
H -->|Local Development| J
J -->|Deployed to| C
```