Backend API for the Stratos Learning Management System, built with FastAPI and a strict MVC pattern.
- Framework: FastAPI
- Server: Uvicorn
- ORM: SQLAlchemy
- Database Migrations: Alembic
- Database: PostgreSQL
- Authentication: JWT (JSON Web Tokens)
- Validation: Pydantic
stratos_backend/
├── alembic/ # Database migration scripts
├── app/
│ ├── controllers/ # API Routers & Business Logic (The 'C' in MVC)
│ ├── models/ # SQLAlchemy Database Models (The 'M' in MVC)
│ ├── views/ # Pydantic Schemas (The 'V' in MVC)
│ ├── utils/ # Utility functions & helpers
│ ├── database.py # Database connection & session management
│ └── main.py # Application entry point
├── .env # Environment variables
├── alembic.ini # Alembic configuration
└── requirements.txt # Project dependencies
- Python 3.10+
- PostgreSQL
-
Clone the repository:
git clone <repository-url> cd stratos/stratos_backend
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure Environment Variables: Create a
.envfile in the root of thestratos_backenddirectory:DATABASE_URL=postgresql://user:password@localhost:5432/stratos_db SECRET_KEY=your_super_secret_key ALGORITHM=HS256 ACCESS_TOKEN_EXPIRE_MINUTES=30
- Create the database in PostgreSQL.
- Run migrations to create the tables:
alembic upgrade head
Start the development server:
uvicorn app.main:app --reloadThe API will be available at http://localhost:8000.
FastAPI provides interactive API documentation automatically:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
POST /auth/register: Register a new userPOST /auth/login: Login and receive an access tokenGET /api/v1/health: Health checkGET /api/v1/courses: List all coursesPOST /api/v1/courses: Create a new course (Teacher only)