Skip to content

Repository files navigation

TodoGRPC Project

A gRPC-based TODO application written in Go with SQLite database backend.

Project Structure

todoGRPC/
├── bin/                    # Compiled binaries
├── internal/
│   ├── client/handles/     # Client-side handlers
│   ├── config/             # Configuration management
│   ├── database/           # Database layer (SQLite)
│   ├── models/             # Data models
│   ├── server/             # Server implementation
│   │   └── handles/        # Server-side gRPC handlers
│   ├── services/           # Business logic layer
│   └── tools/              # Development tools
├── todoproto/
│   ├── client/             # gRPC client
│   ├── proto/              # Protocol buffer definitions
│   └── server/             # gRPC server
├── pkg/datecalc/           # Date calculation utilities
├── googleapis/             # Google API proto files
└── Makefile                # Build automation

Prerequisites

  • Go 1.22.1 or higher
  • Protocol Buffers compiler (protoc)
  • protoc-gen-go
  • protoc-gen-go-grpc

Install protoc plugins:

go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

Building the Project

Using Makefile

Build the entire project:

make all

Build specific components:

make todoproto  # Build todoproto server
make nextdate   # Build nextdate service

Manual Build

Generate protobuf files:

protoc -Itodoproto/proto --go_opt=module=github.com/Vova4o/todogrpc --go_out=. --go-grpc_opt=module=github.com/Vova4o/todogrpc --go-grpc_out=. todoproto/proto/*.proto

Build server:

go build -o bin/todoproto/server ./todoproto/server

Build client:

go build -o bin/todoproto/client ./todoproto/client

Running the Application

Start the gRPC Server

./bin/todoproto/server

Optional flags:

  • -a, --ServerAddress - gRPC server address (default: :50051)
  • -d, --DBPath - Path to SQLite database (default: scheduler.db)
  • -s, --Password - Application password

Example:

./bin/todoproto/server -a :50051 -d ./data/tasks.db

Run the Client

./bin/todoproto/client

gRPC Services

The application provides the following gRPC services:

TodoProtoService

  1. NextDate - Calculate the next date for recurring tasks

    • Request: NextDateRequest{now, date, repeat}
    • Response: NextDateResponse{date}
  2. AddTask - Add a new task

    • Request: AddTaskRequest{title, comment, date, repeat}
    • Response: AddTaskResponse{id}
  3. AllTasks - Stream all tasks (server streaming)

    • Request: TaskRequest{search}
    • Response: Stream of AllTasksResponse

Database Schema

SQLite table: scheduler

  • id - INTEGER PRIMARY KEY AUTOINCREMENT
  • date - TEXT NOT NULL
  • title - TEXT NOT NULL
  • comment - TEXT
  • repeat - TEXT(128)

Index on date field for optimized queries.

Configuration

Configuration is managed via:

  1. Command-line flags
  2. Environment variables
  3. Config files (via Viper)

Priority: Flags > Environment Variables > Config File

Development

Running Tests

go test ./...

Code Structure

  • internal/database: Database operations and storage layer
  • internal/services: Business logic (AddTask, AllTasks, etc.)
  • internal/server/handles: gRPC service implementations
  • internal/models: Data structures and DTOs

Adding New Services

  1. Define service in .proto file
  2. Run make todoproto to generate Go code
  3. Implement service handler in internal/server/handles/
  4. Add business logic in internal/services/
  5. Add database methods in internal/database/ if needed

License

[Add your license here]

Contributing

[Add contribution guidelines here]

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages