CRM-Service

CRM System for Educational Institutions

A robust and scalable Customer Relationship Management (CRM) system built using Golang. This system is specifically designed for educational institutions to manage courses, teachers, students, groups, and timetables efficiently.


Featuress

Core Features

New Features

Data Models


Tech Stack


Quick Start

Prerequisites

Installation

  1. Clone the repository:
    git clone https://github.com/tamimorif/CRM-Service.git
    cd CRM-Service
    
  2. Set up environment variables:
    cp .env.example .env
    # Edit .env with your configuration
    
  3. Install dependencies:
    make deps
    
  4. Run with Docker (Recommended):
    docker-compose up -d
    

    Or run locally:

    make run
    

The API will be available at http://localhost:8080


API Documentation

See API.md for comprehensive API documentation including:

Quick API Examples

Get all teachers with pagination:

curl -H "X-Auth-Token: your_token" \
  "http://localhost:8080/teachers?page=1&page_size=10&search=john"

Create a new course:

curl -X POST -H "X-Auth-Token: your_token" \
  -H "Content-Type: application/json" \
  -d '{"title":"Web Development","monthly_fee":1000,"duration":6}' \
  http://localhost:8080/courses

Health check:

curl http://localhost:8080/health

Project Structure

.
├── cmd/
│   ├── api/          # Main API application
│   └── console/      # Console utilities
├── pkg/
│   ├── auth/         # gRPC auth client (generated)
│   ├── config/       # Application configuration
│   ├── database/     # Database configuration
│   ├── dto/          # Data Transfer Objects
│   ├── errors/       # Custom error definitions
│   ├── handlers/     # HTTP request handlers
│   ├── helpers/      # HTTP response helpers & utilities
│   ├── logger/       # Logging configuration
│   ├── middlewares/  # Auth & logging middleware
│   ├── models/       # Database models
│   ├── repository/   # Data access layer
│   └── services/     # Business logic layer
├── tests/            # Integration and unit tests
├── .env.example      # Environment variables template
├── docker-compose.yml
├── Dockerfile
├── Makefile          # Build & development commands
├── API.md            # API documentation
└── README.md

Development

Available Make Commands

make help           # Show all available commands
make build          # Build the application
make run            # Run the application
make dev            # Run with hot reload (requires air)
make test           # Run tests
make test-coverage  # Run tests with coverage report
make docker-up      # Start Docker containers
make docker-down    # Stop Docker containers
make docker-logs    # Show Docker logs
make lint           # Run linter
make fmt            # Format code

Running Tests

make test

Code Formatting

make fmt
make lint

Configuration

Environment Variables

Create a .env file based on .env.example:

# Database
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=crm_service
DB_PORT=5432

# Application
APP_PORT=8080

# Auth Service
AUTH_SERVICE_ADDR=localhost:50051

# Development
SKIP_AUTH=false

Deployment

Docker Deployment

The project includes a complete Docker setup:

# Build and start all services
docker-compose up -d

# View logs
docker-compose logs -f crm-service

# Stop services
docker-compose down

Services included:

Production Deployment (going live)

CRM goes live from the main branch. HTTPS and routing are handled by the single shared nginx reverse proxy in Github/proxy/ (one per server, not per project), which terminates TLS with a Cloudflare Origin certificate and serves CRM at crm.tamimarif.com.

Bring CRM up from main:

./run.sh      # checks out main, pulls, ensures the edge-proxy network, and starts the stack

API Features

Pagination

All list endpoints support pagination:

GET /teachers?page=1&page_size=10

Search & Filtering

Search across multiple fields:

GET /teachers?search=john
GET /courses?search=web

Sorting

Sort by any field:

GET /teachers?sort=name&order=asc
GET /courses?sort=created_at&order=desc

Relationship Loading

Related data is automatically loaded for single-item GET requests and can be included in list requests.


Architecture

Microservices Communication

Database Schema


Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch:
    git checkout -b feature/amazing-feature
    
  3. Commit your changes:
    git commit -m "Add amazing feature"
    
  4. Push to the branch:
    git push origin feature/amazing-feature
    
  5. Open a Pull Request

Coding Standards


Monitoring & Health Checks

The application provides three health check endpoints:

These endpoints are publicly accessible (no authentication required).


License

This project is licensed under the MIT License. See the LICENSE file for details.


Contact

Author: Tamim Orif
GitHub: @tamimorif
Project: CRM-Service

For questions, issues, or collaboration opportunities, feel free to open an issue or reach out!


Roadmap