Hi! This is Elvis and this repository is dedicated to developing a prototype of a messenger service that enables users to sign up, log in, log out, and create servers where other users can join. The messenger service aims to provide a platform for seamless communication and collaboration among users.
All that you need is Golang. Once you run the application, it will expose a target port on the host.
messengerservice-app-1 | [GIN-debug] Listening and serving HTTP on 0.0.0.0:4200
To get started with the project in docker, follow these steps:
-
Clone the repository to your local machine:
git clone https://github.com/Elvis-Benites-N/MessengerServiceGo.git
-
Move to the project directory:
cd MessengerServiceGo
-
Build the Docker containers:
docker-compose build
-
Start the Docker containers:
docker-compose up
This command will start the necessary services defined in the
docker-compose.yml
file. -
Access the application:
Once the Docker containers are up and running, you can access the application in your Postman software at
http://localhost:4200
.
That's it! You have successfully set up the project using Docker. If you encounter any issues or need further instructions, please refer to the project documentation or reach out to the project maintainers for assistance.
Make sure you have Docker and docker-compose
installed on your machine before following these steps.
Note: If you need to customize any configurations or environment variables for your Docker setup, please refer to the docker-compose.yml
file and make the necessary changes before running the docker-compose build
and docker-compose up
commands.
Feel free to modify this guide as needed to match the specific setup and requirements of your project.
I hope this helps you get started with Docker in your project! Let me know if you have any further questions.
-
Clone the repository:
git clone https://github.com/Elvis-Benites-N/MessengerServiceGo.git
-
Navigate to the project directory:
cd MessengerServiceGo
-
Rename the
.env.example
file to.env
:mv .env.example .env
-
Open the
.env
file and update the database configuration variables (DB_HOST
,DB_USER
,DB_PASSWORD
,DB_NAME
,DB_PORT
,DB_SSLMODE
) with your local PostgreSQL database settings.
DB_HOST=database_host
DB_USER=database_user
DB_PASSWORD=database_password
DB_NAME=database_name
DB_PORT=database_port
DB_SSLMODE=disable
-
Install the required dependencies:
go get ./...
-
Run the project:
go run local/main.go
This will start the project and connect to the PostgreSQL database using the provided configuration.
-
Open Postman or any API testing tool and test the APIs using the appropriate endpoints and request methods.
Remember to ensure that you have PostgreSQL 13.11 (or an older version) and Go 1.20 (or an older version) installed on your local machine before running the project.
Note: It's recommended to have a clean and separate development environment for running the project locally, as it may have different dependencies and configuration compared to the production environment.
Send HTTP requests to user:
POST /signup
: create a new userPOST /login
: login with existing credentialsGET /logout
: logout of session
E.g. A basic chat /signup POST request could look as follows:
{
"username" : "elvisbenites",
"email" : "ebnbenites@gmail.com",
"password" : "admin123"
}
If successful, the server will respond with HTTP code 200 and the newly created user:
{
"id": "1",
"username": "elvisbenites",
"email": "ebnbenites@gmail.com"
}
E.g. A basic chat /login POST request could look as follows:
{
"email" : "ebnbenites@gmail.com",
"password" : "admin123"
}
If successful, the server will respond with HTTP code 200 and the user will be able to login:
{
"id": "1",
"username": "elvisbenites"
}
E.g. If succesful a basic chat /logout GET request could look as follows, the server will respond with HTTP code 200 and the user will be able to logout:
{
"message": "Logout successful"
}
Send HTTP requests to /ws
for server API:
POST /createServer
: create a new chat serverGET /joinServer/:serverId
: join to a chat server by its IDGET /getServers
: list all the servers createdGET /getClients/:serverId
: list all the users connected to an server
E.g. A basic chat /createServer POST request could look as follows. if this process is successful, the server will respond with HTTP code 200 and shows the data entered:
{
"id": "1",
"name": "GoDevelopers"
}
E.g. A basic chat /joinServer/:serverId request could look as follows in Postman using WebSocket:
ws://localhost:4200/ws/joinServer/1?userId=2&username=user2
E.g. If succesful a basic chat /getServers GET request could look as follows, the server will respond with HTTP code 200:
[
{
"id": "1",
"name": "GoDeverlopers"
}
]
E.g. If succesful a basic chat /getClients/:serverId GET request could look as follows, the server will respond with HTTP code 200:
[
{
"id": "2",
"username": "user2"
},
{
"id": "1",
"username": "elvisbenites"
}
]
The expected results in conjunction with the application of the Golang language are shown below.