|
1 | | -# Scalable FastAPI Application with Docker and PostgreSQL Integration |
2 | | - |
3 | | -**A FastAPI project integrated with Docker and PostgreSQL for seamless deployment and efficient API development.** |
4 | | - |
5 | | ---- |
6 | | - |
7 | | -## 🚀 Features |
8 | | -- **FastAPI**: A modern web framework for building APIs with Python. |
9 | | -- **PostgreSQL**: A robust and reliable database system. |
10 | | -- **Docker & Docker Compose**: Simplifies containerization and orchestration. |
11 | | -- **Healthcheck Integration**: Ensures services are running and dependencies are healthy. |
12 | | -- **Easy Setup**: Start the project with minimal configuration. |
13 | 1 |
|
14 | | ---- |
| 2 | +# Scalable FastAPI Application with Docker and PostgreSQL Integration |
15 | 3 |
|
16 | | -## 📦 Project Structure |
| 4 | +## Overview |
| 5 | +This project demonstrates a scalable API solution using FastAPI, Docker, and PostgreSQL. It includes CI/CD integration via GitHub Actions to ensure code quality and smooth deployments. |
17 | 6 |
|
18 | | -``` |
| 7 | +## Project Structure |
| 8 | +```plaintext |
19 | 9 | mystrotamer-FastAPI-Docker/ |
20 | 10 | ├── app/ |
21 | | -│ ├── main.py # FastAPI main application file |
22 | | -│ ├── Dockerfile # Docker configuration for the app |
23 | | -│ ├── requirements.txt # Python dependencies |
24 | | -├── docker-compose.yml # Docker Compose configuration |
25 | | -├── .env.example # Example environment variables |
26 | | -├── README.md # Project documentation |
27 | | -└── LICENSE # Project license |
| 11 | +│ ├── __init__.py # Initialize the app module |
| 12 | +│ ├── main.py # FastAPI main application file |
| 13 | +│ ├── Dockerfile # Docker configuration for the app |
| 14 | +│ ├── requirements.txt # Python dependencies |
| 15 | +│ ├── wait-for-it.sh # Script to wait for dependencies |
| 16 | +├── db/ |
| 17 | +│ ├── init.sql # SQL script for database initialization |
| 18 | +│ ├── Dockerfile # Docker configuration for the database |
| 19 | +├── tests/ |
| 20 | +│ ├── __init__.py # Initialize the tests module |
| 21 | +│ ├── test_main.py # Test cases for the main app |
| 22 | +├── docker-compose.yml # Docker Compose configuration |
| 23 | +├── .env.example # Example environment variables |
| 24 | +├── LICENSE # Project license |
| 25 | +└── README.md # Project documentation |
28 | 26 | ``` |
29 | 27 |
|
30 | | ---- |
31 | | - |
32 | | -## 🛠️ Setup and Installation |
| 28 | +## Technologies Used |
| 29 | +- **FastAPI**: For building modern and fast APIs. |
| 30 | +- **Docker & Docker Compose**: To simplify deployment and runtime environment using containers. |
| 31 | +- **PostgreSQL**: A robust relational database system. |
| 32 | +- **GitHub Actions**: For CI/CD automation. |
33 | 33 |
|
34 | | -### **Prerequisites** |
35 | | -- [Docker](https://www.docker.com/) |
36 | | -- [Docker Compose](https://docs.docker.com/compose/) |
37 | | -- Git |
38 | | - |
39 | | ---- |
40 | | - |
41 | | -### **Steps** |
42 | | - |
43 | | -1. **Clone the repository:** |
| 34 | +## Setup and Installation |
| 35 | +1. Clone this repository: |
44 | 36 | ```bash |
45 | | - git clone https://github.com/mystrotamer/mystrotamer-FastAPI-Docker.git |
46 | | - cd mystrotamer-FastAPI-Docker |
| 37 | + git clone https://github.com/TamerOnLine/MystroTamer-FastAPI-Docker.git |
47 | 38 | ``` |
48 | | - |
49 | | -2. **Copy the environment file and set the variables:** |
| 39 | +2. Navigate to the project directory: |
50 | 40 | ```bash |
51 | | - cp .env.example .env |
| 41 | + cd MystroTamer-FastAPI-Docker |
52 | 42 | ``` |
| 43 | +3. Copy the `.env.example` file to `.env` and update the environment variables as needed. |
53 | 44 |
|
54 | | -3. **Start the services:** |
| 45 | +4. Start the services using Docker Compose: |
55 | 46 | ```bash |
56 | | - docker-compose up -d |
| 47 | + docker-compose up --build |
57 | 48 | ``` |
58 | 49 |
|
59 | | -4. **Access the application:** |
60 | | - - API Documentation: [http://localhost:8000/docs](http://localhost:8000/docs) |
61 | | - - Application: [http://localhost:8000](http://localhost:8000) |
62 | | - |
63 | | ---- |
64 | | - |
65 | | -## 🗄️ Environment Variables |
66 | | - |
67 | | -Ensure you configure the `.env` file before starting the project: |
| 50 | +5. Access the application at `http://localhost:8000`. |
68 | 51 |
|
69 | | -```env |
70 | | -POSTGRES_USER=postgres |
71 | | -POSTGRES_PASSWORD=your_password |
72 | | -POSTGRES_DB=fastapi_db |
73 | | -POSTGRES_HOST=db |
74 | | -POSTGRES_PORT=5432 |
75 | | -DATABASE_URL=postgresql://postgres:your_password@db:5432/fastapi_db |
| 52 | +## Running Tests |
| 53 | +Run the following command to execute the tests: |
| 54 | +```bash |
| 55 | +pytest tests/ |
76 | 56 | ``` |
77 | 57 |
|
78 | | ---- |
79 | | - |
80 | | -## 📋 API Endpoints |
81 | | - |
82 | | -| Endpoint | Method | Description | |
83 | | -|----------------|--------|-------------------------| |
84 | | -| `/items` | GET | Retrieve all items | |
85 | | -| `/items` | POST | Add a new item | |
86 | | -| `/items/{id}` | GET | Retrieve an item by ID | |
87 | | -| `/items/{id}` | PUT | Update an item by ID | |
88 | | -| `/items/{id}` | DELETE | Delete an item by ID | |
89 | | - |
90 | | ---- |
91 | | - |
92 | | -## 🛡️ License |
93 | | - |
94 | | -This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
95 | | - |
96 | | ---- |
97 | | - |
98 | | -## 👤 Author |
99 | | - |
100 | | -- **Mystro Tamer** |
101 | | - - [GitHub](https://github.com/mystrotamer) |
102 | | - - [Website](https://www.mystrotamer.com) |
103 | | - |
104 | | ---- |
105 | | - |
106 | | -## ⭐ Contribute |
107 | | - |
108 | | -Contributions are welcome! Feel free to open an issue or submit a pull request. |
109 | | - |
110 | | ---- |
111 | | - |
112 | | -## 🛠️ CI/CD |
113 | | - |
114 | | -This project uses **GitHub Actions** to automate testing and deployment. The workflow file is located in `.github/workflows/ci.yml`. |
| 58 | +## Future Improvements |
| 59 | +- Add Redis for caching. |
| 60 | +- Integrate user authentication and authorization. |
| 61 | +- Deploy the application on a cloud platform like AWS or Azure. |
115 | 62 |
|
116 | | ---- |
| 63 | +## 🤝 Contributing |
| 64 | +- Open an issue if you encounter bugs or have suggestions. |
| 65 | +- Submit a pull request for any improvements or new features. |
117 | 66 |
|
118 | | -## 📈 Future Improvements |
119 | | -- Add caching with **Redis** for faster response times. |
120 | | -- Deploy the project to a cloud provider like AWS or GCP. |
121 | | -- Implement user authentication and authorization. |
| 67 | +## License |
| 68 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
0 commit comments