StocksAPI

module
v0.0.0-...-50f9ecc Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: BSD-3-Clause

README

Stocks Management System

This project is a simple stocks management system using Go and PostgreSQL.

Project Structure

.
├── .github                # GitHub-related configuration files
├── cmd                    # Contains the main application code
│   ├── middleware         # Middlewares and Request handlers for handling requests
│   │   ├── handlers.go  
│   │   └── middleware.go
│   ├── models             # Database models
│   │   └── models.go
│   ├── router             # API routing
│   │   └── router.go
│   └── main.go            # Application entry point
├── .env                   # Environment variables
├── .gitignore             # Gitignore file
├── LICENSE                # License file
├── Makefile               # Makefile for running commands
├── README.md              # Project README
├── go.mod                 # Go modules file
├── go.sum                 # Dependencies checksum
└── script.sql             # SQL script to set up the database

Prerequisites

  • Go (version 1.16 or higher)
  • PostgreSQL
  • Environment variables specified in the .env file

Installation and Setup

  1. Clone the repository:
git clone https://github.com/Nisarg2061/StocksAPI.git && cd StocksAPI
  1. Set up the database: Make sure PostgreSQL is running locally. You can use the script.sql file to set up the database:
psql -h localhost -U postgres -d stocksdb -a -f script.sql

This will create the required tables and populate initial data into the stocksdb database.

  1. Set up environment variables Create a .env file in the root directory and set the required variables:
POSTGRES_URL=your_postgres_connection_url

Make sure to replace your_postgres_connection_url with your actual PostgreSQL connection string (e.g., postgres://username:password@localhost:5432/stocksdb).

  1. Run the application You can use the Makefile to build and run the project. To start the server, run:
make run

The application should now be running on the configured port.

Usage

  • The API routes are defined in router/router.go.
  • Handlers for various routes are in handlers.go.
  • Middleware logic is found in middleware/middleware.go.
  • Database models are in models/models.go.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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