tools

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 1 Imported by: 0

README

Go Backend Clean Architecture (Financial Tracker)

This is a back-end for a Financial Tracker app, built to learn GraphQL, Clean Architecture and Domain-Driven Design using vanilla Go. Feel free to use this project as a template for your own Go backend projects.

I appreciate any feedback on the project; it helps everyone, especially me.

Technologies

  • Go
  • Postgres
  • Docker
  • gqlgen

About Me

Hi, I’m Beka Birhanu. I’m currently part of the A2SV training program and work with Clean Architecture on a daily basis.

How to Run This Project

You can run this Go Backend Clean Architecture project with or without Docker. Here’s how to do both:

  • Clone the project
# Move to your workspace
cd your-workspace

# Clone this project into your workspace
git clone https://github.com/beka-birhanu/finance-go.git

# Move to the project root directory
cd finance-go
Run Without Docker
  1. Install Go and Postgres if not already installed on your machine.
  2. Edit a .env with your configuration.
  3. Run go mod tidy.
  4. Run make run.
  5. Access the API at http://localhost:8080.
Run With Docker
  1. Install Docker and Docker Compose.
  2. Run docker-compose up -d.
  3. Access the API at http://localhost:8080.
How to Run Tests
# Run all tests
make test

File Structure

file structure

API Documentation

RESTful APIs docs GraphQL APIs docs

TODO
  • Improve based on feedback.
  • Add more test cases.
  • Collect mocks into a dedicated directory.

If this project helps you in any way, show your support ❤️ by starring this project ✌️

License
MIT License

Copyright (c) 2024 Beka Birhanu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Contributing to Finance-Go

All pull requests are welcome.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
error
Package errapi provides a structured way to handle and represent API errors, including common HTTP status codes and corresponding error messages.
Package errapi provides a structured way to handle and represent API errors, including common HTTP status codes and corresponding error messages.
middleware
Package middleware provides HTTP middleware for authorization and context handling.
Package middleware provides HTTP middleware for authorization and context handling.
rest
Package api defines an interface for controllers to register routes with different access levels.
Package api defines an interface for controllers to register routes with different access levels.
rest/base_handler
Package baseapi provides a base handler for HTTP requests, including functionalities for request validation, error handling, and response management.
Package baseapi provides a base handler for HTTP requests, including functionalities for request validation, error handling, and response management.
rest/expense
Package expense provides HTTP handlers for managing user expenses, including adding, retrieving, and updating expense records.
Package expense provides HTTP handlers for managing user expenses, including adding, retrieving, and updating expense records.
rest/user
Package user provides HTTP handlers for user-related actions such as registration and login.
Package user provides HTTP handlers for user-related actions such as registration and login.
router
Package router provides functionality to set up and run the HTTP server, manage routes, and apply middleware based on access levels.
Package router provides functionality to set up and run the HTTP server, manage routes, and apply middleware based on access levels.
application
authentication/command
Package registercmd provides the command handler for user registration.
Package registercmd provides the command handler for user registration.
authentication/query
Package loginqry provides functionality for handling login queries.
Package loginqry provides functionality for handling login queries.
common/cqrs/command
Package command provides a generic interface for handling commands.
Package command provides a generic interface for handling commands.
common/cqrs/query
Package query provides a generic interface for handling queries.
Package query provides a generic interface for handling queries.
common/interface/jwt
Package jwt provides an interface for handling JSON Web Tokens (JWT).
Package jwt provides an interface for handling JSON Web Tokens (JWT).
common/interface/repository
Package irepository provides interfaces for accessing and managing expense data.
Package irepository provides interfaces for accessing and managing expense data.
common/interface/time_service
Package timeservice provides an interface for time-related operations.
Package timeservice provides an interface for time-related operations.
error
Package error provides a way to define and handle application-specific errors.
Package error provides a way to define and handle application-specific errors.
expense/command
Package expensecmd provides functionality for handling commands related to expenses.
Package expensecmd provides functionality for handling commands related to expenses.
expense/query
Package expensqry provides functionality for handling queries related to retrieving expenses.
Package expensqry provides functionality for handling queries related to retrieving expenses.
Package config provides functionality to load and manage application configuration from environment variables.
Package config provides functionality to load and manage application configuration from environment variables.
domain
common/hash
Package hash defines an interface for hashing and matching strings.
Package hash defines an interface for hashing and matching strings.
error/common
Package errdmn provides custom error types for the domain layer.
Package errdmn provides custom error types for the domain layer.
error/expense
Package errexpense defines expense-related errors for the application.
Package errexpense defines expense-related errors for the application.
error/user
Package erruser defines user-related errors for the application.
Package erruser defines user-related errors for the application.
model/expense
Package expensemodel includes the definition of the Expense aggregate, which represents an individual expense, and provides functions for creating and interacting with expenses.
Package expensemodel includes the definition of the Expense aggregate, which represents an individual expense, and provides functions for creating and interacting with expenses.
model/user
Package usermodel defines the `User` aggregate, which represents an individual user, and includes methods for creating and managing users.
Package usermodel defines the `User` aggregate, which represents an individual user, and includes methods for creating and managing users.
infrastructure
db
hash
Package hash provides secure hashing and matching functionalities using PBKDF2 with SHA-256.
Package hash provides secure hashing and matching functionalities using PBKDF2 with SHA-256.
jwt
Package jwt provides JWT generation and validation services.
Package jwt provides JWT generation and validation services.
repository/expense
Package expenserepo provides the implementation of the IExpenseRepository interface for managing expenses in a PostgreSQL database.
Package expenserepo provides the implementation of the IExpenseRepository interface for managing expenses in a PostgreSQL database.
repository/user
Package userrepo provides the implementation for handling user persistence operations in the repository.
Package userrepo provides the implementation for handling user persistence operations in the repository.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL