RESTful API for online clothing store, including web-server implementation in GO and PostgreSQL database
To deploy server locally you need to do the following:
- Have Docker Desktop installed and running
- Clone the repository
- Open Powershell and navigate to repository root folder
- Run following command:
docker compose up --build
- You can access API on port 8080
- Database will be already initialized with data from
db/init/products_init.csv
- GO 1.24.0
- PostgreSQL 17
Goal of this project was to write web-server mostly in pure GO. Some of the implemented functionalities:
- Converter from HTTP request to any data model, including HTTP request validator
- Simplified ORM with query builders with
- Prepared Statements for PostgreSQL to prevent SQL Injection
Resource for all clothing products. Search can go by any combination of the resource parameters
Available requests:
- GET: query clothing products with filters (needs minimum User authorization)
- POST: add new clothing product (needs minimum Admin authorization)
Model parameters:
- "name": string
- "category": string
- "size": ["S", "M", "L", "XL", "XXL"]
- "gender": ['Male', 'Female', 'Unisex']
- "is_for_kids": bool
- "price": decimal, in EUR
- "quantity": unsigned int
Resource for authorization that works with JWT
Available request:
- POST: authorization that takes username and password and returns JWT token
Model parameters:
- "username": unique string
- "password": string
- "role": int (0 - user, 1 - admin)
PostMan is recommended for testing this API
You can create your requests with API described above.
You can also import already created Postman Collection for testing this api in testing/online_store_api.postman_collection.json
You can execute all unit tests available by running testing/execute_unit_tests.bat