Skip to content

Commit

Permalink
Move protobufs to another repository (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
tahadostifam authored Sep 20, 2024
1 parent b0b3825 commit e8b79c5
Show file tree
Hide file tree
Showing 427 changed files with 123 additions and 678,180 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/buf_linter.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ vendor/
minio_data/*
logs/logs*.json
coverage.out*
protobuf/gen/es/protobuf/node_modules
32 changes: 16 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ Please read these guidelines before submitting a pull request or opening an issu
We strive to maintain clean, readable, and maintainable code in Kavka-Core.
Please follow these guidelines when contributing code to the project:

- Code should follow the [Effective Go](https://golang.org/doc/effective_go.html) guidelines.
- Documentation should follow the [Go Doc Comments](https://go.dev/doc/comment) format.
- Follow the principles of clean code as outlined in Robert C. Martin's "[Clean Code](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882)" book. Here you can find a [summary](https://gist.github.com/wojteklu/73c6914cc446146b8b533c0988cf8d29) of the book.
- Write tests for new code or changes to existing code, and make sure all tests pass before submitting a pull request.
- Error strings and log messages SHOULD NOT be capitalized (unless beginning with proper nouns or acronyms) and
SHOULD NOT end with punctuation. Examples:
* Correct: "unable to connect to server"
* Incorrect: "Unable to connect to server"
* Incorrect: "unable to connect to server."
- Code should follow the [Effective Go](https://golang.org/doc/effective_go.html) guidelines.
- Documentation should follow the [Go Doc Comments](https://go.dev/doc/comment) format.
- Follow the principles of clean code as outlined in Robert C. Martin's "[Clean Code](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882)" book. Here you can find a [summary](https://gist.github.com/wojteklu/73c6914cc446146b8b533c0988cf8d29) of the book.
- Write tests for new code or changes to existing code, and make sure all tests pass before submitting a pull request.
- Error strings and log messages SHOULD NOT be capitalized (unless beginning with proper nouns or acronyms) and
SHOULD NOT end with punctuation. Examples:
- Correct: "unable to connect to server"
- Incorrect: "Unable to connect to server"
- Incorrect: "unable to connect to server."

The following commands are available in the Makefile:

- `make fmt` formats the code according to the Go standards.
- `make linter` runs various checks on the code, including formatting and linting.
- `make test` runs the tests to ensure that all functionality is working as intended.
- `make fmt` formats the code according to the Go standards.
- `make linter` runs various checks on the code.
- `make test` runs a thorough test all over the application including (unit_test, integration_test, ...)

## Commit guidelines

Please follow these guidelines when committing changes to go-TimeTraceDB:

- Each commit should represent a single, atomic change to the codebase.
Avoid making multiple unrelated changes in a single commit.
- Use the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format for commit messages and Pull Request titles.
- Each commit should represent a single, atomic change to the codebase.
Avoid making multiple unrelated changes in a single commit.
- Use the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format for commit messages and Pull Request titles.

List of conventional commit [types](https://github.com/commitizen/conventional-commit-types/blob/master/index.json):

Expand All @@ -55,4 +55,4 @@ Please read it before contributing to the project.

---

Thank you for your contributions to Kavka-Core!
Thank you for your contributions to Kavka-Core!
17 changes: 2 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,17 @@ test:
# Format
fmt:
gofumpt -l -w .
buf format -w

# Linter
linter:
golangci-lint run --build-tags "${BUILD_TAG}" --timeout=20m0s

buf_linter:
buf lint

# Run on development
dev:
# set env
export KAVKA_ENV=development

# run server
go run cmd/server/server.go
go run cmd/server/main.go

# Build for production
build:
# set env
export KAVKA_ENV=production

# build
go build -o ./build/server cmd/server/server.go

gen_protobuf:
buf generate --path ./protobuf
go build -o ./build/server cmd/server/main.go
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
<a href="https://github.com/kavkaco/Kavka-Core/actions/workflows/code_linter.yml">
<img src="https://github.com/kavkaco/Kavka-Core/actions/workflows/code_linter.yml/badge.svg"
</a>
<a href="https://github.com/kavkaco/Kavka-Core/actions/workflows/buf_linter.yml">
<img src="https://github.com/kavkaco/Kavka-Core/actions/workflows/buf_linter.yml/badge.svg"
</a>
</div>
</p>
</div>
Expand All @@ -42,27 +39,26 @@ Kavka is designed with a focus on privacy at its core. Our goal is to provide a

### 🔑 Key Features

- **Open-Source**: Kavka's source code is freely available for anyone to inspect, modify, and contribute to.
- **Open-Source**: Kavka's source code is freely available for anyone to inspect, modify, and contribute to.

- **GoLang and Clean Architecture**: The application leverages the power and efficiency of GoLang, while adhering to the Clean Architecture principles for maintainability and scalability.
- **GoLang and Clean Architecture**: The application leverages the power and efficiency of GoLang, while adhering to the Clean Architecture principles for maintainability and scalability.

- **Strong Encryption**: Kavka utilizes strong encryption algorithms to safeguard message confidentiality and anonymity.
- **Strong Encryption**: Kavka utilizes strong encryption algorithms to safeguard message confidentiality and anonymity.

- **Anonymous Server Deployment**: The application can be deployed on anonymous servers, further enhancing user privacy.
- **Anonymous Server Deployment**: The application can be deployed on anonymous servers, further enhancing user privacy.

## 🪜 Built With

[![My Skills](https://skillicons.dev/icons?i=vscode,golang,docker,nginx,git,github,postman,mongodb,redis,vuejs,nuxtjs,ts,aws)](https://skillicons.dev)

## ⚙️ Setup Server Guide

The server setup guide is explained in detail here.

[docs/setup_server.md](https://github.com/kavkaco/Kavka-Core/blob/main/docs/setup_server.md)

## 💎 Contribution!

Kavka welcomes contributions from developers around the world. We are committed to fostering a collaborative and inclusive community where everyone can contribute to the project's growth and development.

We invite you to explore Kavka, join our community, and contribute to building a secure and private communication platform for everyone.💜


25 changes: 0 additions & 25 deletions buf.gen.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions buf.lock

This file was deleted.

4 changes: 0 additions & 4 deletions buf.yaml

This file was deleted.

58 changes: 17 additions & 41 deletions cmd/server/server.go → cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,19 @@ import (
"net/http"
"net/http/pprof"

"connectrpc.com/connect"
connectcors "connectrpc.com/cors"
"github.com/kavkaco/Kavka-Core/config"
"github.com/kavkaco/Kavka-Core/database"
repository_mongo "github.com/kavkaco/Kavka-Core/database/repo_mongo"
grpc_handlers "github.com/kavkaco/Kavka-Core/delivery/grpc/handlers"
"github.com/kavkaco/Kavka-Core/delivery/grpc/interceptor"
"github.com/kavkaco/Kavka-Core/delivery/grpc"
"github.com/kavkaco/Kavka-Core/infra/stream"
"github.com/kavkaco/Kavka-Core/internal/service/auth"
"github.com/kavkaco/Kavka-Core/internal/service/chat"
"github.com/kavkaco/Kavka-Core/internal/service/message"
"github.com/kavkaco/Kavka-Core/internal/service/search"
"github.com/kavkaco/Kavka-Core/log"
"github.com/kavkaco/Kavka-Core/pkg/email"
"github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/auth/v1/authv1connect"
"github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/chat/v1/chatv1connect"
"github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/events/v1/eventsv1connect"
"github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/message/v1/messagev1connect"

"github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/search/v1/searchv1connect"
"github.com/kavkaco/Kavka-Core/utils/hash"
"github.com/rs/cors"
auth_manager "github.com/tahadostifam/go-auth-manager"
Expand Down Expand Up @@ -70,7 +63,6 @@ func main() {
redisClient := database.GetRedisDBInstance(cfg.Redis)

// [=== Init Auth Manager Service ===]
// Repo: github.com/tahadostifam/go-auth-manager
authManager := auth_manager.NewAuthManager(redisClient, auth_manager.AuthManagerOpts{
PrivateKey: cfg.Auth.SecretKey,
})
Expand Down Expand Up @@ -113,44 +105,28 @@ func main() {

searchService := search.NewSearchService(log.NewSubLogger("search-service"), searchRepo)

// [=== Init Grpc Server ===]
grpcListenAddr := fmt.Sprintf("%s:%d", cfg.HTTP.Host, cfg.HTTP.Port)
gRPCRouter := http.NewServeMux()

authInterceptor := interceptor.NewAuthInterceptor(authService)
interceptors := connect.WithInterceptors(authInterceptor)

authGrpcHandler := grpc_handlers.NewAuthGrpcHandler(authService)
authGrpcRoute, authGrpcRouter := authv1connect.NewAuthServiceHandler(authGrpcHandler)

chatGrpcHandler := grpc_handlers.NewChatGrpcHandler(log.NewSubLogger("chats-handler"), chatService)
chatGrpcRoute, chatGrpcRouter := chatv1connect.NewChatServiceHandler(chatGrpcHandler, interceptors)

eventsGrpcHandler := grpc_handlers.NewEventsGrpcHandler(log.NewSubLogger("events-handler"), streamSubscriber)
eventsGrpcRoute, eventsGrpcRouter := eventsv1connect.NewEventsServiceHandler(eventsGrpcHandler, interceptors)

messageGrpcHandler := grpc_handlers.NewMessageGrpcHandler(log.NewSubLogger("message-handler"), messageService)
messageGrpcRoute, messageGrpcRouter := messagev1connect.NewMessageServiceHandler(messageGrpcHandler, interceptors)

searchGrpcHandler := grpc_handlers.NewSearchGrpcHandler(log.NewSubLogger("message-handler"), searchService)
searchGrpcRoute, searchGrpcRouter := searchv1connect.NewSearchServiceHandler(searchGrpcHandler, interceptors)

gRPCRouter.Handle(authGrpcRoute, authGrpcRouter)
gRPCRouter.Handle(chatGrpcRoute, chatGrpcRouter)
gRPCRouter.Handle(eventsGrpcRoute, eventsGrpcRouter)
gRPCRouter.Handle(messageGrpcRoute, messageGrpcRouter)
gRPCRouter.Handle(searchGrpcRoute, searchGrpcRouter)
// [=== Init HTTP Server ===]
router := http.NewServeMux()

// [=== PPROF Memory Profiling Tool ===]
if config.CurrentEnv == config.Development {
gRPCRouter.HandleFunc("/debug/pprof/*", pprof.Index)
gRPCRouter.HandleFunc("/debug/pprof/trace", pprof.Trace)
router.HandleFunc("/debug/pprof/*", pprof.Index)
router.HandleFunc("/debug/pprof/trace", pprof.Trace)
}

// [=== Init HTTP Server ===]
handler := handleCORS(cfg.HTTP.Cors.AllowOrigins, gRPCRouter)
// [=== Init Grpc Server ===]
grpc.NewGrpcServer(router, &grpc.Services{
AuthService: authService,
ChatService: chatService,
MessageService: messageService,
SearchService: searchService,
StreamSubscriber: streamSubscriber,
})

// [=== Serve HTTP Server ===]
handler := handleCORS(cfg.HTTP.Cors.AllowOrigins, router)
server := &http.Server{
Addr: grpcListenAddr,
Addr: fmt.Sprintf("%s:%d", cfg.HTTP.Host, cfg.HTTP.Port),
Handler: h2c.NewHandler(handler, &http2.Server{}),
ReadTimeout: 0,
WriteTimeout: 0,
Expand Down
54 changes: 54 additions & 0 deletions delivery/grpc/grpc_server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package grpc

import (
"net/http"

"connectrpc.com/connect"
grpc_handlers "github.com/kavkaco/Kavka-Core/delivery/grpc/handlers"
"github.com/kavkaco/Kavka-Core/delivery/grpc/interceptor"
"github.com/kavkaco/Kavka-Core/infra/stream"
"github.com/kavkaco/Kavka-Core/internal/service/auth"
"github.com/kavkaco/Kavka-Core/internal/service/chat"
"github.com/kavkaco/Kavka-Core/internal/service/message"
"github.com/kavkaco/Kavka-Core/internal/service/search"
"github.com/kavkaco/Kavka-Core/log"
"github.com/kavkaco/Kavka-ProtoBuf/gen/go/protobuf/auth/v1/authv1connect"
"github.com/kavkaco/Kavka-ProtoBuf/gen/go/protobuf/chat/v1/chatv1connect"
"github.com/kavkaco/Kavka-ProtoBuf/gen/go/protobuf/events/v1/eventsv1connect"
"github.com/kavkaco/Kavka-ProtoBuf/gen/go/protobuf/message/v1/messagev1connect"
"github.com/kavkaco/Kavka-ProtoBuf/gen/go/protobuf/search/v1/searchv1connect"
)

type Services struct {
AuthService *auth.AuthService
ChatService *chat.ChatService
MessageService *message.MessageService
SearchService *search.SearchService
StreamSubscriber stream.StreamSubscriber
}

func NewGrpcServer(router *http.ServeMux, services *Services) {
authInterceptor := interceptor.NewAuthInterceptor(services.AuthService)
interceptors := connect.WithInterceptors(authInterceptor)

authGrpcHandler := grpc_handlers.NewAuthGrpcHandler(services.AuthService)
authGrpcRoute, authGrpcRouter := authv1connect.NewAuthServiceHandler(authGrpcHandler)

chatGrpcHandler := grpc_handlers.NewChatGrpcHandler(log.NewSubLogger("chats-handler"), services.ChatService)
chatGrpcRoute, chatGrpcRouter := chatv1connect.NewChatServiceHandler(chatGrpcHandler, interceptors)

eventsGrpcHandler := grpc_handlers.NewEventsGrpcHandler(log.NewSubLogger("events-handler"), services.StreamSubscriber)
eventsGrpcRoute, eventsGrpcRouter := eventsv1connect.NewEventsServiceHandler(eventsGrpcHandler, interceptors)

messageGrpcHandler := grpc_handlers.NewMessageGrpcHandler(log.NewSubLogger("message-handler"), services.MessageService)
messageGrpcRoute, messageGrpcRouter := messagev1connect.NewMessageServiceHandler(messageGrpcHandler, interceptors)

searchGrpcHandler := grpc_handlers.NewSearchGrpcHandler(log.NewSubLogger("message-handler"), services.SearchService)
searchGrpcRoute, searchGrpcRouter := searchv1connect.NewSearchServiceHandler(searchGrpcHandler, interceptors)

router.Handle(authGrpcRoute, authGrpcRouter)
router.Handle(chatGrpcRoute, chatGrpcRouter)
router.Handle(eventsGrpcRoute, eventsGrpcRouter)
router.Handle(messageGrpcRoute, messageGrpcRouter)
router.Handle(searchGrpcRoute, searchGrpcRouter)
}
5 changes: 3 additions & 2 deletions delivery/grpc/handlers/auth_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (

"connectrpc.com/connect"
grpc_helpers "github.com/kavkaco/Kavka-Core/delivery/grpc/helpers"
"github.com/kavkaco/Kavka-Core/delivery/grpc/proto_model_transformer"

"github.com/kavkaco/Kavka-Core/internal/service/auth"
authv1 "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/auth/v1"
"github.com/kavkaco/Kavka-Core/protobuf/proto_model_transformer"

authv1 "github.com/kavkaco/Kavka-ProtoBuf/gen/go/protobuf/auth/v1"
"google.golang.org/protobuf/types/known/durationpb"
)

Expand Down
6 changes: 3 additions & 3 deletions delivery/grpc/handlers/chat_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
grpc_helpers "github.com/kavkaco/Kavka-Core/delivery/grpc/helpers"
"github.com/kavkaco/Kavka-Core/delivery/grpc/interceptor"

"github.com/kavkaco/Kavka-Core/delivery/grpc/proto_model_transformer"
"github.com/kavkaco/Kavka-Core/internal/model"
"github.com/kavkaco/Kavka-Core/internal/service/chat"
"github.com/kavkaco/Kavka-Core/log"
chatv1 "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/chat/v1"
"github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/chat/v1/chatv1connect"
"github.com/kavkaco/Kavka-Core/protobuf/proto_model_transformer"
chatv1 "github.com/kavkaco/Kavka-ProtoBuf/gen/go/protobuf/chat/v1"
"github.com/kavkaco/Kavka-ProtoBuf/gen/go/protobuf/chat/v1/chatv1connect"
)

type chatHandler struct {
Expand Down
4 changes: 2 additions & 2 deletions delivery/grpc/handlers/events_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/kavkaco/Kavka-Core/infra/stream"
"github.com/kavkaco/Kavka-Core/internal/model"
"github.com/kavkaco/Kavka-Core/log"
eventsv1 "github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/events/v1"
"github.com/kavkaco/Kavka-Core/protobuf/gen/go/protobuf/events/v1/eventsv1connect"
eventsv1 "github.com/kavkaco/Kavka-ProtoBuf/gen/go/protobuf/events/v1"
"github.com/kavkaco/Kavka-ProtoBuf/gen/go/protobuf/events/v1/eventsv1connect"
)

type eventsHandler struct {
Expand Down
Loading

0 comments on commit e8b79c5

Please sign in to comment.