Skip to content

Slightly-Techie/crm-api

Repository files navigation

CRM API

Status GitHub issues GitHub pull requests License


Backend API for Slightly Techie CRM

πŸ“ Table of Contents

Todo

See TODO

About

This project is a CRM API for Slightly Techie. It is built using these technologies.

🏁 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Poetry: Dependency manager for Python.
  • Postgres: A relational database.
  • Python 3.10^: The Python programming language.
  • AutoPEP8: An auto-formatter for Python code.

Setting up a development environment

Step 1: Clone the repository

https://github.com/Slightly-Techie/crm-api.git

or with GithubCLI

gh repo clone Slightly-Techie/crm-api

step 2: Install poetry if you don't have it already

# Linux, macOS, Windows (WSL)
curl -sSL https://install.python-poetry.org | python3 -
# Windows (PowerShell)
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -

Note: If you have installed Python through the Microsoft Store, replace py with python in the command above.

Reference: Poetry Installation

step 3: Create a virtual environment

virtualenv crmenv

OR by using the virtualenvwrapper

  mkvirtualenv crmenv

Activate the virtual environment with

  source crmenv/bin/activate

Step 4: Install dependencies

pip install -r requirements.txt

Note to add a package to the project, run

pip install <package-name>

Step 5: Create a .env file in the project's root directory and add the following environment variables, replacing the placeholders with your specific values:

POSTGRES_USER= #e.g postgres
POSTGRES_PASSWORD= #e.g password123
POSTGRES_SERVER= #e.g localhost
POSTGRES_PORT= #e.g 5432
POSTGRES_DB= #e.g st_crm_db
SECRET= #notasecretkey
BASE_URL= #http://127.0.0.1:8080/
[email protected]
EMAIL_PASSWORD=xxxxxxxxxxx
EMAIL_SERVER=smtp.gmail.com
EMAIL_PORT=587
AWS_ACCESS_KEY=xxxxxxxxxxxxx
AWS_SECRET_KEY=xxxxxxxxxxx
AWS_BUCKET_NAME=stncrmutilities
AWS_REGION=eu-west-1
URL_PATH=/users/reset-password/new-password

Step 6: Create a test.env file in the root directory and add the following environment variables

POSTGRES_USER= #e.g postgres
POSTGRES_PASSWORD= #e.g password123
POSTGRES_SERVER= #e.g localhost
POSTGRES_PORT= #e.g 5432
POSTGRES_DB= #e.g st_crm_db

Step 7: Start the uvicorn server

uvicorn app:app --reload

Step 8: Interact with the Database

To interact with the database, you can use tools like psql, pgAdmin or any database client that supports PostgreSQL. Here are some basic commands:

  • Connect to the database:
psql -U postgres -d st_crm_db
  • List all tables:
\d
  • Execute SQL queries:
SELECT * FROM table_name;

πŸ”§ Running the tests

To ensure the code is functioning correctly, you can run tests by executing the following command:

pytest

Make sure your test.env file is correctly configured with test-specific environment variables.

Running the project in Docker-Compose

  • Clone the project and from the main, create your feature branch if you are about to make changes. Else stay on the main branch
  • From the .env.sample create a .env file with the correct credentials
  • Ensure you have docker and docker compose installed on your local system
  • To build the docker image use
  docker-compose -f docker-compose.dev.yml build
  • To start the services
  doker-compose -f docker-compose.dev.yml up
  • A combination of build and start command is
  docker-compose -f docker-compose.dev.yml up --build
  • To run tests
  docker-compose -f docker-compose.dev.yml run --rm app sh -c "python -m pytest test"

βš™οΈ Project Structure

β”‚   app.py
β”‚   Dockerfile
β”‚   fly.toml
β”‚   poetry.lock
β”‚   pyproject.toml
β”‚   README.md
β”‚   test_app.py
β”‚   __init__.py
β”‚
β”œβ”€β”€β”€.github
β”‚   └───workflows
β”‚           build.yml
β”‚           fly.yml
β”‚
β”œβ”€β”€β”€Alembic
β”‚   β”‚   env.py
β”‚   β”‚   README
β”‚   β”‚   script.py.mako
β”‚
β”œβ”€β”€β”€api
β”‚   β”‚   __init__.py
β”‚   β”‚
β”‚   β”œβ”€β”€β”€api_models
β”‚   β”‚   β”‚   announcements.py
β”‚   β”‚   β”‚   skills.py
β”‚   β”‚   β”‚   stacks.py
β”‚   β”‚   β”‚   tags.py
β”‚   β”‚   β”‚   user.py
β”‚   β”‚
β”‚   β”œβ”€β”€β”€routes
β”‚   β”‚   β”‚   announcements.py
β”‚   β”‚   β”‚   auth.py
β”‚   β”‚   β”‚   feeds.py
β”‚   β”‚   β”‚   profile_page.py
β”‚   β”‚   β”‚   skills.py
β”‚   β”‚   β”‚   stacks.py
β”‚   β”‚   β”‚   tags.py
β”‚   β”‚   β”‚   techieotm.py
β”‚   β”‚   β”‚   __init__.py
β”‚
β”œβ”€β”€β”€core
β”‚   β”‚   config.py
β”‚   β”‚   exceptions.py
β”‚
β”œβ”€β”€β”€db
β”‚   β”‚   database.py
β”‚   β”‚   __init__.py
β”‚   β”œβ”€β”€β”€models
β”‚   β”‚    users.py
β”‚   └───repository
β”‚        users.py
β”œβ”€β”€β”€docs
β”‚       TODO.md
β”‚
β”œβ”€β”€β”€test
β”‚   β”‚   conftest.py
β”‚   β”‚   test_announcements.py
β”‚   β”‚   test_auth.py
β”‚   β”‚   test_feeds.py
β”‚   β”‚   test_profile_page.py
β”‚   β”‚   test_skills.py
β”‚   β”‚   test_stacks.py
β”‚   β”‚   test_tags.py
β”‚   β”‚   test_techieotm.py
β”‚   β”‚   test_users.py
β”‚   β”‚   utils_test.py
β”‚   β”‚   __init__.py
β”‚
└───utils
    β”‚   oauth2.py
    β”‚   permissions.py
    β”‚   utils.py
    β”‚   __init__.py

✏️ Contributing

We welcome contributions from the community. To contribute to the CRM API project, follow these guidelines:

Coding Standards

  • Follow the PEP 8 coding style for Python.
  • Ensure your code is well-documented with clear comments and docstrings.
  • Use meaningful variable and function names.

Branch Naming Conventions

Create a new branch for your feature or bug fix using the format below.

git checkout -b <initials/issue_no/feature> eg. # RG/121/Fixed-login-page

Pull Requests

  • Commit your changes to your branch with a clear and descriptive commit message:
git add .
git commit -m "Made this in this file"
  • Push your branch to the repository on GitHub:
git push -u origin <name-of-branch>
  • Open a pull request in the original repository, providing a detailed description of your changes and any relevant information.

please try building the project on your local machine to confirm everything works before pushing...Thanks

🎈 Usage

visit the API Documentation at https://crm-api.fly.dev/docs

⛏️ Built Using

✍️ Team

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 18

Languages