Generic Chat Service API

This is a FastAPI application that provides a backend for a generic chat service with invoice generation capabilities.

New Features

  • User authentication with JWT tokens
  • Client management
  • Invoice generation and management
  • Activity logging
  • PDF invoice generation
  • RESTful API with OpenAPI documentation

Tech Stack

  • FastAPI: Modern web framework for building APIs
  • SQLAlchemy: SQL toolkit and ORM
  • Alembic: Database migration tool
  • Pydantic: Data validation and settings management
  • SQLite: Lightweight database
  • JWT: JSON Web Token for authentication
  • Weasyprint: HTML to PDF conversion
  • Python 3.9+: Modern Python features

Project Structure

.
├── app/
│   ├── api/
│   │   ├── deps.py
│   │   └── v1/
│   │       ├── api.py
│   │       └── endpoints/
│   │           ├── auth.py
│   │           ├── clients.py
│   │           ├── invoices.py
│   │           └── users.py
│   ├── core/
│   │   ├── auth.py
│   │   ├── config.py
│   │   ├── logging.py
│   │   └── security.py
│   ├── crud/
│   │   ├── crud_client.py
│   │   ├── crud_invoice.py
│   │   └── crud_user.py
│   ├── db/
│   │   └── session.py
│   ├── models/
│   │   ├── activity.py
│   │   ├── base.py
│   │   ├── client.py
│   │   ├── invoice.py
│   │   └── user.py
│   ├── schemas/
│   │   ├── activity.py
│   │   ├── client.py
│   │   ├── invoice.py
│   │   ├── token.py
│   │   └── user.py
│   ├── services/
│   ├── static/
│   ├── templates/
│   └── utils/
│       ├── activity.py
│       └── pdf.py
├── migrations/
│   └── versions/
│       └── 001_initial_migration.py
├── alembic.ini
├── main.py
└── requirements.txt

Getting Started

Prerequisites

  • Python 3.9+
  • pip

Installation

  1. Clone the repository
git clone <repository-url>
cd <repository-name>
  1. Install dependencies
pip install -r requirements.txt
  1. Run database migrations
alembic upgrade head
  1. Start the server
uvicorn main:app --reload

The API will be available at http://localhost:8000

API Documentation

Authentication

The API uses JWT tokens for authentication. To obtain a token:

  1. Send a POST request to /api/v1/auth/login with your email and password
  2. Use the returned token in the Authorization header for subsequent requests

Endpoints

  • Auth: /api/v1/auth/

    • Login
    • Test token
  • Users: /api/v1/users/

    • Create user
    • Get users
    • Get user by ID
    • Update user
    • Delete user
  • Clients: /api/v1/clients/

    • Create client
    • Get clients
    • Get client by ID
    • Update client
    • Delete client
  • Invoices: /api/v1/invoices/

    • Create invoice
    • Get invoices
    • Get invoice by ID
    • Update invoice
    • Delete invoice
    • Generate PDF
  • Health Check: /health

    • Application health status

License

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

Description
Project: Generic Chat Service
Readme 63 KiB
Languages
Python 99.1%
Mako 0.9%