a-ariff / a-ariff/rust-selfhost-server
Phase 1d: AppState and config loader integration (refs #3)
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Rust
- Stars
- 2
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Description
Implement AppState structure and config loader integration as part of Phase 1 database integration for issue #3.
Acceptance Criteria
- Create AppState struct with Database field
- Integrate Config::from_env() loader in main.rs
- Add proper error handling for configuration loading
- Initialize tracing before config loading
- Implement graceful application startup sequence
- Add AppState to Axum router with .with_state()
- Ensure all handlers can access database through State
- Add comprehensive logging for startup process
- Handle configuration errors with proper exit codes
- Test configuration loading with and without .env file
Technical Requirements
- Use Config::from_env() for environment variable loading
- Implement proper error propagation with anyhow::Result
- Add tracing logs for configuration and database initialization steps
- Structure AppState to be easily extensible for future services
- Follow Rust best practices for state management in web applications
Done Criteria
- AppState struct is properly defined and used
- Configuration loading works in both development and production environments
- All HTTP handlers can access database through AppState
- Startup sequence is logged with clear success/failure messages
- Tests pass for configuration loading scenarios
- Application exits gracefully on configuration errors
Related
- Parent: #3 (Implement database integration)
- Dependencies: #4 (sqlx driver), #5 (docker-compose), #6 (health endpoint)
- Part of: Phase 1 database integration implementation
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading main.rs and the Config::from_env() entry point, then trace the HTTP handlers and their current router setup. Implement the AppState-based startup and configuration flow, including logging and error handling; done means handlers access the database state and configuration tests cover environments with and without a .env file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, backend, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100