This is a sample backend project for collecting student exam answers.
You can play with the API in production at https://exam-depository.fly.dev/docs For demonstration purposes, you can obtain the API key from the appropriate route, see the documentation at the link above.
Any files you upload to the service will be stored in the EU and automatically deleted 3 days after upload.
- Rename the .envrc-example to .envrc and specify values for environment variables
- Load environment variables use
direnv allow
in the project's directory - Make sure that you have python and poetry installed with
asdf install
- Install project dependencies with
make deps
- Start PostgreSQL and MinIO containers with
make containers_up
- Migrate database with
make migrate_up
- Run tests with
make tests
, run server withmake server
After uploading submissions, you can view them in the MinIO web GUI on http://localhost:9000
Runtime errors associated with response code 500 can be found in the errors
table in the PostgreSQL database.
You can list them with the following command: psql postgresql://postgres:postgres@localhost:5432/exam_depository_dev -c "SELECT * FROM errors ORDER BY id DESC LIMIT 10;"
A push to the master
branch will automatically deploy the version of the app to Fly.io via the Github workflow.
The application persists students exam submissions and serves the submitted files for examiners to review the answers.
Authenticated examainers and unauthenticated students.
- Creates students and issues appropriate upload code to accept submissions
- Persists uploaded submission file and issues appropriate verification code
- Limits the size of a submission file to a maximum of 3MB
- Supports resubmission up to 5 times per student, automatically deletes previously persisted file
- Serves the earlier uploaded file for verification by verification code (no authorisation required)
- Scalability to handle peak loads
- Cost-effective performance maintenance strategies
- Good security practices to protect data and prevent unauthorised actions
- The application persists files on AWS S3 compatible data storage (Cloudflare R2)
- Uses PostgreSQL database to store list of students and submissions
- Using Fly.io to host the application on free tier plan
- Use CI/CD pipeline with GitHub Actions for deployment
- API key available through endpoint route
- Language: Python
- Web API: FastAPI, uvicorn
- Persistance: SQLAlchemy, boto3
- PostgreSQL, R2 for data storage
- Github Actions for deployment
- Fly.io for hosting
- Schema:
+-------------+ +------------+
| Application |----| PostgreSQL |
+-------------+ +------------+
| +---------------+
--------| Cloudflare R2 |
+---------------+
- Main Routes:
Method | Path | Purpose | Authentication? |
---|---|---|---|
GET | /strudents | Shows list of students and their submissions | Yes |
POST | /student | Creates a student | Yes |
POST | /submissions/{upload_code} | Uploads a submission file | No |
GET | /verifications/{verification_code}/download_url | Returns an URL to download the submission file | No |
- No route to bulk add student records with a CSV file, which can be added as needed
- The application exposes the API key through one of the routes that should be removed for production
Copyright © 2024 Ivan Rublev.
This project is licensed under the MIT license.