DynamicStockManager is a comprehensive management system designed for managing dynamic stock data and forms. It supports user authentication and allows for detailed manipulation of forms, fields, and stock data through a RESTful API. This system is particularly tailored for the needs of the Perwatch case study but can be adapted for broader usage.
- User Registration and Authentication
- CRUD operations on forms
- CRUD operations on fields within forms
- CRUD operations on stock data linked to forms
- MongoDB
- Go (at least version 1.15)
- Fiber v2 for the backend framework
-
Clone the repository:
git clone https://github.com/kbc0/DynamicStockManager.git cd DynamicStockManager -
Set up your MongoDB database and ensure it is running.
-
Configure your environment variables (I didn't implement them because of simplicity, but the best practice is of course setting up an env var, for now you can change the URL from main.go):
MONGO_URI: Your MongoDB connection string.PORT: Port number for the server to listen on (default8080).
-
Install Go dependencies:
go mod tidy
-
Start the server:
go run main.go
- Register User
POST /api/v1/register
- Login User
POST /api/v1/login
- Get User Account Info
GET /api/v1/account
- Create Form
POST /api/v1/form/create
- List All Forms
GET /api/v1/form
- Get Specific Form
GET /api/v1/form/:_id
- Update Specific Form
PUT /api/v1/form/:_id
- Delete Specific Form
DELETE /api/v1/form/:_id
- Add Field to Form
POST /api/v1/form/:_id/field
- List All Fields in Form
GET /api/v1/form/:_id/field
- Get Specific Field
GET /api/v1/form/:_id/field/:field_id
- Update Specific Field
PUT /api/v1/form/:_id/field/:field_id
- Delete Specific Field
DELETE /api/v1/form/:_id/field/:field_id
- Add Stock to Form
POST /api/v1/form/:_id/stock
- List All Stocks in Form
GET /api/v1/form/:_id/stock
- Get Specific Stock
GET /api/v1/form/:_id/stock/:stock_id
- Update Specific Stock
PUT /api/v1/form/:_id/stock/:stock_id
- Delete Specific Stock
DELETE /api/v1/form/:_id/stock/:stock_id