This repository contains a Go microservice using the Gin framework and MongoDB. The microservice provides basic CRUD operations for managing users and includes several controllers for various functionalities.
- Go (version 1.18 or later)
- MongoDB (installed and running)
- Git
- curl or PowerShell's
Invoke-RestMethod
Clone the repository to your local machine:
git clone https://github.com/anassajja/Training_Session_Microservice.git
cd Training_Session_Microservice
Create a .env
file in the root directory with the following content:
MONGODB_URI=mongodb://localhost:27017
Run the following command to install the required Go packages:
go mod tidy
Start the server by running:
go run cmd/main.go
The server should now be running on http://localhost:8080.
Recommended to test API endpoints using Postman tool.
Retrieve a list of users:
curl -X GET http://localhost:8080/users
Or in PowerShell:
Invoke-RestMethod -Method Get -Uri http://localhost:8080/users
Create a new user:
curl -X POST http://localhost:8080/users \
-H "Content-Type: application/json" \
-d '{"name": "John Doe", "email": "john.doe@example.com"}'
Or in PowerShell:
$body = @{
name = "John Doe"
email = "john.doe@example.com"
}
Invoke-RestMethod -Method Post -Uri http://localhost:8080/users -Body ($body | ConvertTo-Json) -ContentType "application/json"
-
Scheduling Sessions:
- Create Session: Add new training sessions with details such as time, location, and capacity.
- Update Session: Modify existing sessions, including changes to time, location, or other details.
- Delete Session: Remove sessions from the schedule.
-
Getting Sessions:
- Retrieve All Sessions: List all scheduled sessions.
- Retrieve Session by ID: Get details of a specific session using its unique identifier.
-
Managing Sessions:
- Update Session: Apply updates to sessions as required.
- Cancel Session: Mark sessions as canceled and handle related notifications.
- Modify Session: Make adjustments to session details as needed.
-
User Enrollment:
- Register User: Add users to the system and manage their registration.
- Participate in Sessions: Handle user participation in sessions, including enrollments and withdrawals.
-
User Invitations:
- Send Invitations: Manage invitations for private or special sessions.
- Manage Invitations: Track and manage the status of invitations sent to users.
-
User Cancellation:
- Cancel Enrollment: Process user requests to cancel their session participation.
- Process Refunds: Handle refunds for canceled sessions as required.
-
Feedback:
- Submit Feedback: Collect and process user feedback for sessions and coaches.
- Review Management: Handle reviews submitted by users.
-
Coach Management:
- Manage Coaches: Handle actions related to coach profiles and their sessions.
-
Coach Role Assignment:
- Assign Roles: Allocate roles and responsibilities to coaches and assistants.
-
Coach Session Creation:
- Create Sessions: Allow coaches to schedule and manage their own sessions.
-
Business Management:
- Manage Sessions: Oversee training sessions from a business perspective.
-
Business Dashboard:
- Manage Tools: Provide tools for businesses to oversee and manage their training sessions.
-
Business Session Creation:
- Create and Manage Sessions: Facilitate the creation and management of sessions from a business account.
- Pitch Reservations:
- Manage Reservations: Handle reservations for pitches, including availability checks and booking confirmations.
-
Session Notifications:
- Send Notifications: Notify users about session updates, cancellations, and reminders.
-
User Notifications:
- Send Notifications: Notify users about invitations, changes, and updates related to their sessions.
-
Session Feedback:
- Collect Feedback: Manage the collection and processing of feedback for sessions.
-
Coach Feedback:
- Handle Coach Feedback: Process feedback related to coaches and their performance.
-
QR Code Generation:
- Generate QR Codes: Create QR codes for verifying session participation.
-
QR Code Validation:
- Validate QR Codes: Ensure the integrity of session participation through QR code validation.
To run the tests for the project, use the following command:
go test ./...
This command will execute all tests in your project. Make sure to create test files following Go’s testing conventions (*_test.go
) to ensure coverage.
- Environment Variables Section: Added instructions for creating a
.env
file. - Test Commands Section: Added instructions for running tests with
go test ./...
.
By including these updates, your README.md
will provide clear instructions for setting up, running, and testing your Go microservice project.