Skip to content

This is a JSON API server written in Go that provides endpoints for managing users, customers, products, sales, and expenses.

Notifications You must be signed in to change notification settings

AndresCampuzano/golang-dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

golang-pet

GOLANG-DASHBOARD

license last-commit repo-top-language repo-language-count

Go



📍 Overview

This is a JSON API server written in Go that provides endpoints for managing users, customers, products, sales, and expenses.


📦 Features

  • User authentication and authorization
  • CRUD operations for users, customers, products, sales, and expenses
  • Integration with AWS S3 for file storage

Additional Information

Database Storage

The server uses PostgreSQL as its database backend. It provides a NewPostgresStore function to create a new instance of PostgresStore, which establishes a connection to the PostgreSQL database and initializes necessary extensions.

AWS S3 Integration

The server integrates with AWS S3 for file storage. The BucketBasics struct encapsulates Amazon S3 actions such as uploading and deleting files. It provides methods for uploading base64-encoded images to an S3 bucket and deleting files from the bucket.

Helper Functions

The server includes helper functions for handling JSON responses, HTTP request routing, and working with PostgreSQL array types.


📂 Repository Structure

└── golang-dashboard/
    ├── Makefile
    ├── api.go
    ├── auth.go
    ├── customer.service.go
    ├── customer.storage.go
    ├── customer.types.go
    ├── database.go
    ├── expense.service.go
    ├── expense.storage.go
    ├── expense.types.go
    ├── earnings.service.go
    ├── earnings.storage.go
    ├── earnings.types.go
    ├── go.mod
    ├── go.sum
    ├── main.go
    ├── product.service.go
    ├── product.storage.go
    ├── product.types.go
    ├── s3.go
    ├── sale.service.go
    ├── sale.storage.go
    ├── sale.types.go
    ├── storage.go
    ├── user.service.go
    ├── user.storage.go
    ├── user.types.go
    └── utils.go

🛣️ Endpoints

The server exposes the following endpoints:

  • POST /login: User login
  • POST /signup: User sign up

Protected routes with JWT

  • GET /users: Get all users
  • GET /users/{id}: Get user by ID
  • GET /customers: Get all customers
  • GET /customers/{id}: Get customer by ID
  • POST /customers: Create a new customer
  • PUT /customers/{id}: Update customer by ID
  • DELETE /customers/{id}: Delete customer by ID
  • GET /products: Get all products
  • GET /products/{id}: Get product by ID
  • POST /products: Create a new product
  • PUT /products/{id}: Update product by ID
  • DELETE /products/{id}: Delete product by ID
  • GET /sales: Get all sales
  • GET /sales/{id}: Get sale by ID
  • POST /sales: Create a new sale
  • GET /expenses: Get all expenses
  • GET /expenses/{id}: Get expense by ID
  • POST /expenses: Create a new expense
  • PUT /expenses/{id}: Update expense by ID
  • DELETE /expenses/{id}: Delete expense by ID
  • GET /earnings: Get earnings by month calculated from multiple postgres tables

🧩 Dependencies

This project depends on the following external packages:


🚀 Getting Started

Requirements

You may need to configure environment variables or configuration files for database connection, AWS credentials, and other settings.

Ensure you have the following dependencies installed on your system:

  • Go: version go1.22.2

⚙️ Installation

  1. Clone the golang-dashboard repository:
git clone https://github.com/AndresCampuzano/golang-dashboard
  1. Change to the project directory:
cd golang-dashboard
  1. Install the dependencies:
go mod download

🤖 Running golang-dashboard

Use the following command to run golang-dashboard:

make run

⚙️ Configuration

This project requires the following environment variables to be set for proper operation:

PostgreSQL

  • POSTGRES_USER: PostgreSQL username
  • POSTGRES_DB_NAME: PostgreSQL database name
  • POSTGRES_PASSWORD: PostgreSQL password

AWS

  • AWS_ACCESS_KEY_ID: AWS access key ID for accessing AWS services
  • AWS_SECRET_ACCESS_KEY: AWS secret access key for accessing AWS services
  • AWS_REGION: AWS region where resources are located
  • AWS_S3_BUCKET_NAME: Name of the AWS S3 bucket for file storage
  • AWS_S3_BUCKET_URL: URL of the AWS S3 bucket for accessing stored files

Amazon RDS

  • AMAZON_RDS_USER: Username for Amazon RDS database
  • AMAZON_RDS_DB_NAME: Name of the Amazon RDS database
  • AMAZON_RDS_PASSWORD: Password for Amazon RDS database
  • AMAZON_RDS_ENDPOINT: Endpoint for connecting to Amazon RDS database

JWT

  • JWT_SECRET: Secret key for JWT token generation

SendGrid Emails

  • SENDGRID_API_KEY: SendGrid API Key
  • SENDGRID_CUSTOM_SENDER: Custom email sender

🧪 Tests

Embrace the chaos, this is a work in progress!

About

This is a JSON API server written in Go that provides endpoints for managing users, customers, products, sales, and expenses.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published