Skip to content

Application implements various technologies, Golang, Graphql, Postgres and others

License

Notifications You must be signed in to change notification settings

sandermendes/Project-001

Repository files navigation

Project

Golang-Gorm-Postgres-Gqlgen-Graphql-gRPC is a project showcasing the implementation of a system using various technologies and frameworks.

Technologies Used

  1. DevContainer: Provides a consistent and reproducible development environment.
  2. Gorm: A powerful Go ORM framework for simplifying database interactions and enabling efficient data access.
  3. Postgres: An open-source, scalable, and reliable relational database management system.
  4. Gqlgen: A Go library that simplifies the development of GraphQL servers by automatically generating code based on the GraphQL schema.
  5. GraphQL: A modern query language and runtime for APIs, enabling efficient and flexible data retrieval.
  6. gRPC: A high-performance, language-agnostic framework for building distributed systems with efficient communication.
  7. Protobuf: A language-agnostic data serialization format for structured data communication.

Buy me a coffee

Whether you use this project, have learned something from it, or just like it, please consider supporting it by buying me a coffee, so I can dedicate more time on open-source projects like this :)

Buy Me A Coffee

Project structure

Sander Mendes App Project-001

Architecture Overview

The project consists of the following components:

  1. GraphQL Service: Acts as an entry point for receiving GraphQL requests from clients. It handles incoming requests and forwards them to the appropriate resolver functions for processing.

  2. Account Service: Serves as an intermediary between the GraphQL service and the User service. It handles account-related functionality, such as authentication, authorization, and account management.

  3. User Service: Responsible for managing user-specific operations. It handles user-related business logic, such as user creation, retrieval, updates, and deletion. The User service interacts with the database to perform these operations.

  4. Database: Stores user information and provides persistent storage for the system. The User service interacts with the database to store and retrieve user data.

The data flow starts with a GraphQL request coming into the GraphQL service. The request is then forwarded to the Account service, which handles authentication and authorization. Once authenticated and authorized, the Account service communicates with the User service to perform user-related operations. The User service interacts with the database to store or retrieve user data as needed. The response follows the reverse path, with the User service providing the response to the Account service, which returns the response to the GraphQL service for final delivery to the client.

Login Page

Access Login Page at url: http://localhost:4050/

This login system functions similarly to Google Single Sign-On, allowing for a single sign-in across all applications. It uses a server-generated Cookie Session that respects the domain using the wildcard "*". For example, a cookie generated with "*.example.com" will allow requests from app-test.example.com to share the same login information with the main domain. This provides a seamless, integrated, and consistent login experience across different applications within the same domain.

When accessing the URL, after processing, it will include a parameter called "redirect_uri". Upon successful authentication, the user will be redirected to the URI specified in the "redirect_uri" parameter. If no URI is provided, it will default to the URI that redirects to the default application user settings, e.g.:

http://localhost:4050/signin/v1/identifier?redirect_uri=http%3A%2F%2Flocalhost%3A4000

Login test data:

Email:
janedoe@acme.corp

Password:
123456

Sander Mendes App Project-001


Generating Protobuf Files

To generate Protobuf files, run the following command if there have been changes in the *.proto files:

$ ./generate-protobufs.sh

Note: Run this command inside the devcontainer terminal.

Generating GraphQL Schema Files

To generate/regenerate GraphQL files, run the following command if there have been changes in the schema.graphql file:

$ ./generate-graphql.sh

Note: Run this command inside the devcontainer terminal.

Public GraphQL Server

The main GraphQL server can be accessed at: http://localhost:8080/

Adminer

Adminer, a database management tool, can be accessed at: http://localhost:8088/

Redis Commander

Redis Commander, a Redis management tool, can be accessed at: http://localhost:8081/

To get started, run the following command:

$ docker-compose up -d --build

Note: Run this command in host terminal. This command will start the necessary services and set up the environment inside a Docker container.

GraphQL Service Test ::TODO::

Account Service Test ::TODO::

User Service Test

User Service Test

Feel free to explore the code and make any improvements or modifications to suit your needs!