Backend repo for our ClassTrack project
-
User registration (
POST /register) -
Login & token generation (
POST /login) -
Logout (
POST /logout) -
Password hashing & JWT authentication
-
Register: Luis
-
Login: Darren
-
Logout: Luis
-
Designing tables (users, posts, comments, etc.)
-
Setting up SQLAlchemy models
-
Writing Alembic migrations
-
Luis
-
Darren
-
Implementing API endpoints for main resources (e.g., posts, comments)
-
Writing database queries (async SQLAlchemy or raw SQL)
-
Dan
-
Luis
-
Darren
-
Writing unit tests with pytest
-
Handling errors properly (e.g., 404 for missing resources, 401 for unauthorized access)
- Luis
backend/
├── app/
│ ├── api/ # API endpoints
│ │ ├── v1/
│ │ │ ├── endpoints/
│ │ │ │ ├── auth.py # Login, register, logout
│ │ │ │ ├── users.py # CRUD for users
│ │ │ │ ├── posts.py # CRUD for posts
│ │ │ │ ├── __init__.py
│ │ │ ├── __init__.py
│ │ ├── __init__.py
│ │
│ ├── core/ # Configurations & security
│ │ ├── config.py # Settings (DB URL, secrets)
│ │ ├── security.py # Password hashing, JWT tokens
│ │ ├── database.py # DB connection setup
│ │ ├── __init__.py
│ │
│ ├── db/ # Database models & migrations
│ │ ├── models/
│ │ │ ├── user.py
│ │ │ ├── post.py
│ │ │ ├── __init__.py
│ │ ├── repositories/ # CRUD logic
│ │ │ ├── user_repo.py
│ │ │ ├── post_repo.py
│ │ │ ├── __init__.py
│ │ ├── migrations/ # Alembic migrations
│ │ ├── __init__.py
│ │
│ ├── tests/ # Automated tests
│ │ ├── test_auth.py
│ │ ├── test_users.py
│ │ ├── test_posts.py
│ │ ├── __init__.py
│ │
│ ├── main.py # Entry point
│ ├── dependencies.py # Shared dependencies
│ ├── __init__.py
│
├── alembic/ # Database migrations folder (Alembic)
├── .env # Environment variables
├── requirements.txt # Dependencies (FastAPI, asyncpg, etc.)
├── Dockerfile # Docker config for deployment
├── docker-compose.yml # PostgreSQL + FastAPI setup
├── .gitignore
main.py- Starts FastAPI app & includes routes
api/v1/endpoints/- API endpoints (routes)
-
core/config.py- Stores settings (DB URL, JWT secret) -
core/security.py- Password hashing & JWT authentication
-
db/models/- SQLAlchemy database models -
db/repositories/- Contains reusable database queries -
db/migrations/- Alembic migration scripts
tests/- Unit tests using pytest
-
Dockerfile- Defines the Docker container for the backend -
docker-compose.yml- Runs FastAPI + PostgreSQL locally
- FastAPI
-
Postgresql
-
asyncpg (Driver)
- Python
- Firebase Authentication
To run the postgres database, run the following command in the terminal:
docker compose up
To stop, run just press ctrl + c in the terminal window where you ran docker.
You can also run docker compose down in another terminal.
To run the fastapi server, run the following command in the terminal: Note: make sure to be in the root directory of the server
fastapi dev app/main.py