File size: 1,904 Bytes
005a292
 
6532466
005a292
6532466
 
 
 
 
 
005a292
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6532466
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# CTP Slack Bot

## Tech Stack

* Hugging Face Spaces for hosting and serverless API
* Google Drive for reference data (i.e., the material to be incorporated into the bot’s knowledge base)
* MongoDB for data persistence
* Docker for containerization
* Python
    * See `pyproject.toml` for Python packages.

## General Project Structure

* `src/`
    * `ctp_slack_bot/`
        * `api/`: FastAPI application structure
        * `core/`: fundamental components like configuration (using pydantic), logging setup (loguru), and custom exceptions
        * `db/`: database connection
            * `repositories/`: repository pattern implementation
        * `models/`: Pydantic models for data validation and serialization
        * `services/`: business logic
        * `tasks/`: background scheduled jobs
        * `utils/`: reusable utilities
* `tests/`: unit tests
* `scripts/`: utility scripts for development, deployment, etc.
* `notebooks/`: Jupyter notebooks for exploration and model development

## How to Run the Application

### Normally

Just run the Docker image. 😉

### For Development

Development usually requires rapid iteration. That means a change in the code ought to be reflected as soon as possible in the behavior of the application.

First, make sure you are set up with a Python virtual environment created by the Python `venv` module and that it’s activated. Then install dependencies from `pyproject.toml` within the environment using:

```sh
pip3 install -e .
```

If `localhost` port `8000` is free, running the following will make the application available on that port:

```sh
scripts/run-dev.sh
```

You can check that it’s reachable by visiting [http://localhost:8000/health](http://localhost:8000/health).

```text
$ curl http://localhost:8000/health
{"status":"healthy"}
```

Uvicorn will restart the application automatically when any source files are changed.