A full-stack blog application with a FastAPI backend and Vue.js frontend.
- RESTful API with FastAPI
- JWT-based authentication
- PostgreSQL database with SQLModel ORM
- User management (CRUD operations)
- Post management (CRUD operations)
- Voting system (upvote/downvote)
- Database migrations with Alembic
- Modern Vue.js 3 with Composition API
- Responsive design
- User authentication (register/login)
- Post management interface
- Voting functionality
- Search posts
- Real-time updates
.
├── app/ # FastAPI backend
│ ├── routers/ # API route handlers
│ │ ├── auth.py # Authentication endpoints
│ │ ├── post.py # Post endpoints
│ │ ├── user.py # User endpoints
│ │ └── vote.py # Voting endpoints
│ ├── main.py # FastAPI app initialization
│ ├── models.py # Database models
│ ├── schemes.py # Pydantic schemas
│ ├── database.py # Database connection
│ ├── config.py # Configuration settings
│ ├── auth2.py # JWT authentication logic
│ └── utils.py # Utility functions
├── frontend/ # Vue.js frontend
│ ├── src/
│ │ ├── components/ # Vue components
│ │ ├── views/ # Page views
│ │ ├── router/ # Router configuration
│ │ └── services/ # API services
│ └── ...
├── alembic/ # Database migrations
├── requirements.txt # Python dependencies
└── README.md # This file
- Python 3.8+
- Node.js 14+
- PostgreSQL database
- pip and npm
- Clone the repository:
git clone <repository-url>
cd Fastapi- Create a virtual environment:
python -m venv env
source env/bin/activate # On Windows: env\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Set up environment variables:
Create a
.envfile in the root directory with the following:
DATABASE_HOSTNAME=localhost
DATABASE_PORT=5432
DATABASE_NAME=fastapi_db
DATABASE_USERNAME=your_username_here
DATABASE_PASSWORD=your_password_here
SECRET_KEY=your-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
- Run database migrations:
alembic upgrade head- Start the FastAPI server:
uvicorn app.main:app --reloadThe API will be available at http://localhost:8000
API documentation: http://localhost:8000/docs
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Start the development server:
npm run devThe frontend will be available at http://localhost:5173
POST /login- User login
POST /users/- Create user (register)GET /users/- Get all usersGET /users/{id}- Get user by IDPUT /users/{id}- Update userDELETE /users/{id}- Delete user
GET /posts/- Get all posts (with pagination and search)POST /posts/- Create post (authenticated)GET /posts/{id}- Get post by IDPUT /posts/{id}- Update post (authenticated, owner only)DELETE /posts/{id}- Delete post (authenticated, owner only)
POST /vote/- Vote on a post (authenticated)dir: 1to upvotedir: 0to remove vote/downvote
- Start the backend server (port 8000)
- Start the frontend server (port 5173)
- Open
http://localhost:5173in your browser - Register a new account
- Create, view, and vote on posts!
- Framework: FastAPI
- ORM: SQLModel
- Database: PostgreSQL
- Authentication: JWT (PyJWT)
- Password Hashing: bcrypt
- Framework: Vue.js 3
- Build Tool: Vite
- HTTP Client: Axios
- Routing: Vue Router
- State: Composition API (ref, computed)
Contributions are welcome! Please feel free to submit a Pull Request.
This repository uses branch protection rules to maintain code quality and prevent accidental changes. Please see BRANCH_PROTECTION.md for details on:
- How branch protection is configured
- How to apply protection rules
- Working with protected branches
- Creating pull requests
This project is open source and available under the MIT License.