Skip to content

Engineered a high-performance FastAPI backend for a support CRM, streamlining ticket management and automation with a secure, scalable RESTful API

Notifications You must be signed in to change notification settings

wisdom-dosoo/support-crm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Support CRM Backend

Python FastAPI SQLAlchemy License

A comprehensive backend system built with Python and FastAPI that provides secure RESTful APIs for managing customer support interactions. This CRM backend enables efficient customer relationship management with features for authentication, ticket tracking, communication logging, and analytics.

πŸ“‹ Table of Contents

✨ Features

πŸ” Authentication & Authorization

  • JWT-based authentication system
  • Role-based access control (Agent, Admin)
  • Secure password hashing with bcrypt
  • Token-based API access

πŸ‘₯ Customer Management

  • Complete CRUD operations for customer profiles
  • Customer search and filtering capabilities
  • Customer data validation and integrity

🎫 Support Ticket System

  • Create and manage support tickets
  • Priority levels (Low, Medium, High, Urgent)
  • Status tracking (Open, In-Progress, Resolved, Closed)
  • Agent assignment functionality

πŸ“ Communication Logs

  • Track all customer interactions
  • Support for multiple communication types (Call, Email, Chat)
  • Timestamped log entries
  • Ticket association for context

πŸ“Š Analytics & Reporting

  • Ticket status summaries
  • Agent workload distribution
  • Response time analytics
  • Dashboard-ready JSON responses

πŸ›  Technology Stack

  • Framework: FastAPI - Modern, fast web framework for building APIs
  • Database: SQLAlchemy - SQL toolkit and ORM
  • Authentication: PyJWT - JSON Web Token implementation
  • Password Hashing: Passlib - Secure password hashing
  • Validation: Pydantic - Data validation and serialization
  • Documentation: Swagger UI - Interactive API documentation

πŸ“‹ Prerequisites

  • Python 3.8 or higher
  • pip package manager
  • SQLite (included with Python) or PostgreSQL/MySQL for production

πŸš€ Installation

1. Clone the Repository

git clone https://github.com/BROOKS69/support-crm-backend.git
cd support-crm-backend

2. Create Virtual Environment

# Create virtual environment
python -m venv .venv

# Activate virtual environment
# On Windows:
.venv\Scripts\activate
# On macOS/Linux:
source .venv/bin/activate

3. Install Dependencies

pip install -r app/requirements.txt

4. Initialize Database

python migrate_db.py

This will create the necessary database tables and set up the initial schema.

🎯 Usage

Development Server

Start the development server with auto-reload:

uvicorn app.main:app --reload

The server will start at http://localhost:8000

Production Deployment

For production deployment, use a production ASGI server:

# Using Gunicorn with Uvicorn workers
gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000

πŸ“š API Documentation

Once the server is running, access the comprehensive API documentation:

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc
  • OpenAPI Schema: http://localhost:8000/openapi.json

Key Endpoints

Endpoint Method Description
/auth/login POST User authentication
/auth/register POST User registration
/customers GET/POST Customer management
/tickets GET/POST Ticket operations
/logs GET/POST Communication logs
/reports/tickets-summary GET Analytics data

πŸ— Project Structure

support-crm-backend/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ main.py              # FastAPI application instance
β”‚   β”œβ”€β”€ database.py          # Database configuration
β”‚   β”œβ”€β”€ models.py            # SQLAlchemy models
β”‚   β”œβ”€β”€ schemas.py           # Pydantic schemas
β”‚   β”œβ”€β”€ auth.py              # Authentication utilities
β”‚   └── routers/
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ auth.py          # Authentication endpoints
β”‚       β”œβ”€β”€ customers.py     # Customer management
β”‚       β”œβ”€β”€ tickets.py       # Ticket operations
β”‚       β”œβ”€β”€ logs.py          # Communication logs
β”‚       β”œβ”€β”€ reports.py       # Analytics & reporting
β”‚       └── utils.py         # Authentication utilities
β”œβ”€β”€ crm.db                   # SQLite database (development)
β”œβ”€β”€ migrate_db.py            # Database migration script
β”œβ”€β”€ test_api.py              # API testing script
β”œβ”€β”€ requirements.txt         # Python dependencies
└── README.md               # Project documentation

πŸ—„ Database

Development

  • Database: SQLite (crm.db)
  • Location: Project root directory
  • Migration: Run python migrate_db.py

Production

For production environments, configure environment variables:

export DATABASE_URL="postgresql://user:password@localhost/crm_db"
# or
export DATABASE_URL="mysql://user:password@localhost/crm_db"

πŸ§ͺ Testing

Run the included test suite:

python test_api.py

This will test all major API endpoints and ensure functionality.

🚒 Deployment

Docker Deployment

FROM python:3.9-slim

WORKDIR /app
COPY app/requirements.txt .
RUN pip install -r requirements.txt

COPY . .
EXPOSE 8000

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

Environment Variables

Create a .env file for configuration:

DATABASE_URL=sqlite:///./crm.db
SECRET_KEY=your-secret-key-here
ACCESS_TOKEN_EXPIRE_MINUTES=30

🀝 Contributing

  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

Development Guidelines

  • Follow PEP 8 style guidelines
  • Write comprehensive docstrings
  • Add tests for new features
  • Update documentation as needed

πŸ“„ License

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

πŸ“ž Contact

Project Maintainer: [BROOKS]


⭐ Star this repository if you find it helpful!

Built with ❀️ using FastAPI and Python

About

Engineered a high-performance FastAPI backend for a support CRM, streamlining ticket management and automation with a secure, scalable RESTful API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages