BlazinglySAC is a high-performance backend for a Student Activity Center (SAC) application, built with Rust and the Axum web framework. It provides a robust and scalable platform for managing student clubs, events, announcements, and other student-related activities.
- User Authentication: Secure user registration and login using JWT (JSON Web Tokens) with email verification.
- Profile Management: Users can view and manage their profiles.
- Council and Club Management: Admins can create and manage councils and clubs.
- Club Membership: Students can join and leave clubs.
- Announcements and Events: Club heads can create, update, and delete announcements and events for their respective clubs.
- Discussion Forum: Users can create threads and comments within clubs to foster discussions.
- File Uploads: Users can upload files, which are stored securely.
- Grievance System: Students can submit grievances, which can be reviewed by admins.
- Language: Rust
- Web Framework: Axum
- Database: PostgreSQL
- Async Runtime: Tokio
- Authentication: JWT (JSON Web Tokens)
- Password Hashing: bcrypt
- Database Toolkit: SQLx
- Serialization/Deserialization: Serde
BlazinglySAC is built with a focus on performance, scalability, and maintainability. The following are the core architectural and design principles:
- Modularity: The codebase is organized into modules, each responsible for a specific domain (e.g.,
auth,club,announcements). This separation of concerns makes the codebase easier to understand, maintain, and scale. - Layered Architecture: The application follows a classic layered architecture, with a clear separation between the API layer (Axum handlers), the business logic layer, and the data access layer (using
sqlx). - State Management: The application state, including the database connection pool and JWT secret, is managed in an
AppStatestruct and shared across handlers using Axum's state management capabilities. - Authentication and Authorization: JWT-based authentication is implemented as middleware to protect routes. Authorization is handled within each handler by checking the user's role or ownership of a resource.
- Error Handling: The application uses Axum's
IntoResponsetrait to handle errors and return appropriate HTTP status codes. - Asynchronous Programming: The entire application is built on top of the Tokio async runtime, enabling high concurrency and scalability.
The following is a list of the available API endpoints, grouped by module:
POST /auth/register: Register a new user.POST /auth/login: Log in a user and receive a JWT.GET /auth/whoami: Get the profile of the currently logged-in user.GET /auth/verify/:token: Verify user email with token.POST /auth/reverify/: Resend verification email.
GET /auth/whoami: Get the profile of the currently logged-in user.
POST /council/create: Create a new council (admin only).GET /council/list: Get a list of all councils.POST /council/update: Update a council (admin only).
GET /club/list: Get a list of all clubs.GET /club/list_my: Get the clubs the user is a member of.GET /club/list_my_applied: Get the clubs the user has applied to.POST /club/create: Create a new club (admin only).POST /club/update: Update a club.POST /club/join: Apply to join a club.GET /club/view_applications: View club join applications.POST /club/accept_application: Accept a club join application.GET /club/get_full: Get full details of a club.
GET /announcement/public: Get public announcements.GET /announcement/view: Get full announcements.POST /announcement/create: Create a new announcement.
GET /event/view: Get events.POST /event/create: Create a new event.
GET /conversation/threads: Get threads.POST /conversation/threads/new/: Create a new thread.POST /conversation/threads/like/: Like a thread.
GET /conversation/comments: Get comments.POST /conversation/comments/new/: Create a new comment.POST /conversation/comments/like/: Like a comment.
POST /media/upload/: Upload a file.GET /media/view: View file.GET /media/attachment: View attachment from ID.
POST /grievance/create: Submit a new grievance.GET /grievance/list: Get all grievances.
The database schema is managed using sqlx-cli and is defined in the migrations directory. The following are the main tables in the database:
user_profile: Stores user information.council: Stores information about student councils.club: Stores information about student clubs.membership: Stores the relationship between users and clubs.announcement: Stores announcements made by clubs.event: Stores events organized by clubs.thread: Stores threads for discussions within clubs.comment: Stores comments on threads.upload: Stores information about uploaded files.website_grievances: Stores grievances submitted by users.transportation: Stores transportation information.
For more details, please refer to the SQL files in the migrations directory.
To get a local copy up and running, follow these simple steps.
- Rust
- PostgreSQL
- sqlx-cli
- Clone the repo:
git clone https://github.com/your_username/blazinglySAC.git
- Navigate to the project directory:
cd blazinglySAC - Install the required Rust tools:
rustup component add rustfmt
- Set up the database:
- Create a PostgreSQL database.
- Create a
.envfile in the root of the project and add theDATABASE_URLandEMAIL_PASSWORDenvironment variables (seeEnvironment Variablessection below). - Run the database migrations:
sqlx migrate run
- Run the application:
cargo run
The application will be available at http://localhost:5000.
The following environment variables are required to run the application. Create a .env file in the root of the project and add the following:
DATABASE_URL=postgres://user:password@host:port/database
EMAIL_PASSWORD=your_email_password
To build the application for production, run the following command:
cargo build --releaseThe release binary will be located in the target/release directory.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request