I'm not sure exactly what you're asking. The only practically usable homeserver software right now is Synapse (https://github.com/matrix-org/synapse), an implementation in Python built by the Matrix core developer team.
I somehow didn't process the "it's a smartphone part" and completely misunderstood his question as a result. I'll edit my original reply to correct that. Edit: Apparently I can't edit it anymore. :{
Yes, it is possible. Ultimately, a homeserver is just a program that implements the client-server, and optionally the federation, APIs. The only feature-complete homeserver right now is Synapse, which is written in Python, and as of this moment has performance issues even running on a server, so it's not realistic that it could be modified to run on a phone. My homeserver Ruma is written in Rust, which is a systems language that actually is suited for mobile and embedded systems development, although I am currently not targeting that use case, nor is Ruma mature enough to be practically useful yet. If you're interested in the possibility of developing your own homeserver implementation specifically targeting your use case, you should take a look through the Matrix specification documents: https://matrix.org/docs/spec/