This is a simple RESTful API built with FastAPI and PostgreSQL, created as part of a technical test for HRflow.ai. The goal was to build a clean and functional job posting platform backend with user authentication and basic job management.
- Python 3.11
- FastAPI – web framework
- SQLAlchemy – ORM
- PostgreSQL – relational database
- JWT (PyJWT) – for authentication
- passlib[bcrypt] – for password hashing
- Pydantic – for data validation
- Pytest – for unit testing
app/
├── api/ # API routes
│ └── v1/
│ ├── auth.py # Auth endpoints (register/login)
│ └── job.py # Job CRUD endpoints
├── crud/ # DB logic (get, create, update)
├── auth/ # ha
├── models/
├── schemas/ # Pydantic schemas (request/response)
├── utils/ # Utility functions (none atm)
├── dependencies.py # Dependency overrides (used for testing)
├── database.py # DB connection & session
└── main.py # FastAPI app init and router setup
tests/
- Users can register with a username + password.
- Passwords are hashed using bcrypt before saving to the database.
- Users log in using OAuth2 form data, and get a JWT token on success.
- Auth-protected endpoints check this token to authorize access.
- Users can create, read, update, delete jobs.
- Each job has a title, description, owner, status, and timestamp.
- There's support for listing jobs with optional filtering by status or keyword.
- All tests use SQLite (in-memory) so the real DB isn’t touched.
- Authentication and job features have their own test files.
- The DB session is overridden during tests so it's completely isolated.
-
Install dependencies:
pip install -r requirements.txt
-
Set up PostgreSQL and
.env
:DATABASE_URL=postgresql://user:password@localhost:5432/hrflowai
-
Run the app:
uvicorn app.main:app --reload
-
Access the docs at: http://localhost:8000/docs
- I focused on keeping the code simple, readable, and modular.
- This was my first time building a Python/FastAPI backend, so I focused on learning the flow end-to-end.
- Code is decoupled, and every component is separated logically (routes, models, DB, utils).
- I also added helpful comments and chose names that make the code self-explanatory.