153 lines
3.4 KiB
Markdown
153 lines
3.4 KiB
Markdown
# 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
|
|
```bash
|
|
git clone <repository-url>
|
|
cd <repository-name>
|
|
```
|
|
|
|
2. Install dependencies
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Run database migrations
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
4. Start the server
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at http://localhost:8000
|
|
|
|
## API Documentation
|
|
|
|
- Swagger UI: http://localhost:8000/docs
|
|
- ReDoc: http://localhost:8000/redoc
|
|
|
|
## 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. |