A simple backend-only service for creating posts and comments using FastAPI, SQLAlchemy, and Alembic.
- Create posts
- Add comments to posts
- Retrieve posts and their comments
- pip install -r requirements.txt
-
Clone the repository:
git clone https://github.com/yourusername/post-comments-service.git cd Simple-post-comments-service
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Set up the database:
Generate an Alembic migration:
alembic revision --autogenerate -m "Initial migration"
Apply the migration to create the database tables:
alembic upgrade head
-
Start the FastAPI server:
uvicorn app.main:app --reload
-
Access the API documentation:
Open your browser and navigate to
http://127.0.0.1:8000/docs
to access the interactive API documentation provided by Swagger UI.