Follow the following steps to run this project.
Open your terminal and clone repository:
git clone https://github.com/xx/synergazing_backend.git
cd synergazing_backendCopy the environment example file and configure your settings:
cp .env.example .envEdit the .env file with your database credentials and other configurations:
DB_HOST=127.0.0.1
DB_PORT=5432
DB_USER=your_username
DB_PASSWORD=your_password
DB_NAME=your_database
DB_SSLMODE=disable
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
APP_URL=http://127.0.0.1:3002
# OAuth Configuration
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=http://127.0.0.1:3002/api/auth/google/callback
# Frontend URL for OAuth redirects
FRONTEND_URL=http://localhost:3000go mod tidyFor normal development and production use:
go run main.goFor development when you want to reset the database:
go run main.go freshThe server will start automatically after migration. You can access the API at:
http://127.0.0.1:3002
| Command | Description |
|---|---|
go run main.go |
Run with auto migration (preserves existing data) |
go run main.go fresh |
Run with fresh migration (drops all tables and recreates) |
synergazing_backend/
├── config/ # Database configuration
├── controller/ # Request controllers
├── handler/ # Request handlers
├── helper/ # Utility functions
├── middleware/ # Custom middleware
├── migrations/ # Database migrations
├── model/ # Database models
├── routes/ # API routes
├── service/ # Business logic
├── storage/ # File uploads
├── .env.example # Environment example
├── go.mod # Go modules
├── go.sum # Go dependencies
└── main.go # Application entry point
The project creation process includes intelligent team capacity management:
- Define
total_team- the maximum number of team members for your project - Example: If you set
total_teamto 5, you can have a maximum of 5 people
- Add Members: Directly invite specific users to join your project
- Create Roles: Define open positions for recruitment
- Automatic Calculation: The system tracks:
filled_team: Number of members already addedremaining_team: Available positions for new roles- Total allocation cannot exceed
total_team
Stage 2: total_team = 5
Stage 4:
- Add 2 members directly → filled_team = 2
- Create 2 roles with 1 slot each → role_slots = 2
- Remaining capacity = 5 - 2 - 2 = 1 slot available
The project supports OAuth authentication with Google. After successful authentication, users are redirected to the frontend with tokens in query parameters.
- Login Initiation:
GET /api/auth/google/login
- Redirects user to Google OAuth consent screen
- OAuth Callback:
GET /api/auth/google/callback
- Handles Google OAuth response
- Redirects to frontend with authentication data
Success Redirect:
{FRONTEND_URL}/auth/callback?success=true&token={jwt_token}&user_id={id}&user_name={name}&user_email={email}
Error Redirect:
{FRONTEND_URL}/auth/callback?error={error_type}
| Variable | Description | Example |
|---|---|---|
FRONTEND_URL |
Primary frontend URL for OAuth redirects | http://localhost:3000 |
CLIENT_URL |
Alternative frontend URL (fallback) | http://localhost:3000 |
GOOGLE_CLIENT_ID |
Google OAuth Client ID | Your Google OAuth client ID |
GOOGLE_CLIENT_SECRET |
Google OAuth Client Secret | Your Google OAuth client secret |
GOOGLE_REDIRECT_URI |
Google OAuth callback URL | http://127.0.0.1:3002/api/auth/google/callback |
The system uses the following priority for determining the frontend redirect URL:
FRONTEND_URLenvironment variableCLIENT_URLenvironment variable- Derived from
APP_URL(changes port to 3000) - Default fallback:
http://localhost:3000
GET /api/auth/success- Handles OAuth success data extractionGET /api/auth/error- Handles OAuth error information
### API Endpoints
- `GET /api/projects/:id/capacity` - Get current team capacity information
- Response includes:
```json
{
"total_team": 5,
"filled_team": 2,
"total_role_slots": 2,
"remaining_team": 1,
"members": 2,
"roles": 2
}