A Go-based REST API server for a CRM/lead management system that helps users organize and manage their contacts, leads, and business relationships.
- User Management: Authentication via Google OAuth with JWT tokens
 - Contact Management: Create, update, and organize contacts (cards) with detailed information
 - List Organization: Organize contacts into customizable lists (like sales pipelines)
 - Tagging System: Categorize contacts with colored tags
 - Activity Tracking: Log and track interactions with contacts
 - Custom Fields: Add custom contact and company information
 - API Key Management: Generate API keys for external integrations
 - Bulk Operations: Import multiple contacts via API
 
- Backend: Go with Gin web framework
 - Database: PostgreSQL with GORM ORM
 - Authentication: JWT tokens + Google OAuth 2.0
 - Logging: Uber Zap logger with Axiom integration
 - Deployment: Docker & Docker Compose
 
- Go 1.24.6 or higher
 - PostgreSQL 17+
 - Docker & Docker Compose (optional)
 
- Clone the repository:
 
git clone https://github.com/Cognize-AI/server-cognize.git
cd server-cognize- Create a 
.envfile in the root directory: 
PORT=4000
DB_STRING=postgres://root:root@localhost:5432/cognize?sslmode=disable
JWT_SECRET=your-jwt-secret-key
GOOGLE_OAUTH_CLIENT_ID=your-google-oauth-client-id
GOOGLE_OAUTH_CLIENT_SECRET=your-google-oauth-client-secret
GOOGLE_OAUTH_REDIRECT_URL=http://localhost:3000/auth/callback
ENVIRONMENT=dev
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=your-email@gmail.com
SMTP_PASSWORD=your-app-password
AXIOM_TOKEN=your-axiom-token
AXIOM_ORG=your-axiom-org
AXIOM_DATASET=cognize-logs
ENC_SECRET=your-encryption-secret- Start the services:
 
docker-compose up -dThis will start:
- PostgreSQL database on port 5432
 - Cognize API server on port 8080
 
- Start PostgreSQL database:
 
docker run --name cognize-postgres -e POSTGRES_USER=root -e POSTGRES_PASSWORD=root -e POSTGRES_DB=cognize -p 5432:5432 -d postgres:17- Install dependencies and run:
 
go mod tidy
go run main.goThe server will start on http://localhost:4000
The API uses JWT tokens for authentication. Most endpoints require the Authorization header:
Authorization: Bearer <your-jwt-token>
For API integrations, use the Cognize-API-Key header:
Cognize-API-Key: <your-api-key>
http://localhost:4000
GET /user/me- Get current user profile
GET /oauth/google/redirect-uri- Get Google OAuth redirect URLGET /oauth/google/callback- Handle Google OAuth callback
GET /list/create-default- Create default lists for new usersGET /list/all- Get all lists for authenticated user
POST /card/create- Create a new contactGET /card/:id- Get contact details by IDPUT /card/:id- Update basic contact informationPUT /card/details/:id- Update detailed contact informationDELETE /card/:id- Delete a contactPOST /card/move- Move contact between lists
POST /tag/create- Create a new tagGET /tag/- Get all tagsPOST /tag/add-to-card- Add tag to a contactPOST /tag/remove-from-card- Remove tag from a contactPUT /tag/- Update tagDELETE /tag/:id- Delete tag
POST /activity/create- Create activity for a contactPUT /activity/:id- Update activityDELETE /activity/:id- Delete activity
GET /key/api- Generate API key for external integrations
POST /api/bulk-prospect- Bulk import contacts (requires API key)
POST /field/field-definitions- Create custom field definitionsPOST /field/field-value- Add custom field values
curl -X POST http://localhost:4000/card/create \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "designation": "Software Engineer",
    "email": "john@example.com",
    "phone": "+1234567890",
    "list_id": 1
  }'curl -X GET http://localhost:4000/card/123 \
  -H "Authorization: Bearer <token>"curl -X POST http://localhost:4000/api/bulk-prospect \
  -H "Cognize-API-Key: <api-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "list_id": 1,
    "prospects": [
      {
        "name": "Jane Smith",
        "designation": "Product Manager",
        "email": "jane@example.com",
        "phone": "+1987654321"
      }
    ]
  }'id(uint) - Primary keyname(string) - User's full nameemail(string) - Email address (unique)password(string) - Hashed password (for future use)profile_picture(string) - Profile picture URL
id(uint) - Primary keyname(string) - List name (e.g., "New Leads", "Qualified")color(string) - Hex color code for UIuser_id(uint) - Foreign key to Userlist_order(decimal) - Display order
id(uint) - Primary keyname(string) - Contact namedesignation(string) - Job titleemail(string) - Email addressphone(string) - Phone numberimage_url(string) - Profile picture URLlocation(string) - Personal locationlist_id(uint) - Foreign key to Listcard_order(decimal) - Position within listcompany_name(string) - Company namecompany_role(string) - Role at companycompany_location(string) - Company locationcompany_phone(string) - Company phonecompany_email(string) - Company email
id(uint) - Primary keyname(string) - Tag namecolor(string) - Hex color codeuser_id(uint) - Foreign key to User
id(uint) - Primary keycontent(string) - Activity descriptioncard_id(uint) - Foreign key to Card
├── main.go                 # Application entry point
├── config/                 # Configuration management
│   ├── config.go          # Environment configuration
│   ├── dbConfig.go        # Database configuration
│   └── oauthConfig.go     # OAuth configuration
├── internal/              # Internal packages
│   ├── activity/          # Activity management
│   ├── card/              # Contact management
│   ├── field/             # Custom fields
│   ├── keys/              # API key management
│   ├── list/              # List management
│   ├── oauth/             # OAuth handlers
│   ├── tag/               # Tag management
│   └── user/              # User management
├── middleware/            # HTTP middleware
├── models/                # Database models
├── router/                # Route definitions
├── logger/                # Logging configuration
└── util/                  # Utility functions
# Build for current platform
go build -o cognize .
# Build for Linux (production)
CGO_ENABLED=0 GOOS=linux go build -o cognize .go test ./...This project follows standard Go conventions. Use gofmt and go vet for code formatting and static analysis.
- Build and deploy with Docker Compose:
 
docker-compose up -d- Build the binary:
 
CGO_ENABLED=0 GOOS=linux go build -o cognize .- 
Set up PostgreSQL database
 - 
Configure environment variables
 - 
Run the binary:
 
./cognize| Variable | Description | Required | 
|---|---|---|
PORT | 
Server port | Yes | 
DB_STRING | 
PostgreSQL connection string | Yes | 
JWT_SECRET | 
JWT signing secret | Yes | 
GOOGLE_OAUTH_CLIENT_ID | 
Google OAuth client ID | Yes | 
GOOGLE_OAUTH_CLIENT_SECRET | 
Google OAuth client secret | Yes | 
GOOGLE_OAUTH_REDIRECT_URL | 
OAuth callback URL | Yes | 
ENVIRONMENT | 
Environment (dev/prod) | Yes | 
SMTP_HOST | 
SMTP server host | No | 
SMTP_PORT | 
SMTP server port | No | 
SMTP_USERNAME | 
SMTP username | No | 
SMTP_PASSWORD | 
SMTP password | No | 
AXIOM_TOKEN | 
Axiom logging token | No | 
AXIOM_ORG | 
Axiom organization | No | 
AXIOM_DATASET | 
Axiom dataset name | No | 
ENC_SECRET | 
Encryption secret | No | 
- Fork the repository
 - Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
 
This project is proprietary software owned by Cognize-AI.
For support, please contact the development team or create an issue in the repository.