This is a Go project that uses gRPC-gateway and SQLite. It uses Viper for managing application configurations which are stored in an app.env
file. The development database is dev.db
.
- Go
- SQLite
- gRPC
- gRPC-Gateway
- Viper
- Buf
- sqlc
- VSCode REST Client
The database documents are available at dbdocs.io.
Password
'zs&U+sI"qtC>R]&y.4B:Y&QhP3]fx08i{5])z$k7so,(sy(4$/L8_Dg[37Z>tP
A Makefile is provided to help with common tasks. Here are the commands you can run:
make create_migration
: Create database migration e.g make create_migration name=initial_schemamake db_schema
: Build SQL from dbmlmake migratedown
: Run migrations downmake migrateup
: Run migrations upmake mock
: Generate mocksmake prod
: Run project with docker composemake proto
: Build proto filesmake server
: Run dev servermake sqlc
: Build sqlc database filesmake test
: Run testsmake test_coverage
: Run test with gocov coverage
sqlc is used to create database migrations. To create a new migration, use the command make create_migration name=<MIGRATION NAME>
. Replace <MIGRATION NAME>
with the name of your migration.
We use Buf for managing our Protocol Buffers. You can use the command make proto
to lint, format, and generate protobuf stubs and Swagger documentation via protoc-gen-openapiv2
.
We also use protovalidate
for generating validations for our protobuf models.
We use the REST Client extension for VS Code for executing HTTP requests. You can find our test HTTP requests in the requests.http file.
- Clone the repository
- Run
make server
to start the server or with docker usemake prod
- View the API docs and test it at http://localhost:8555/swagger/index.html
- Alternatively open the requests.http in VSCode with the VSCode REST Client extension enabled and siimply test the end-points.
For more information, refer to the Makefile.
src
├── api # gRPC-Gateway API implementations
├── db # Contains all database migrations, mocks and query files
├── doc # Contains swagger documentation & database dbml docs
├── pb # Contains all generated proto stubs
├── proto # Contains proto definitions and their buf configurations
├── tools # Contains go module inclusions that are not directly accessed e.g statik
├── util # contains helper methods for configuration etc
├── app.env # .env for general API configuration
├── buf.gen.yaml # buf plugin configurations
├── buf.work.yaml # buf directory and version configurations
├── dev.db # SQLite database with dummy data
├── main.go # app central execution point
├── Makefile # helper commands
├── sqlc.yaml # sqlc database manager configurations
└── requests.http # test http requests