|
1 | | -# MiBook-Server |
| 1 | +# 📚 MiBook-Server |
| 2 | + |
| 3 | +A modern RESTful API server built with FastAPI for managing family recipes and cookbook collections. |
| 4 | + |
| 5 | +## 🚀 Tech Stack |
| 6 | + |
| 7 | +- **FastAPI** - Modern, fast web framework for building APIs |
| 8 | +- **PostgreSQL** - Powerful relational database |
| 9 | +- **Redis** - In-memory cache for improved performance |
| 10 | +- **Docker** - Containerization for easy deployment |
| 11 | +- **Python 3.13** - Latest Python version |
| 12 | + |
| 13 | +## 📋 Prerequisites |
| 14 | + |
| 15 | +Before running this project, make sure you have installed: |
| 16 | + |
| 17 | +- 🐳 [Docker](https://www.docker.com/get-started) (version 20.10 or higher) |
| 18 | +- 🐳 [Docker Compose](https://docs.docker.com/compose/install/) (version 2.0 or higher) |
| 19 | + |
| 20 | +## 🛠️ Installation & Setup |
| 21 | + |
| 22 | +1. **Clone the repository** |
| 23 | + ```bash |
| 24 | + git clone <repository-url> |
| 25 | + cd MiBook-Server |
| 26 | + ``` |
| 27 | + |
| 28 | +## 🚀 Running the Project |
| 29 | + |
| 30 | +### Using Docker Compose (Recommended) |
| 31 | + |
| 32 | +1. **Start all services** |
| 33 | + ```bash |
| 34 | + docker-compose up --build |
| 35 | + ``` |
| 36 | + |
| 37 | +2. **The API will be available at:** |
| 38 | + - 🌐 API: http://localhost:8000 |
| 39 | + - 📊 Interactive API Docs: http://localhost:8000/docs |
| 40 | + - 📚 Alternative API Docs: http://localhost:8000/redoc |
| 41 | + |
| 42 | +3. **Stop the services** |
| 43 | + ```bash |
| 44 | + docker-compose down |
| 45 | + ``` |
| 46 | + |
| 47 | +### Running in Development Mode |
| 48 | + |
| 49 | +The project is configured to run in development mode with hot-reload enabled. Any changes you make to the code will automatically restart the server. |
| 50 | + |
| 51 | +## 📦 Services |
| 52 | + |
| 53 | +The project includes three main services: |
| 54 | + |
| 55 | +| Service | Port | Description | |
| 56 | +|---------|------|-------------| |
| 57 | +| 🚀 **API** | 8000 | FastAPI application server | |
| 58 | +| 🗄️ **PostgreSQL** | 5432 | Database server | |
| 59 | +| ⚡ **Redis** | 6379 | Cache server | |
| 60 | + |
| 61 | +## 🗂️ Project Structure |
| 62 | + |
| 63 | +``` |
| 64 | +MiBook-Server/ |
| 65 | +├── src/ |
| 66 | +│ ├── main.py # FastAPI application entry point |
| 67 | +│ └── ... |
| 68 | +├── db-data/ # PostgreSQL data (auto-generated) |
| 69 | +├── docker-compose.yml # Docker services configuration |
| 70 | +├── Dockerfile # API service container configuration |
| 71 | +├── requirements.txt # Python dependencies |
| 72 | +└── README.md # Project documentation |
| 73 | +``` |
| 74 | + |
| 75 | +## 🔧 Development |
| 76 | + |
| 77 | +### Running Tests |
| 78 | + |
| 79 | +```bash |
| 80 | +docker-compose exec api pytest |
| 81 | +``` |
| 82 | + |
| 83 | +### Code Formatting |
| 84 | + |
| 85 | +```bash |
| 86 | +docker-compose exec api black . |
| 87 | +``` |
| 88 | + |
| 89 | +### Linting |
| 90 | + |
| 91 | +```bash |
| 92 | +docker-compose exec api flake8 |
| 93 | +``` |
| 94 | + |
| 95 | +## 🌍 Environment Variables |
| 96 | + |
| 97 | +| Variable | Default | Description | |
| 98 | +|----------|---------|-------------| |
| 99 | +| `DB_HOST` | db | Database host | |
| 100 | +| `DB_NAME` | family_recipes | Database name | |
| 101 | +| `DB_USER` | postgres | Database user | |
| 102 | +| `DB_PASS` | postgres | Database password | |
| 103 | +| `DB_PORT` | 5432 | Database port | |
| 104 | +| `DEBUG` | - | Enable debug mode | |
| 105 | +| `SECRET_KEY` | - | Application secret key | |
| 106 | +| `ALLOWED_HOSTS` | - | Allowed hosts for CORS | |
| 107 | + |
| 108 | +## 📝 API Endpoints |
| 109 | + |
| 110 | +- `GET /` - Welcome message |
| 111 | +- `GET /docs` - Swagger UI documentation |
| 112 | +- `GET /redoc` - ReDoc documentation |
| 113 | + |
| 114 | +## 🤝 Contributing |
| 115 | + |
| 116 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 117 | + |
| 118 | +## 📄 License |
| 119 | + |
| 120 | +This project is licensed under the terms specified in the LICENSE file. |
| 121 | + |
| 122 | +## 👤 Author |
| 123 | + |
| 124 | +**Luis Silva** |
| 125 | +- Email: luisgsilva26@gmail.com |
| 126 | + |
| 127 | +--- |
| 128 | + |
| 129 | +Made with ❤️ using FastAPI |
0 commit comments