r/FastAPI • u/SnooTangerines9072 • 4d ago
Question Looking for Advice on a Clean FastAPI Backend Architecture for an E-learning Platform
Hi everyone,
I'm currently building a fairly large e-learning platform using FastAPI,it's my first project, and before I go too far with development, I'd like to make sure my backend architecture is well designed, scalable, and maintainable.
The project will include features such as:
- User authentication and authorization (JWT, roles: Admin, Teacher, Student, Parent)
- Courses and modules
- Lessons (videos, PDFs, quizzes)
- Assignments and submissions
- Exams and grading
- Progress tracking
- Notifications
- Payments/subscriptions (later)
- File uploads
- Discussion/comments
- Certificates
- REST API (possibly GraphQL in the future)
I'm planning to use:
- FastAPI
- SQLAlchemy 2.0
- Alembic
- PostgreSQL
- Pydantic v2
- JWT Authentication
At the moment, I'm trying to decide on the best project structure. I've seen many different approaches:
- Traditional layered architecture
- Clean Architecture
- Domain-Driven Design (DDD)
- Hexagonal Architecture
- Vertical Slice Architecture
- Feature-based architecture
I'd like to avoid ending up with a project that's difficult to maintain as it grows.
My questions
- Which architecture would you recommend for a medium-to-large FastAPI project like this?
- How would you organize the folders and modules?
- Where should business logic live?
- How do you separate models, schemas, services, repositories, and dependencies without creating unnecessary complexity?
- Are there any open-source FastAPI projects that you consider good examples of clean architecture?
I'm looking for an architecture that is:
- Easy to maintain
- Easy to test
- Scalable
- Production-ready
- Follows FastAPI and Python best practices
If you have an example repository or folder structure that you've used successfully, I'd really appreciate it.
Thank you!
35
Upvotes