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.
- Features
- Technology Stack
- Prerequisites
- Installation
- Usage
- API Documentation
- Project Structure
- Database
- Testing
- Deployment
- Contributing
- License
- Contact
- JWT-based authentication system
- Role-based access control (Agent, Admin)
- Secure password hashing with bcrypt
- Token-based API access
- Complete CRUD operations for customer profiles
- Customer search and filtering capabilities
- Customer data validation and integrity
- Create and manage support tickets
- Priority levels (Low, Medium, High, Urgent)
- Status tracking (Open, In-Progress, Resolved, Closed)
- Agent assignment functionality
- Track all customer interactions
- Support for multiple communication types (Call, Email, Chat)
- Timestamped log entries
- Ticket association for context
- Ticket status summaries
- Agent workload distribution
- Response time analytics
- Dashboard-ready JSON responses
- 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
- Python 3.8 or higher
- pip package manager
- SQLite (included with Python) or PostgreSQL/MySQL for production
git clone https://github.com/BROOKS69/support-crm-backend.git
cd support-crm-backend# Create virtual environment
python -m venv .venv
# Activate virtual environment
# On Windows:
.venv\Scripts\activate
# On macOS/Linux:
source .venv/bin/activatepip install -r app/requirements.txtpython migrate_db.pyThis will create the necessary database tables and set up the initial schema.
Start the development server with auto-reload:
uvicorn app.main:app --reloadThe server will start at http://localhost:8000
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:8000Once 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
| 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 |
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: SQLite (
crm.db) - Location: Project root directory
- Migration: Run
python migrate_db.py
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"Run the included test suite:
python test_api.pyThis will test all major API endpoints and ensure functionality.
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"]Create a .env file for configuration:
DATABASE_URL=sqlite:///./crm.db
SECRET_KEY=your-secret-key-here
ACCESS_TOKEN_EXPIRE_MINUTES=30- 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
- Follow PEP 8 style guidelines
- Write comprehensive docstrings
- Add tests for new features
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE file for details.
Project Maintainer: [BROOKS]
- Email: [email protected]
- GitHub: @BROOKS69
- LinkedIn: Your LinkedIn Profile
β Star this repository if you find it helpful!
Built with β€οΈ using FastAPI and Python