Skip to content

nanakin/CRM-backend-OC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Internal Customer Relationship Management Software

Table Of Contents

Preamble

This application was designed for a school project with specific requirements and fixed constraints. For example, here client-server architecture was not an available option even though it would have been more appropriate for security reason. Conversely, CLI was a requirement. It was developed in a limited period of time and in this context this project is not intended be perfect and to evolve that much once finished. This project is not open to contribution. The following need is fictive.

About the project

Epic Events logo

Project context

Epic Events is a French company specialized in organizing events for professionals. The company has been growing for the past few years and the number of events organized has increased. The company has decided to develop an internal CRM (Customer Relationship Management) software to manage its customers and events. The company gave me the business requirements and I had to design and implement the database and develop the software.

Screenshots

crm --help
crm customer list
crm event detail
crm contract permission

About the project design

The application:

  • is a command line tool,
  • displays data with a nice terminal user interface (TUI),
  • authentications are session based: a token is created at login with a limited lifetime,
  • permissions are role-based and resource-based,
  • data are stored in a local database (schema available here),
  • subcommands were designed using DDD approach (Domain Driven Design) for business efficiency,
  • architecture is using the Model-View-Controller pattern to have a clear separation between the code manipulating data (model) and the one for the user interface (view),
  • is following security best practices (password hashing, JWT token, etc.),
  • errors are logged to a monitoring tool,
  • code is tested with unit tests and integration tests.

Other minor facts about the project:

  • compliant flake8,
  • documented with docstrings, CLI help and the "How To" part of this README,
  • managed by Poetry for virtual environment and dependencies,
  • configured using pyproject.toml,
  • formatted with black.

Technology

This application was tested with Python 3.11 and Poetry 1.5 (for the virtual environment and dependencies).

Main external dependencies:

Development dependencies:

Installation

  1. Clone this repository

    git clone https://github.com/nanakin/OC-P12-CRM.git CRM-project
  2. Move to the project directory

    cd CRM-project
  3. Install poetry if not installed yet, by following the official documentation here : https://python-poetry.org/docs/#installation

  4. Install project dependencies in a new virtual environment using poetry

    poetry install

    and use it

    poetry shell
  5. Start using crm tool

    crm --help
  6. Don't forget to consult the How to part

How To

This application is a command line tool. It is used with the crm command.

All available subcommand are:

See crm --help for more details, and crm <subcommand> --help for subcommand details.

Authentication

All CRM operation requires authentication.

  • To authenticate: crm auth login
    A 30 minutes session is created.
  • To logout: crm auth logout

See crm auth --help for more details.

Permissions

All authenticated users have - at least - read access to resources (employees, customers, contracts and events).

Employee

This application is designed to be used by authenticated employees. Depending on their role, they can perform different actions.

  • To list all employees: crm employee list
    A filter --role-filter is available to list only employees with a specific role.
  • To see employee's details: crm employee detail
  • To create a new employee: crm employee add
  • To set employee's role: crm employee set-role
  • To set employee's password: crm employee set-password
  • To update employee's details: crm employee update
    The fullname and the username can be updated by this command.
  • To delete an employee: crm employee delete

See crm employee <subcommand> --help for more details.

Permissions

Only administrator employees can perform write operations on employees.

Screenshots

'crm employee list' output
'crm employee list' output

Customer

Customers are one of the principal resource of this application. They are the one who order events (and sign/pay contracts) to the company. Each customer is associated with a commercial employee.

  • To list all customers: crm customer list
  • To see customer's details: crm customer detail
  • To create a new customer: crm customer add
  • To set customer's commercial employee: crm customer set-commercial
  • To update customer's details (fullname or username): crm customer update
    The fullname, the company, the email and the phone can be updated by this command.

See crm customer <subcommand> --help for more details.

Permissions

  • Only commercial employees can create customers. They can also modify their own customers.
  • Except set-commercial operation, which can be performed by an administrator employee.

Screenshots

'crm customer list' output
'crm customer detail' output

Contract

Contracts define the event(s) price and must be signed before organizing them.

  • To list all contracts: crm contract list
    Filters --not-signed-filter an --not-paid-filter are available to list only contracts with a specific status.
  • To see contract's details: crm contract detail
  • To create a new contract: crm contract add
  • To sign a contract: crm contract sign
  • To pay a contract: crm contract add-payment
  • To update contract's details: crm contract update
    The contract amount and customer can be updated by this command.

See crm contract <subcommand> --help for more details.

Permissions

  • Only administrator employees can create a new contract. They can also modify all contracts.
  • Commercial employees can only modify contracts associated with their customers.

Screenshots

'crm contract list' output
'crm contract detail' output

Event

Organizing events is the main purpose of this application. They are defined by many criteria (date, location, type, etc.) and must be associated with a contract.

  • To list all events: crm event list
    A filter --no-support-assigned is available to list only events without a support assigned.
  • To see event's details: crm event detail
  • To create a new event: crm event add
    The associated contract must be signed to allow this operation.
  • To assign a support to an event: crm event set-support
  • To update event's details: crm event update
    The event's name, date, location, attendees and note can be updated by this command.

See crm event <subcommand> --help for more details.

Permissions

  • Only commercial employees can create new events associated with their customers.
  • Only administrator employees can assign a support to an event.
  • Only support employees can update events associated with them.

Screenshots

'crm event list' output
'crm event detail' output

Server Configuration

DISCLAIMER: This file is not supposed to be versioned in a real-life project as a .env file typically wouldn't be.

Configuration is done via crm.toml file. It is located in the project root directory.

To enable/disable error tracing with sentry, change enabled boolean value, under error_tracing category, and set the dns key accordingly.

Available configuration options for database category are:

  • url: database url
  • echo: boolean to enable/disable SQLAlchemy echo mode
  • reset: boolean to enable/disable database reset on application start

Available option to populate database with fake data: populate boolean, under database_sample. Note that the application requires roles to be created before usage.

The JWT secret key is stored in 'authentication_secret_key option, under controller category.