Coder Social home page Coder Social logo

kosanamsandeep / personify-service Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gnknithin/personify-service

0.0 0.0 0.0 140 KB

A server developed keeping the user application domain in mind for high scalability

License: GNU General Public License v3.0

Python 99.05% Makefile 0.72% Mako 0.20% Dockerfile 0.04%

personify-service's Introduction

Personify Service

Coverage Status

Introduction

A proof of concept of a highly scalable Personal Server. The application was developed keeping a personal utility of a user domain in mind, but the principles used can easily be applied to design software solutions for any domain. One of the primary challenges for a user application domain is the ability to expand as per requirement, giving the ability to explore more on top of existing. To do so, we have to architect the application supporting the scale. After understanding several different system architectures, a Domain-Driven Design was considered to meet the requirement. This approach holds Framework-Agnositic Design, PostgreSQL, MongoDB and Test Driven Development.

Development Environment

At the bare minimum you'll need the following for your development environment:

  1. Python
  2. PostgreSQL
  3. MongoDB

It is strongly recommended also to install and use the following tools:

  1. virtualenv

Local Setup

I have included the following for you to assume that you have all of the recommended tools listed above installed.

Clone the project:

$ git clone https://github.com/gnknithin/Personify-Service.git
$ cd Personify-Service

Create and initialize virtualenv for the project:

$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip3 install -r requirements.txt

Running the entire application stack

If you have docker-compose installed and docker running; it is really simple to spin up the entire application stack or use docker-compose as shown below.

Make sure you are in the root directory of the repository where the docker-compose file is.

Expected Environment Variables

All the environment variables for the application need to be specified in the docker-compose file, this allows us to separate environment configuration concerns from our application code meaning it can easily spin up for local, development and production environments with different db credentials, ports etc.

Create a .env as following

POSTGRES_HOST=localhost
POSTGRES_USER=personifydev
POSTGRES_PASSWORD=testenv@123
POSTGRES_DATABASE=personify
APPLY_MIGRATIONS=1
ALEMBIC_CONFIG=src/infra/data/migrations/alembic.ini
MONGODB_HOST=localhost
MONGODB_USERNAME=personifydev
MONGODB_PASSWORD=testenv@123
MONGODB_DATABASE=personify

Up Infrastructure:

docker-compose -f ./docker-compose.dev.yml up -d --force-recreate --renew-anon-volumes

To Run Server:

python3 src/server.py -p 8888 -c ./configs/development.yaml -d

To Stop Run Server:

press Cntrl + c

To Stop

docker-compose -f ./docker-compose.dev.yml down --remove-orphans

Tests and Code Coverage

Installing Dependencies and checking

pip3 install pytest pytest-asyncio pytest-cov pytest-dotenv

Unit Tests and Code Coverage

pytest -vv --cov --cov-report=term-missing ./tests/unit

Integration Tests and Code Coverage

pytest -vv --cov --cov-report=term-missing ./tests/integration

End2End Tests and Code Coverage

pytest -vv --cov --cov-report=term-missing ./tests/e2e

Code Coverage

pytest -vv --cov --cov-report=term-missing

Linting

Installing Dependencies and checking

pip3 install ruff
ruff check .

Type Checking

Installing Dependencies and checking

pip3 install mypy
mypy .

Working Features

Once you run the entire application stack using docker-compose, you should be able to access the public routes below:

Feature Type Route Access
Health Check GET http://localhost:8888/health Public
Add a new user POST http://localhost:8888/api/v1/signup Public
Authenticate a user POST http://localhost:8888/api/v1/signup Public
Get all contacts GET http://localhost:8888/api/v1/contact Protected
Add a new contact POST http://localhost:8888/api/v1/contact Protected
Get a specific contact GET http://localhost:8888/api/v1/contact/{contact_id} Protected
Update a specific contact PUT http://localhost:8888/api/v1/contact/{contact_id} Protected
Delete a specific contact DELETE http://localhost:8888/api/v1/contact/{contact_id} Protected

Highlights

  • Documentation - Swagger
  • Code Coverage
  • Markdown Diagrams
  • Ruff Linting
  • MyPy Typing
  • Testing
    • Unit Testing
    • Integration Testing
    • End2End Testing
    • Postman
  • Deployment Solution and Documentation
  • Final: Production READY

Project Links

License

GNU General Public License v3.0. See the bundled LICENSE file for more details.

personify-service's People

Contributors

gnknithin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.