<<<<<<< HEAD
A secure, database-backed RESTful API for managing a course enrollment platform using FastAPI.
- User authentication and authorization with JWT
- Role-based access control (Student/Admin)
- Course management
- Enrollment management with business rules
- Comprehensive automated tests
- Clone the repository (if applicable) and navigate to the project directory.
A secure, database-backed RESTful API for managing course enrollments using FastAPI.
Key features
- JWT authentication
- Role-based access control (student / admin)
- Course and enrollment management with business rules
- PostgreSQL + SQLAlchemy with Alembic migrations
- Comprehensive automated tests (pytest)
Quickstart
- Create and activate a virtual environment:
python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
source venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Copy environment file and fill secrets:
cp .env.example .env
- Run migrations:
alembic upgrade head- Run the app:
uvicorn app.main:app --reloadInteractive docs: https://final-captone-project.onrender.com/docs Deployment: Render
Testing Run the automated test suite:
pytestEnvironment
- Provide a
DATABASE_URLpointing to a PostgreSQL instance. Example format:postgresql://user:password@host:5432/dbname SECRET_KEYmust be a securely generated random string. Do not commit.envto VCS.
API Endpoints (overview)
- Authentication
POST /users/register— registerPOST /users/login— obtain JWTGET /users/me— current user (authenticated)
- Courses
GET /courses/— list active courses (authenticated)GET /courses/{course_id}— get course (authenticated)POST /courses/— create course (admin)PUT /courses/{course_id}— update course (admin)DELETE /courses/{course_id}— delete course (admin, only if no enrollments)
- Enrollments
POST /enrollments/— enroll (student)DELETE /enrollments/{course_id}— deregister (student)GET /enrollments/my-enrollments— view own enrollments (student)GET /enrollments/all— view all enrollments (admin)GET /enrollments/course/{course_id}— view enrollments by course (admin)DELETE /enrollments/admin/{course_id}/user/{user_id}— remove student (admin)DELETE /enrollments/admin/{course_id}— bulk remove students byuser_ids(admin)
Business rules enforced
- Unique emails for users
- Unique course codes
- Course
capacitymust be > 0 - Only active users may authenticate
- Students cannot enroll twice in the same course
- Enrollment fails if course is full or inactive
Notes
- Migrations are handled via Alembic (
alembic/versionspresent). - The repository should not contain secrets. Use
.env.examplefor sharing config structure.
If you'd like, I can also add a CI workflow to run migrations and tests automatically.